Jonel Dominic Brave
Jonel Dominic Brave

Reputation: 1

How do I get the segmented regions from watershed (OpenCV - C++) for further classification

I want to get all the segmented regions. I want to test if a particular segment is round (cell) or not.

Can I use findingcontour in this kind of problem?

Segmented Image

***Edit

I've successfully get the segmented regions using contours. Any suggestion on how to classify these contour depending on their shape. (Remove the non-circular contours).

The situation looks like these :

Segmented Regions

Upvotes: 0

Views: 579

Answers (1)

S. Vogt
S. Vogt

Reputation: 445

Yes, it should work for you. If "wshed" will be your input image for the findContours() function. If you think that it is possible that there will be nested regions, you should use CV_RETR_TREE if you want to process them in a special way, CV_RETR_LIST if you want to handle the regions in a region too or CV_RETR_EXTERNAL if you want to ignore all nested regions. See Doc and an Example for usage.

EDIT 1.0:

To answer your edit: circular contours will have one outer and one inner contour. So if you use CV_RETR_TREE and check for each contour if there is another contour inside, it is a circular contur and you can keep it and delete all other contours. See here under 4. RETR_TREE or here for usage

EDIT 2.0: Seems I missunderstood you. With "circular" in Edit 1.0 i meant closed objects. Now I am not shure what you mean with circular. If convexity is sufficient i would lead you to convecHull and convexityDefects.

If you it is realy necessary to have a circle/oval shape, i would try to calculate the parameters of the oval or circle based on the contour and to draw an ideal circle/oval based on these and compare the contour with it. But maybe there are better ways to to that. In that case i would recommend you to ask it as a new question, because it does not has anythin to do with the topic of this question.

Upvotes: 1

Related Questions