Ask Your Question
0

Extracting area of interest from image

asked 2018-05-11 06:57:42 -0500

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:

  1. Detecting contours
  2. Creating a convex hull around all contours (so one hull enclosing all, not one hull for each contour)
  3. 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:

  1. is this approach feasible or is there some better solution?
  2. 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: source image After Threshold: after threshold Detected Contours: image description

edit retag flag offensive close merge delete

Comments

is it always round ? (fitEllipse() might help then)

berak gravatar imageberak ( 2018-05-11 07:18:50 -0500 )edit

Works pretty well so far! Ellipse tends to be a liitle bit too small, but thats better than too big! Very much appreciated!

hammeron gravatar imagehammeron ( 2018-05-11 08:10:14 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-05-11 08:12:35 -0500

rwong gravatar image

How about converting to HSV colorspace (call cv::cvtColor with cv::COLOR_BGR2HSV), then threshold the Saturation channel (perhaps using cv::inRange), to generate the mask? The Saturation channel is what our human eyes perceive as "the rich colorfulness". Tones of grays on the image should produce low values in the Saturation channel. Please let us know how that turns out (especially as the background color changes) by adding the new output images to your question.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-05-11 06:57:42 -0500

Seen: 114 times

Last updated: May 11 '18