Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Using NIVision 8.0 (imaq*), how to export particle contours

My application uses different vision libraries for different machine
vision problems. The Application is mostly written in C++ and for the
NI part, uses IMAQ Vision (NIVision.h) version 8.2.0.562

For a Blob Segmentation task, I use imaqLocalThreshold followed by
imaqParticleFilter2 to filter the binarized image based on the
ParticleFilterCriteria2 parameters I pass in.

I am able to extract the statistics of all of the blob results, but
not the actual blob contours (outlines) so I can draw them in my GUI
which uses a different (i.e. non-NI) graphics package.

I can call imaqMeasureParticle and pass in the particle number to get
a single piece of information, such as Centroid_X or Area, but not to
get a pointer/handle to the outline.

Any ideas?

Thanks

0 Kudos
Message 1 of 6
(3,863 Views)

Hi

Here's my idea. I am using the Vision Development Module from LabVIEW only, but it should be similar when called from C++.

Use the function IMAQ Label (in C++, it is probably called imaqLabel) to generate an image of particle labels. In this image, each pixel holds the number of particle it belongs to. Now you have to do some low-level image processing in C++. Go through all image pixels, and when you hit a pixel of your desired particle, check its neighbors (4 or 8, depending on whether you want to have the contours 8- or 4-connected). If at least one of the neighbors is zero, this is a contour pixel and you can draw it on the canvas for the user.

Hope this helps,

Vladimir


View my profile on LinkedIn
0 Kudos
Message 2 of 6
(3,858 Views)

If you want to represent the outlines on a pixel by pixel basis, you could use edge detection on your blobs to reduce them to edges (or erosion and subtraction), then search and record the individual pixels as suggested previously.

If you need the contours as a continuous curve, that is much more difficult.  I don't have any ideas how to do that at the moment.

Bruce

 

Bruce Ammons
Ammons Engineering
0 Kudos
Message 3 of 6
(3,854 Views)
On Mar 17, 6:40 am, Bruce Ammons <x...@no.email> wrote:
> If you want to represent the outlines on a pixel by pixel basis, you could use edge detection on your blobs to reduce them to edges (or erosion and subtraction), then search and record the individual pixels as suggested previously.
> If you need the contours as a continuous curve, that is much more difficult.&nbsp; I don't have any ideas how to do that at the moment.
> Bruce
> &nbsp;

Our current work-around already involves passing the thresholded image
into another library's contour tool to do the Sobel and coarse edgelet
determination. This just wastes valuable processing time.The blob/
particleAnalysis tool has got to already have the perimeters stored as
part of its basic analysis. I just can't see how to get it
efficiently.

0 Kudos
Message 4 of 6
(3,849 Views)

Hi

Well I'm not certain, but I definitely don't think that the Particle Analysis function stores the perimeter points for later exposure to the programmer. It would just be an internal waste of memory. However, the Sobel approach you are using is much slower and also gives worse results than the method I've described. If you don't want to get the contour of each particle separately, you can omit the "IMAQ Label" step and use just the original thresholded image for determining the contours of all particles. This is just one more linear pass through the image, thus the performance should not be severely affected.

Vladimir


View my profile on LinkedIn
0 Kudos
Message 5 of 6
(3,847 Views)

Hello rbiro,

You should be able to get this functionality using ROI's.  If you have LabVIEW, I've attached an example vi that I've seen which does what you are looking for.  The functions should be the same in C++.  You will need to use the imaqMaskToROI function to convert your thresholded image into an ROI containing the contour information.

Regards,
Luke H

 

Message 6 of 6
(3,818 Views)