LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I get good results from pattern matching/shape detection for this image?

Solved!
Go to solution

I need to be able to identify all nine boxes in the first image (0000094718...) and others like it.  I've tried shape detection, pattern matching, and geometric pattern matching.  I've tried varying all the parameters within these functions.  I've tried pre-processing the image (and template, if applicable: usually created from just one of the boxes) with thresholding and/or a muliplier prior to using the detection or matching function, and I still can't get all nine boxes, and just those nine boxes.

 

Can somebody offer some help?  I would ideally like to be able to use shape detection, because it returns the corner coordinates for rectangles, and those are particularly useful to me.  What confounds me about this function is that after setting the min/max height/width of rectangles to find, the program seems to ignore these instructions and returns matches out of these bounds.

 

It would be even better to be able to have a script that will identify all nine boxes in both images attached.  The boxes in the second image (X820A32) are more squarish.

 

Thank you,

Holly

0 Kudos
Message 1 of 10
(3,926 Views)

Have you tried the Particle Analysis VIs?  These may be more appropriate for locating your features since you don't really have rectangles but what could be arbitrary parallelograms.  After you've got glob locations, you could create a coordinate system and use edge detects and intersections to find corners.

Message 2 of 10
(3,919 Views)

I'll give it a shot and get back to you...Thanks!

0 Kudos
Message 3 of 10
(3,917 Views)

While the particle analysis vi is very good about picking out all nine boxes (thanks!), it picks out quite a few other particles.  I'm trying to use the particle filter to weed them out, but the function doesn't seem to take my input limits on bounding rectangle height/width.  Is there a 'commit' button that I'm not seeing or something?

0 Kudos
Message 4 of 10
(3,904 Views)

Looks like you've got your max and min backwards (i.e. min should be 0 and max should be 200, but I'm guessing you probably want min to be something a bit larger if you're getting additional particles identified due to noisy pixels.).  I'm not sure what the default is when that happens.  Once you click OK, the settings in the Vision Assistant script should be saved.

0 Kudos
Message 5 of 10
(3,902 Views)

If I enter the min as 200 and the max as 400 and hit okay, those settings seem to be saved in that if I re-open the filter for editing, those numbers re-appear in the entry fields.  But I am still getting matches with bounding rectangles smaller than the requirements.

0 Kudos
Message 6 of 10
(3,900 Views)

If I lower the threshold point, I can get rid of these nuisance particles, but I'm still concerned about the filter not doing what I want it to do...

0 Kudos
Message 7 of 10
(3,899 Views)
Solution
Accepted by topic author Godnumber1

Try the attached script.  I think you may not be using optimal threshold values.  You may find that you want to use a smoothing filter before doing the threshold.  This should also help with the nuisance particles.

0 Kudos
Message 8 of 10
(3,875 Views)

Thanks, I'll give it a try tomorrow...

0 Kudos
Message 9 of 10
(3,868 Views)

This script seems to work fine, the threshold value certainly makes a difference.  The particle filter isn't really doing its job, you can tell if you raise the threshold so that smaller particles are present - the filter doesn't weed them out according to the input limits like it should.  However, lowering the threshold seems to make the filter non-essential to the process.

 

I think this will work out for me.  Thanks for your help!

0 Kudos
Message 10 of 10
(3,842 Views)