First time here? Check out the FAQ!
answered 2017-02-13 01:56:51 -0600
you can use function connectedComponentsWithStats
Then you can find number of pixel in the components like this (for labels output CV_32S)
stats.at<int>(labels.at<int>(x,y),0)