Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Pattern match in vision with a masked region

Hi Jack,

 

First, have you tried opening up the image viewer to verify that the mask is being created properly?

 

Secondly, I would recommend using the template editor (found in National Instruments>Vision>Template Editor) if you are just using this for one or a few files.  Then, you could create the template file and load it for future use. 

Marti C
Applications Engineer
National Instruments
NI Medical
Message 21 of 26
(1,678 Views)

Hi Marti,

 

I think all programmer wanna user create the template by himself program not lauch the template editor.

 

As the mention before, I use above program make a template file, but it can not be used in the pattern match. so I open the image for checking by template editor,  it can be opened normally, and the mask area is black, it means it is a mask image. as you know, when we use the editor create the template, the area is red which you wanna ignore. am I right?

 

Yes, I can create the template with NI editor. but that's not good way.

 

Best regards,

 

Jack

0 Kudos
Message 22 of 26
(1,670 Views)

Hi Jack,

 

I noticed that you are filling your mask with 255, which will make all the pixels black--is this what you are seeing?  When you test it out are you seeing the template with a mask at all or the black?

 

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 23 of 26
(1,648 Views)

   

1) CWIMAQVision1.RegionsToMask ImageMask, CWIMAQViewer2.Regions, CWIMAQViewer2.Image, 255
2)      CWIMAQViewer2.Regions.RemoveAll
3)       CWIMAQVision1.Xor ImageMask, 255, ImageMask
4) CWIMAQVision1.Mask CWIMAQViewer2.Image, ImageMask, CWIMAQViewer2.Image

 

please note line1 , as the mention before, user select a ROI in first, it is CWIMAQViewer2.Regions, then transform the ROI to ImageMask as mask.

 

Line4 just implement a mask by ImageMask, as the result, I saw the select ragion is black only.

0 Kudos
Message 24 of 26
(1,645 Views)

Hi Jack,

 

The way that IMAQ saves masks is actually by saving an 8 bit image of that mask.  I believe that if you were to take that 8 bit image and convert it to a binary image, save it, and then use this as the template, it would work.  The red that you conventionally see for masks is a binary image.  Try using that mask that you have converted from 8 bit image to a binary image, as the template. 

 

Please let me know how this test goes. 

Marti C
Applications Engineer
National Instruments
NI Medical
0 Kudos
Message 25 of 26
(1,616 Views)

In this illustrative example, we will create a program in Labview capture an image pattern, after the search to show the location and coordinates, you can check the following article in the following link

 

https://decibel.ni.com/content/docs/DOC-31880

0 Kudos
Message 26 of 26
(1,078 Views)