Ask Your Question
0

How to get the total number of black pixels in the connected component to which a pixel is attached?

asked 2017-02-12 23:16:21 -0600

i need to implement a function that can find the number of all the pixels in the connected component to which a pixel is attached. There are opencv functions for finding connected components from image but i am unable to find any function that can find no. of connected components to a certain pixel. How can i achieve that>?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-02-13 01:56:51 -0600

LBerger gravatar image

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)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-12 23:16:21 -0600

Seen: 481 times

Last updated: Feb 13 '17