Search code examples
opencvimage-processingpython-imaging-libraryscikit-image

Extracting retina region from 2D images


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?


Solution

  • 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.sstatic.net/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]