Reputation: 5182
I'm looking for a good solution how to segment large areas of similar gray shades in opencv in a video stream.
This is my image for example:
To get this image i already did histogram equalization. I want to detect that area in the middle. Which is a big gray area, but it still differs in shades of gray.
Applying a threshold is not a solution because the area can be light gray, or darkgray, well any kinds of gray. But the area will have more or less the same gray all over the area. I've tried adaptive thresholding in opencv but i don't get a good result:
I also tried canny . But the result is also bad.
So my question is how can i segment an area of similar gray properly in opencv ?
Thx in advance
Upvotes: 1
Views: 1642
Reputation: 1
I am using OpenCV for detecting blue,yellow or green colored objects in a robot-hockey game. Here you have a similar problem, that the "measured" color of a puck, depends light and other factors. By converting my camera image into HSV Color Space, you can match these condotions very good (H = Hue, S= Saturation). So what you could do is transform your image to HSV and then define a threshhold for your grey area.(Set all pixels between e.g. 30,100,100 and 40,255,255 to 1 and the rest to 0.
Upvotes: 0
Reputation: 19221
Well, ultimately you might want to use the work of Chan & Vese (and other similar) given how noisy your image is. But for the moment we can stick to the basic morphological operators implemented in OpenCV.
Start with a morphological closing to remove some minor details, I used a square 9x9 here. Then perform a morphological gradient to possibly highlight interesting edges, and segment by a simply if value > mean + std/2, then 1, else 0
. If you discard small components and do another closing using a vertical structuring element (supposing you want to join near segments vertically), this is what we end with:
Upvotes: 0
Reputation:
A good way of segmenting out such an area would be to build a bank of Gabor Filters that can be applied to the image, check responses of each gabor filer, with a collective response in an area that is close to the surrounding of each Gabor filter, you can crave out the desired part.
1- Builde Gabor Filters of different orientations and sizes 2- Apply them to the image, 3- Measure the response of each filter. 4- Responses of each filter within a close vicinity should reasonably close to one another. 5- Then do the segmentation.
Hope this helps.
You can find more info on Gabor filters Here
Upvotes: 1