Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

What's the best way to handle my pattern matching problem?

Solved!
Go to solution

Using vision assistant 8.2, I have trained a template (Psquare.png) from the GoodPrndl.bmp.   Of course, I get a good pattern match for this image.  I would expect to get a bad pattern match for BadPrndlClip.bmp.  You will notice that a corner of the square is missing.  This clipping problem has occured in production and made it to customer.  Could an expert look at this problem and give suggestions on best method to detect this clipping problem.  Keep in mind that the clipping or void could happen anywhere on the square or 'P'.   I also attached pattern matching script.

 

Thanks

0 Kudos
Message 1 of 12
(5,033 Views)
I am downloading your zip file. And before I see it, Why are you using pattern matching here? Since the defect is not always going to be something consistent, my suggestion is to use a particle analysis. Let me get back after seeing the image..
0 Kudos
Message 2 of 12
(5,030 Views)
Solution
Accepted by topic author DelphiDan

good.JPG

 

You can do like this. And use a particle filter after this operation. This i feel will give you consistency because the broken part here means the rectangle is not going to get completed. Please see the image attached which shows the processing for the bad image.

 

 

 

Message Edited by muks on 04-27-2010 08:06 PM
Message 3 of 12
(5,026 Views)

The reasons I'm using pattern matching are:     1.  Each Square and letter is a constant pattern.  2.  Since this is a backlit VF display the intensity may be slightly different from part to part and I believe pattern matching should handle this.

 

My concern with particle anaysis is that backlighting intensity may change and there is a also an associated frequency with this display.  The combination of these two things would make a binary tool not the best choice.

0 Kudos
Message 4 of 12
(5,025 Views)
I feel pattern matching will also suffer if there is any drastic lighting variation. If you are very particular in using pattern match you can always increase the score to above 900 and differentiate the good from the bad but i feel it will not be consistent. You have to use a adaptive thresholding and use the particle analysis.
0 Kudos
Message 5 of 12
(5,021 Views)

The simplest way to do this is usually the best.

 

I'm assuming you're controlling the environment - i.e. no external light allowed.

 

You should then lock the camera down, so that the bright display is at about 200 contrast. 

  

You need to get a number of different "brightness" parts, and see where they lie.

 

You're trying to do a six sigma on the brightness, this should be pretty narrow, maybe 50 contrast at worse.

 

The black background is obviously down near 0, lets say less than 50 contrast.

 

Set thresholding to 100 (approx).

 

Then undertake pixel counting of the high values.

 

This is the easiest and in my opinion the best solution for what you are trying to do.

 

ADL 

 

 

0 Kudos
Message 6 of 12
(5,014 Views)

I agree. I've noticed pattern matching doesn't handle differences in intensity as well as I would think.   Do you try to shy away from pattern matching whenever possible, because of similar issues? 

 

I tried out your script and like it's simplicity.  I see that the "fill holes" is the key to the solution.    The only potential problem is if the letter inside the square is clipped but the square is intact.   I'm not sure of the probability of this problem.  The customer return was a clipped square along with a clipped letter.   I will find out from product group.

 

I have questions on "particle analysis".    There are so many types of  "select measurements".  I have typically always used "area".  I notice others such as "equivalent Rect Long Side" etc.   What measurement would you use for this problem? or can you point me to documentation explaining each measurement?

 

 

0 Kudos
Message 7 of 12
(5,013 Views)

delphi Dan wrote:

I agree. I've noticed pattern matching doesn't handle differences in intensity as well as I would think.   Do you try to shy away from pattern matching whenever possible, because of similar issues? 

 

I tried out your script and like it's simplicity.  I see that the "fill holes" is the key to the solution.    The only potential problem is if the letter inside the square is clipped but the square is intact.   I'm not sure of the probability of this problem.  The customer return was a clipped square along with a clipped letter.   I will find out from product group.

 

I have questions on "particle analysis".    There are so many types of  "select measurements".  I have typically always used "area".  I notice others such as "equivalent Rect Long Side" etc.   What measurement would you use for this problem? or can you point me to documentation explaining each measurement?

 

 


Personally i do avoid pattern matching as much as possible. In this case area alone can do the trick. One more idea. Use the dilation and then use an erosion just to make sure that the broken parts remain seperated from the border and if you are able to do this then the area of the filled rectangles (with alphabets) are somewhere around 8000+ and without the aplhabets (the top ones) are in the range of 3000+ and the broken ones are somewhere in 2000s and 1000s.

 

0 Kudos
Message 8 of 12
(5,007 Views)

I may be misunderstanding the 'dilate' then 'erode' statement.   Wouldn't that be the same as doing nothing after the intial threshold?   Unless you have different iterations for each.

 

0 Kudos
Message 9 of 12
(5,002 Views)

A dilate followed by an erode will first expand the particles and then reduce them. Particles without holes will be uneffected as their borders will expand and then shrink by the same amount. However if there are holes present up to the size of your structuring element, they will be filled in. You can do this in a single call to the morphology function by selecting the Close operation, which will also reduce some calling overhead. The concepts manual details all of the morphology operations.

Tyler Weston
Vision R&D
National Instruments
0 Kudos
Message 10 of 12
(4,955 Views)