# extracting already labelled objects

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 .

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).

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

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);