Ask Your Question
0

Unable to understand connectedComponents() in opencv [closed]

asked 2016-06-19 01:43:35 -0600

Akash Garg gravatar image

I am writing a program wherein i need to use connectedCompponents(img, label, connectivity= 8, type= CV_32S ). All I know is that this function returns an integer stating the no of components in the image. Then what does Mat label suggest? Thanks in advance

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Akash Garg
close date 2016-07-12 04:25:05.230126

Comments

1

you can see this post too

LBerger gravatar imageLBerger ( 2016-06-20 08:57:39 -0600 )edit

Thanks. The link was of great help!!!

Akash Garg gravatar imageAkash Garg ( 2016-06-21 10:36:06 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-06-19 21:24:22 -0600

Tetragramm gravatar image

The input is a binary image. Any contiguous area (with connectivity 4 or 8, as per the argument) is given a label.

label is the same size as the input image, and of type CV_32S, as you passed the argument. Each pixel in label contains the number of the blob it belongs to, with 0 being no blob. You have a maximum label value of the return value - 1.

edit flag offensive delete link more

Comments

So can I print the mat label? According to the explanation the background should be black and other objects having color corresponding to their label value.

Akash Garg gravatar imageAkash Garg ( 2016-06-21 10:35:20 -0600 )edit

What do you want to actually do with it? Of course you can print it, but since I don't know what you're doing, I can't tell you if it does anything useful.

The background does have a value of 0, and anything above 0 is a blob.

Tetragramm gravatar imageTetragramm ( 2016-06-21 19:03:37 -0600 )edit

Thank you so much!

Akash Garg gravatar imageAkash Garg ( 2016-07-12 04:24:38 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-19 01:43:35 -0600

Seen: 198 times

Last updated: Jun 19 '16