Extracting area of interest from image
I have a set of images with a colored border which is enclosing a grey area. only the grey area is relevant for my image analysis. But i have a hard time to extract the grey area.
My approach for getting the grey area is:
- Detecting contours
- Creating a convex hull around all contours (so one hull enclosing all, not one hull for each contour)
- Checking if pixel of source image is within convex hull and applying my analysis algorithm.
Current problem is that there are multiple contours which are noise/unwanted and i cant remove them. I have uploaded the results so you know what i mean.
Two questions regarding this:
- is this approach feasible or is there some better solution?
- how could i remove those contours which are outside of the circle so that i only have the area of interest in my convex hull?
Please also keep in mind that lighting may change and the color can vary betweeen blue and purple.
Source Image: After Threshold: Detected Contours:
is it always round ? (fitEllipse() might help then)
Works pretty well so far! Ellipse tends to be a liitle bit too small, but thats better than too big! Very much appreciated!