0

I am working on Diabetic Retinopathy detection. The database comprises of 2D images that looks like this one:

Original Image

Now, I want to extract just the retina part from the images so that the final image looks like this one:

New image

I have tried Canny and HoughCircles but it failed. Is there any way to extract this region using OpenCv or scikit-image or PIL?

enterML
  • 2,110
  • 4
  • 26
  • 38
  • 4
    Possible duplicate of [Crop black edges with OpenCV](https://stackoverflow.com/questions/13538748/crop-black-edges-with-opencv) – zteffi Jul 01 '19 at 11:31

1 Answers1

2

Since the foreground is so obvious, you can use simple thresholding to find it and then use regionprops to get the crop you need:

from skimage import io, color, filters, measure

image = io.imread('https://i.stack.imgur.com/kKBiU.jpg')
grayscale = color.rgb2gray(image)
foreground = (grayscale > filters.threshold_otsu(grayscale)).astype(int)
foreground_properties = measure.regionprops(foreground)[0]
cropped = image[foreground_properties.slice]
Juan
  • 5,433
  • 21
  • 23