17.12.2018 Views

Image Acquisitionand Proces

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Image</strong> Analysis 171<br />

7.1.3 A PRACTICAL EXAMPLE<br />

The example in Figure 7.7 uses Interactive Pattern Matching Example.vi<br />

(which is on the accompanying CD-ROM) to:<br />

• Prompt the user to load an image to be searched.<br />

• Interactively deÞne a rectangular ROI (the search template).<br />

• Set search parameters.<br />

• Perform a pattern matching.<br />

Once the source image has been loaded, the user deÞnes a ROI, and then presses<br />

the Learn Template button, which calls the code shown in Figure 7.8.<br />

As you can see, the ROI’s global rectangle is returned, and its corresponding underlying<br />

portion is extracted from the source image — this forms the search template. The<br />

next step is to train the system to recognize it, which is achieved by Þrst deÞning the<br />

learn pattern parameters using IMAQ Setup Learn Pattern. This VI simply creates<br />

a learn pattern parameter string based on one input: learn mode. Learn mode speciÞes<br />

the invariance mode to use when learning the pattern. You can choose from values shown<br />

in Table 7.2. Once the template is learned, the next step is to search for it. First, deÞne<br />

searching criteria with IMAQ Setup Match Pattern. Like IMAQ Setup Learn Pattern,<br />

this VI simply constructs a match pattern parameter string based on its inputs (Table<br />

7.3). The actual searching process is executed in IMAQ Match Pattern. Feed the source<br />

image, template and match pattern parameters (from IMAQ Setup Match Pattern)<br />

into this VI, and it will search the source for the template.<br />

Two further methods of increasing the speed of the search include deÞning a<br />

rectangle within the source image to be searched (if you know that the object is<br />

going to be in a particular area of the source image, then there is no sense in searching<br />

the whole image), and deÞning the number of matches requested. If you are sure<br />

that the image will only have a maximum number of instances of the search object,<br />

once they are found it wastes time looking for further instances (Figure 7.9).<br />

The same pattern match could be even faster. Simply rotate the source image<br />

and template 180∞ before performing the search, which causes even less of the source

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!