Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to find the centre of multiple objects in a image

I got this image

image description

I like to find the centre of each white area and mark it as red (also get their coordinates). I am looking into moments functions, is there a better way to get the centre point? do help or share ur codes/ideas.

how to find the centre of multiple objects in a image

I got this image

image description

I like to find the centre of each white area and mark it as red (also get their coordinates). I am looking into moments functions, is there a better way to get the centre point? do help or share ur codes/ideas.

UPDATE:- I tried to find the contour of this image using the below codes:-

    IplImage* mask1 = NULL;        
CvMemStorage * storage5 = cvCreateMemStorage(0);    
CvSeq * contour1 = 0;
mask1= cvCloneImage(mask);
cvShowImage("mask1", mask1);

cvFindContours(mask, storage5, &contour1, sizeof(CvContour), mode, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));
cvDrawContours(mask1, contour1, CV_RGB(0, 255, 255), CV_RGB(255, 0, 0), 2, 1, 8);   

cvShowImage("result1", mask);

The original Image I have shown is declared as mask and I used a clone image mask1 to find out contours. But after this what I get is the below shown image:-

image description

I used the same method in other sections of the program and got good results,but I dunno what happened in this case..