Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Exclude particles that touch image boundaries

Hello,  I have grayscale image from which I extract a rectangle excluding everything outside the masked rectangle region.  I then threshold the masked image.  I then use a particle filter to keep only particles of a min and max area.  This works great, but I also want to exclude any particle that touches the boundaries of the search box or masked image.  How can I do this?
0 Kudos
Message 1 of 9
(5,210 Views)

How about IMAQ RejectBorder?  That removes any particles touching the edge of the image.

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 9
(5,209 Views)
- copy your thresholded image in a temporary buffer
- draw a thin 1 pixel wide white rectangle around the search area in the temporary buffer.
- label the buffer: the 1 pixel rectangle will connect every particles touching the border of your search area, so they will all have the same value.
- find the value of this big particle: get the pixel value at one corner of the rectangle
- double threshold the labelled buffer so that everything is white excepted pixels having the value you found at the previous step
- mask the original image using the buffer: a simple binary AND is plainly sufficient. particles touching the border of the search area should disappear

(you may have to adjust the colors depending on which color are your particles and background: if background is black, draw a black rectangle, etc...)

Message 3 of 9
(5,176 Views)

The reject border worked and was simple too incorporate.    Very interesting way of accomplishing the same thing though.

Thanks

0 Kudos
Message 4 of 9
(5,167 Views)
Hi
 
I have got a similar problem. I have an image where I have made a ROI with IMAQ convert rectangle to ROI and afterwards I use AutoBThreshold to binarize the image. Then I use IMAQ RejectBorder, but it does not remove the blobs that touches the ROI, why doesn't it do this and how do I make it do it?
 
Best regards
Simon
LabVIEW 8.6 / 2009 / 2010
Vision Development Module 8.6 / 2009 / 2010
VBAI 3.6 / 2010
0 Kudos
Message 5 of 9
(5,074 Views)
Hi Simon,

When you use IMAQ Reject Border, it rejects particles that contact the border of the image that you are working with, not a previously specified ROI.  One way to accomplish what you are trying to do would be to use IMAQ Extract to extract the ROI with which you are working. I would place this image in a new buffer. Then you can apply IMAQ Reject Border, it will reject the particles you mention.

Thanks,

Sherrie R
Applications Engineer
National Instruments
0 Kudos
Message 6 of 9
(5,056 Views)

How would I do the inverse?  That is, how could I keep ONLY the blobs touching the border?

0 Kudos
Message 7 of 9
(4,221 Views)

Remove the edge blobs, then subtract from original image.  You might need to use logic or invert and use as a mask.

 

Bruce

Bruce Ammons
Ammons Engineering
Message 8 of 9
(4,216 Views)

Thanks Bruce -- I got it!  🙂

0 Kudos
Message 9 of 9
(4,213 Views)