Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with Pattern Matching

Hello,  I am using Vision Development Module 8.5 with VB6.   I need immediate help on coming up with a solution for an auto warranty return for incomplete "Fog Lamp" indicator symbol.  I use a match score minumum of 900, but the match score returns a 932.  I don't see how a score > 900 is returned for so much missing from this symbol.  I use this test in a high production line and am very concerned.  I attached a Vision Assistant 8.5 script and actual image from auto warranty return.  The *.png template used for comparison is also in zip file.

 

Thanks

Download All
0 Kudos
Message 1 of 8
(5,423 Views)

Perhaps you need to look at using golden templates.  I don't think they existed in 8.5, though.  It might be time for an upgrade.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 8
(5,413 Views)

Golden Template does exist in 8.5, and that was my first idea too, however, after trying it, it might not be the best algorithm for it.

Golden Template compare the contour of objects, and they don't produce very good result in the specific image because the symbols are relatively small and not contrasted enough once we look at the luminance plane (i.e. we can't perform a great contour extraction).

 

What I tried and works decently is the looking at the identification score of the classification algorithm.

The only drawback of this method is that the object needs to be whole (i.e you might need to do a little morphology to close the objects). But the identification score will be quite different on the partial fog lamp.

 

Another tactic, which is similar to the previous one is to (mis)use the OCR algorithm to train the object and use the character verification function (i.e. define a perfect fog lamp image (character) as the reference character when you train the OCR engine.

The algorithm will them return a verification score which will tell you how far or close the pattern under inspection is from the reference one defined in the OCR file. OCR is based on classification.

After trying that on your image, the verification score is different enough and you could use that for making a decision, but the difference is not as marked as with using the identification score of the classification algorithm.

 

Both algorithms are based on thresholding the image. One advantage of using the OCR is that you can tweak the min character spacing parameter to adjust the segmentation so that the symbol is considered one full object (as opposed to having to perform morphology to do it if you use the classification algorithm).

As I mentioned, classification seems to give you a better differentiation between the scores.

 

Both methods allow you to define a Classification file or Character Set File that allow you to test multiple symbols.

 

I am attaching a couple inspections and files I used to do this quick test.

 

Hope this helps.

 

Best regards,

 

Christophe

 

0 Kudos
Message 3 of 8
(5,408 Views)

Thanks Chris,

 

Regarding the below comment:

 

What I tried and works decently is the looking at the identification score of the classification algorithm.

The only drawback of this method is that the object needs to be whole (i.e you might need to do a little morphology to close the objects). But the identification score will be quite different on the partial fog lamp

 

If the Fog Lamp inspection was setup to look for 2 separate symbols would the classification algorithm work better or even the current pattern matching algorithm. I am wondering if the algorithm for these tools work better on 1 contiguous symbol.

 

Dan

 

0 Kudos
Message 4 of 8
(5,400 Views)

In your specific image, pattern matching could be used to find the symbol, but as you noticed, you can't really use the score for determining the quality of the symbol.

For inspecting the symbol, I would definitively use the identification score of the classification algorithm.

What I meant by the sentence you highlighted is if that unfortunately, there is currently no way with the classification algorithm to treat all the separate tiny parts of the object in the ROI as a whole symbol. This means that for the classification algorithm to work well, you need to alter the image by applying some morphology operation to close the object (close operation, which is a series of dilations then erosions). To illustrate that, increase the threshold level in the inspection, or remove the morphology step. The algorithm will then find multiple objects in the ROI (but you really want them to be considered as one, which represent the fog light).

 

The OCR segmentation actually allows to do that by changing a parameter (Max Element Spacing), and you would not have to alter the image.

This might be better. Check if you're satisfied with the differences in the verification score with the OCR algorithm. My experience with your image is that the gap between the good fog light and the bad one was not as big as when using the classification algorithm. But it might be good enough for your application.

 

Hope that makes sense.

Message 5 of 8
(5,398 Views)

ok, I understand.

 

A question on your script and OCR file.  I get a Identification Score of 953 on good FogLamp symbol.  I get a identification score of 860 score on bad FogLamp symbol.   When I change the acceptance level to 900, both symbols get no score.  I would expect the good Foglamp symbol to get same score of 953 and the bad Foglamp symbol to get no score.   Can you explain?

 

thanks

0 Kudos
Message 6 of 8
(5,394 Views)

Hello DelphiDan,

 

I don't know if it in 8.5 exists, but you could use geometric pattern matching with option "0" occluded.

 

0 Kudos
Message 7 of 8
(5,385 Views)

Chris,

 

I tried a GoldenTemplate.scr, ClassificationInspection.scr, OCR.scr, and Geometric.scr on hundreds of images and determined that due to large differences in contrast in the FogLamp symbol, a binary thresholding tool is not the best option.  The OCR seemed to have the best promise, but still not reliable enough due to contrast differences from part to part.  Although I believe there are some problems with pattern matching, it is a grayscale tool and if I separate the fog lamp symbol into 2 independent symbols, then the algorithm seems to work better.      Thanks

0 Kudos
Message 8 of 8
(5,274 Views)