In this Clarity demonstration video, we will be talking about Pattern Match. Pattern Match allows you to train a pattern, and find the pattern in images. I’ve loaded these images that I previously captured on a live device of a JADAK business card. We will train a pattern on the “visionary” word at the bottom of the card.
The first step is to go up to the Pattern Match plug-in and the first thing after clicking on it will bring up a dialogue asking you to train a new pattern. There are two different types of Pattern Matches: Pixel Match and Edge Match. Pixel Match will train an image and try to match pixel per pixel on the image you are searching. We’ll start with that one.
To train a pattern, drag the ROI (Region of Interest) over to the “visionary” word. And I’ll just adjust the ROI to the area I want to train to. You can make this as large or small as you want to actually train your pattern. I can train it to the “ry” or I can train it to the whole word “visionary.” I can also train it to non-words, I can train it to corners or other fiducial marks within the image. I’ll start by training it to “visionary.” And accepting that as our trained pattern. [Click Accept]
Down here you’ll see that our pattern shows up and that it correctly finds it within the image we are searching, within this ROI, which is our region of interest. As we cycle through the images and run to the next image, I’ve mocked up this image to remove the “y” in the “visionary” word. This pattern is searching inside this ROI, pixel per pixel, for a match. Removing the “y” results in about a 10% score drop, and that’s because most of the letters of “visionary” are here. This is an example of the how the score can lower based on how the pattern is getting degraded. I could raise my passing score requiring it to have a high score in order to pass. You can see that this failed by the red border on the Pattern Match, and the red ROI.
I’ll go ahead and set this back down to a value of 90. As we run through the next image, this image fails because the word “visionary” is outside of our searching region. I can account for this by enlarging the searching region and now it correctly finds it. And we’ll continue to go through the images to make sure all of the patterns can be found… Which it does.
Next I’ll show you the Min and Max Angle feature of Pattern Match, will allows restrictions placed on the amount of angle movement we actually want to find the pattern. We can lower the tolerances of the Min Angle and the Max Angle. Now it is no longer found, because the Max Angle is outside of 8 degrees. This is a trained pattern, which we trained on the horizontal orientation, by more than 8 degrees. We can enlarge this again to find the pattern. Or you can open these angles up to allow more rotation allowed from your pattern.
Next let’s look at the Edge Match. You can retrain a new pattern by clicking the New Pattern button and selecting the Edge Match. Or you can go back and retrain a new pixel pattern.
I’m actually going to go back to our horizontal orientation to train the images. Training generally should be done on the image that you’re expecting the normal pattern to be.
Here I’ll select Edge Match, and we can work on trying to train the word “visionary.” As with Pixel Pattern match, you don’t have to train on just words, but it can be features. I can train on a corner and look for this corner of this card. I can look at edges of the QR code finder. But edge match will ultimately look for borders of objects with good contrast. By training on the word “visionary,” the Granularity and Kernel Size allow me to finely tune the edge match pattern. If I lower the Kernel Size, you’ll notice the words “visionary” becomes more pronounced with the borders. And I can accept this as our trained pattern. Which finds it in the image we were training on. Like pixel match, with the image with the “y” removed, the score lowers. The difference between edge and pixel are there are less pixels being compared. It’s really just the edge pixels being compared with Edge Match, so the resulting score drop is lower. Our Pixel pattern match dropped to 90, where Edge match dropped to 80. The Edge Match will be more sensitive to pattern degradation. But as I continue through the images, you’ll see that the word “visionary” is found in the orientations.
One of the benefits of Pattern Match is to be able to use it as an anchor for another step. We’ve already trained the “visionary” word at the bottom of the card. Next we want to decode the barcode on the card. If we have an ROI located here, as the card moves the barcode will go outside of the ROI. Normally ROIs are anchored to 0,0, at the top left of the image. We can now anchor it to Pattern Match. This means that the ROI is now relative to the “visionary” word that we’ve trained. So as the “visionary” word moves, so will the barcode ROI. This step the “y” was removed, resulting in a low score and failure. So the decode won’t run, because the pattern wasn’t found. Now as the visionary moves, the ROI will move with the “visionary” word. It will also rotate to the correct orientation.
This is a powerful feature. It means you can find the fiducial in an image and have all of the following ROIs be based on that fiducial mark. This allows you to account for mechanical tolerances or movements of the object that you’re looking for in the image.
Pattern match is an important tool in Clarity and can be used as anchor points or to finding features. One last thing to note is that when training, try to make your ROI as tight as possible to the marks in the image you are trying to train.
Also note that because pixel match is comparing pixel to pixel of the image, it generally is a more intensive operation and may take longer. Edge match is faster because it’s just looking for the edges of contrast within the image.