Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Color Pattern Matching - Ignore Black and White options

Hi,
 
I am using .net libraries in Vision Development Module to implement color pattern matching for my product and I encounter the following problem.
 
Since the product has an irregular shape, I create a template of product image with a background in black color (RGB: 255,255,255) and learn with the learn option "CWIMAQControls.CWIMAQIgnoreBlackAndWhiteOptions.cwimaqIgnoreBlack". However, no match was found while matching with the photos of the realistic product. I even try on "Ignore White" option with a template of white color in background and "Ignore black and white" option, but nothing help.
 
If I modify the photo so that it's all black in color except the product (with irregular shape), then I got 998 in score while matching with the template that I created. I even tried these steps using Vision Assistant 8.0 and it returns the same result.
 
I wonder whether I misunderstand the defintion of CWIMAQIgnoreBlackAndWhiteOptions or I do not use it properly.
 
Any help is appreciated.
 
Best Regards,
Joanne
 
 
 
 
 
0 Kudos
Message 1 of 3
(3,483 Views)
Joanne,

Would you post a copy of your Vision Assistant script, your image, and your modified image that works so I can take a look at it and get a better idea of what you are seeing.  Also, there is a shipping example called ColorPatternMatching you might find useful.  It is located on your hard drive:

C:\Program Files\National Instruments\Vision\Examples\MSVB.NET\2. Functions\Color Pattern Matching

Thanks,
S. Arves S.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 3
(3,473 Views)
Hi S.A.S :),
 
After doing some testings and readings, I have more ideas about IgnoreBlackAndWhite option now, let see if my understanding is correct.
 
Let say if I set "IgnoreBlack" in LearnMode, it will ignores all pixels which contain black color spectrum while learning, but not the pixels with RGB 255,255,255 in color. So, if the target area used for matching contains some pixels with black color spectrum, those pixels will also be ignored and it does affect the accuracy.
 
As you can see from the attachment - photo01.jpg, the product is irregular in shape and is placed in a mold. What I would like to do is check the design/pattern on the product, but not for the mold. The design/pattern may have large variety of colors and patterns, but the color of mold is constant. Since the position of mold is fixed,  I can mask the photo before matching in order to increase the accuracy. However, I have no idea of how to eliminate the masked part while matching or create a template in irregular shape.
 
My program is written in C# and I referenced Color Pattern Matching.vb before implementation.
 
Please find the attachment for your reference.
 
Thanks a lot.
 
Regards,
Joanne
 
P.S.   photo01.jpg                          - live image of product and mold
          photo01_masked.jpg           - masked live image
          template01.png                    - template created by Vision Assistant
          Color Pattern Matching.scr - script file
0 Kudos
Message 3 of 3
(3,457 Views)