Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Fill Holes and Particle Filter Error

I posted a question about an error I was getting doing a particle filter operation some days ago on the VB forum and got no response so I am reposting here under Vision. To illustrate the problem I have attached some VB code to show the error described below under PARTICLE FILTER.

I have also found another problem with filling holes in a Binary image, which is also illustrated in this code. When I try to fill holes on my binary image it turns the whole image black! I have tried thresholding before the operation, inverting the image etc, with no luck! All I get is a fully black image! Again this code pretty much follows the example given in the documentation!


All the files for the sample code are in one attached zip f
ile


PARTICLE FILTER
The following code is given in the IMAQ Vision documentation for conducting a particle filter


Dim i As New CWIMAQImage
Dim data As New CWIMAQParticleFilterData
' Select particles that contain less than 100 pixels or
' more than 300 pixels and remove them.
data.Add
data(1).Parameter = cwimaqParticleArea
data(1).MinValue = 100
data(1).MaxValue = 300
data(1).Exclude = True
' Perform the particle filter operation and
' store the result in i
CWIMAQVision1.ParticleFilter CWIMAQViewer1.Image, i, data, True


However it generates the following error for me when doing this on a binary image.
Run time error ‘438’ - Object does not support this property or method which is generated by the line in the code
data(1).MinValue = 100
same is also true for the line
data(1).MaxValue = 300
but not
data(1).Exclude = True
Has the syntax been changed from that in the documentation?"
0 Kudos
Message 1 of 2
(3,085 Views)
It appears that the format is slightly different from what is listed in the manual. You will need to use:
data(1).Range.min = 4
data(1).Range.max = 300
I have attached modified code. Also, as for the fill holes, I made sure to threshold and view the image in a binary palette,and the blobs are not being deleted. Take a look at the code and let us know if you need more help!
Best Regards,
Chris D
NI Application Engineer
Message 2 of 2
(3,085 Views)