Undesired Hierarchy Result
Hi to all,
My aim is to classify contours which have no children and any parent. I found my contours with "CV_RETR_TREE" hierarchy. To classify, I just determined if statement as
if ( hierarchy[i][3] == -1 && hierarchy[i][2]==-1)
Source image:
However it could not classify the contours I wanted. In below image red circle shows the contour type that I would like to classify;
As you can see there is no any child or parent in this contour, however I cheched its hierarchy and this is the result:
[121, 76, 119, -1]
It finds it's child while there is not as I can see. What do you think the problem might be?
The reason why I intend to do this, I would like to find these contours and draw them with different color after watershed algorithm. In this image, the contours without child or parent are the ones which do not have any peaks. So that's why I thought that solution which I could not make it work. If there is any other solution you can suggest please do not hesitate.
Thank you!
Please post original image without red circle in png format. What is your opencv version?
@LBerger Hi thanks for your reply, I updated post with source image that I found contours and my opencv version is : 3.4.4