extracting already labelled objects

asked 2019-09-22 08:10:33 -0500

vom gravatar image

I have a watershed segmented image which I changed to a binary image to apply the connectedComponentsWithStats as given in this example. The image looks like this.

Now, I want to find the number of components and label(color) only the first 3 largest objects. When I applied the connectedComponentsWithStats, I get a total connected components value of 2. What am I doing wrong? Is it possible to find the largest three objects from the already labelled result of watershed segmentation result(given below for reference).

Result

edit retag flag offensive close merge delete

Comments

I don't understand. When I apply code result is image description

LBerger gravatar imageLBerger ( 2019-09-22 08:37:02 -0500 )edit

I don't understand too. Can you share your code? Here is my code :

cv::Mat labelImage;

cv::Mat stats, centroids;

int nLabels = cv::connectedComponentsWithStats(input_image, labelImage, stats, centroids);

vom gravatar imagevom ( 2019-09-23 02:36:27 -0500 )edit