Skip to content

Code for extracting a circular mask from fundus images and tightly cropping the images around the mask.

License

Notifications You must be signed in to change notification settings

berenslab/fundus_circle_cropping

Repository files navigation

DOI

Overview

Fundus images are processed by (1) finding a circular mask with least-squares expectation-maximization fitting of a circle to the image edges, and (2) cropping the image tightly around the found circle.

With this preprocessing method, all images are equally centered, some background pixels are removed, and a boolean mask of the extracted circle is stored.

original cropped mask

Installation

Setup a python environment with a python version between >=3.6 and <3.12. Then, install all the other dependencies directly from source

git clone https://github.com/berenslab/fundus_circle_cropping
cd fundus_circle_cropping
pip install -e .

Basic example

Download some example data of healthy fundus images from https://www5.cs.fau.de/research/data/fundus-images/ with a bash script

bash download_data/download.sh

This will create a data/images folder to store the images and an image identity file data/ids.lst with a list of filenames.

To crop the downloaded fundus images, run the sample script crop.py, which expects a configuration basic_example.yaml and runs over the downloaded data.

python crop.py -c ./configs/basic_example.yaml

The preprocessed images are stored in data/images_cropped and the corresponding circular masks in data/masks.

Parallel processing with ray

Since the image preprocessing of images can be run independently, we also support code parallel processing with ray. We have one example configuration file ray_eyample.yaml on how to run that.

python crop.py -c ./configs/ray_example.yaml

Note

If you run the code on other retinal fundus datasets, adjust the root_folder in the config file and provide a text file with image names. The preprocessing parameters were optimized with the kaggle-dr-dataset and may need to be adjusted for other datasets.

Cite

If you use this software, please cite it as below.

@software{mueller_fundus_circle_cropping_2023,
  author = {M\"uller, Sarah and Heidrich, Holger and Koch, Lisa M. and Berens, Philipp},
  doi = {10.5281/zenodo.10137935},
  title = {fundus circle cropping},
  url = {https://github.com/berenslab/fundus_circle_cropping},
  version = {0.2.0},
  year = {2023}
}

About

Code for extracting a circular mask from fundus images and tightly cropping the images around the mask.

Resources

License

Stars

Watchers

Forks

Packages

No packages published