Automatically extracting the optic disc area in fundus images

Automatically extracting the optic disc area in fundus images

My master’s supervisor, Mohammad Amin Shayegan, once asked me to help two of his master’s students with a data annotation tool. They were working with fundus images and needed bounding boxes around the optic disc.

Rather than manually labeling hundreds of images, I tried a more automated approach. From the literature, threshold methods could work, but picking the right threshold was the hard part. Using two known properties of the optic disc — it’s roughly circular, and its size relative to the eye is fairly consistent — I wrote an OpenCV pipeline that sweeps threshold values until the detected region matches those expectations.

Once that worked, I used the algorithm to auto-label the dataset and trained a ResNet34 with SmoothL1Loss to predict the top-left and bottom-right corners of the optic disc. Normalizing every image to a fixed size made the regression tractable.

Results of the deep learning model:

Deep learning model results

I handed the labeled data over to the students and never followed up on what they ended up doing with it. On my end, this was one of my first attempts at auto-labeling images — and I’d like to do more of it in the future, since I still have a soft spot for classic computer vision and hand-crafted feature extractors!

Code: github.com/mh-salari/self_training_optic_disc_localization