Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get boundary contour points?

Letsay i have binary image with two separate particles.
I want to get the boundary points for each particle in array.
 
The array structure should be:  
Row: Particle number. (~1-100 particles)
Column: boundary point number (~100-10000 points)
ArrayData: (X,Y) cluster of position of boundary. 
 
Lets call the Binary image: G
Then, BoundaryImage= G - Erosion(G)
 
But now i dont know how to get those boundary pixels into array.
The VI GetPointsOnContour isnt doing the job well. IT sometimes split the bondary contour to couple of segments (For example 2 particles with no holes have 2 contours segment, but this VI return 7 segments, and i dont know why he split them).
 
 
Tnx,
HaD
0 Kudos
Message 1 of 8
(6,880 Views)

This may not be the most efficient way to get there, but I am pretty sure it would work:

First number the particles using IMAQ Label, then subtract the eroded particles.  You should have all the boundary pixels with the number of the particle they belong to.

Convert the image to a 2D array, and loop through all the pixels.  If the pixel is non-zero, add its coordinates to the appropriate contour array.  This is kind of brute force, but it should do the job.

The only problem is if you need the coordinates in order.  You should be able to write a sorting routine that would put the points in order, but that could be more complex than finding the coordinates to begin with.

Another possibility is taking the boundary segments from GetPointsOnContour, checking the endpoints and assembling the complete boundary curve.

Bruce

Bruce Ammons
Ammons Engineering
Message 2 of 8
(6,868 Views)
I did something in the middle,
I took the countour results and checked their pixle values..
0 Kudos
Message 3 of 8
(6,864 Views)
You should use IMAQ MaskToROI. Here's an example.

IMAQ MaskToROI will always return particles in the same order as IMAQ Particle Analysis and IMAQ Label, so you may use those functions together in an application.

Kevin C.
National Instruments

Message Edited by KevinC on 09-10-2007 09:53 AM

Message 4 of 8
(6,857 Views)
I have Labview 8.0.1 i cant see your 8.2 vi.
 
😞
0 Kudos
Message 5 of 8
(6,836 Views)

Kudos!!! I was looking for it as well.

Instead of implementing that (ans most probably badly) it saved me a lot of work.

 

Thx a lot,

 

JPh

0 Kudos
Message 7 of 8
(6,252 Views)
thanks for attaching a useful subvi
0 Kudos
Message 8 of 8
(5,951 Views)