I try to separate the contours of the image (to find homogeneous areas), so I applied cvCanny and then cvFindContours, then I use the following code to draw 1 outline every time I press a key:
for( ; contours2 != 0; contours2 = contours2->h_next ){ cvSet(img6, cvScalar(0,0,0)); CvScalar color = CV_RGB( rand()&255, rand()&255, rand()&255 ); cvDrawContours(img6, contours2, color, cvScalarAll(255), 100); //cvFillConvexPoly(img6,(CvPoint *)contours2,sizeof (contours2),color); area=cvContourArea(contours2); cvShowImage("3",img6); printf(" %d", area); cvWaitKey(); }
But in the first iteration, he draws ALL contours, in the second he draws ALL except one, the third draws everything except two, etc.
And if I use the cvFillConvexPoly function, it fills most of the screen (although, as I wrote this, I realized that a convex polygon will not work for me, I only need to fill the contour of the contour)
So, how can I take only 1 path in each iteration of for instead of all the other paths?
Thanks.
source share