Good evening everyone, I have a small issue that intrigues me. I would like to remove the circle surrounding the retinal blood vessels to keep only the interior. Do you have any ideas? Thanks.
My image: Segmentation – This is the source image where I applied segmentation. I want to remove the large white circle.
Purpose: Ground_truth – This is my goal, it's the image I want to achieve after removing the circle.
Your image has a nasty white line around the edges - probably where you have screen-grabbed it rather than sharing your actual image. The first step is to remove that. Then you can do the following:
flood-fill from top-left corner with white - this will effectively expand the circle outside the edges of the eye as far as the edges of the image
now flood-fill with black from the top-left corner, which will make all the outer white become black
Note that this technique can fail if your eye's circumference touches the edge of the frame because that prevents the flood-fill from flowing round the edges properly. If there is a risk of that, just add a 1px wide black border around the edges for the flood-fill to flow properly all the way around the edges and into the image from every point of every side. Then shave 1px off all sides when you are finished.
I'll do the steps with ImageMagick separately and then all in one go. You can do the same with OpenCV, or wand
or scikit-image
. Here is an example of how to flood-fill with Pillow
:
# Shave 1 pixel off all edges
magick YOURIMAGE -shave 1x1 step1.png
# Flood-fill with whote from top-left corner
magick step1.png -fill white -draw "color 0,0 floodfill" step2.png
# Flood-fill with black from top-left corner
magick step2.png -fill black -draw "color 0,0 floodfill" result.png
Or, all in one fell swoop:
magick OlDlUKx1.png -shave 1x1 -fill white -draw "color 0,0 floodfill" -fill black -draw "color 0,0 floodfill" result.png