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 |
---|---|---|
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 .
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
.
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
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.
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}
}