cuda-based connected component labeling

asked 2015-04-09 09:04:36 -0600

Guyygarty gravatar image

Hi,

I am trying to identify/label blobs in an image. Given a binarized image like this: image description

I want the centroid, area and other morphological parameters of each of the white spots.

I currently have code that works well using findContours and ApproxPolyDP but I want to write code that uses GPU processing. I have tried using the Hough transform but, since my objects are not necessarily round, it does not perform very well.

I have a pretty good idea how to get the required parameters IF I could "paint" each of the spots a different "color" .

I have tried using cv::cuda::connectivityMask and cv::cuda::labelComponents to do this, but there seems to be no documentation at all regarding these routines, so I am guessing how to use them.

Invoking cv::cuda::connectivityMask(GPUBinaryImage, GPUConnectedComponentMask,0 ,2); I get the following image:

image description

It appears that all pixels have a value of 15 except for those on the boundary of each blob which have lower values.

Invoking cv::cuda::labelComponents(GPUConnectedComponentMask, GPULabels,8); I get a 32bit image with the 1st and 2nd byte looking something like: image description

How should I be using these functions?

Is there anything better I should be using?

guy

edit retag flag offensive close merge delete

Comments

1

I have figured this out.

It turns out that there were several errors in the CUDA kernels used by cv::cuda::labelComponents() I have fixed them and now have a working version which was tweaked for my application. I would be willing to share this with others but am not sure how.

guy

Guyygarty gravatar imageGuyygarty ( 2015-04-17 12:45:42 -0600 )edit
1

You could publish it in your own github fork of opencv.

willyd gravatar imagewillyd ( 2015-07-29 15:20:08 -0600 )edit

Could you please share your solution, I am facing the same issue with the CUDA based CCL method. Thanks!

Woking-34 gravatar imageWoking-34 ( 2017-01-04 08:38:43 -0600 )edit

Hey Guyygarty,

I have the same question as Woking-34. Is it possible that you provide the code or instructions how to repair the labelcomponents method.

Best

Mondi

mondi gravatar imagemondi ( 2017-04-26 04:49:59 -0600 )edit

Is this solution currently posted somewhere? Thanks!

zxpatric gravatar imagezxpatric ( 2018-12-25 10:51:35 -0600 )edit