ANA.CompareBlock

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Image/Pixel-Color Operations > ANA. - Imageworks > Pattern-Recognition >

ANA.CompareBlock

ANA.CompareBlock

Previous Top Next


MiniRobotLanguage (MRL)

 

ANA.CompareBlock

Compares a rectangular area in an Image-Register (IR) with a given Pattern.
The result includes the number of pixel hits and a 0/1 value indicating whether the pattern matches at that position.

 

 

Intention

 

The ANA.CompareBlock command allows you to compare a rectangular area within an Image-Register (IR) with a specified Pattern.

It provides information on the number of pixel hits and whether the pattern matches at the given position.

This command is useful when you need to assess the similarity or presence of a pattern within a specific area of an image.

This command will compare a rectangular Area in an IR with the given Pattern.
The result will be the number of Pixel-Hits and 0/1  if the Pattern will match at that place, on TOS.

 

 

For more  Details please see the

ANA.FindPattern Command

 

 

 

Syntax

 

ANA.CompareBlock|P1|P2[|P3][|P4][|P5][|P6]

 

Parameter Explanation

 

P1 - Target Image-Register (IR): The Image-Register containing the target area for comparison.

P2 - Pattern Image-Register (IR): The Image-Register containing the pattern to be compared.

 

P3 - X-Position in Target: The X-coordinate of the upper-left corner of the target area.

P4 - Y-Position in Target: The Y-coordinate of the upper-left corner of the target area.

P5 - Color Tolerance: The allowed difference in color values between the target and pattern pixels.

P6 - Pixel-Hits Needed: The minimum number of pixel hits required for the pattern to be considered a match.

 

About the P6 - Parameter ("Pixel-Hits"):

The maximum number of matching pixels in your pattern is determined by its size.

For example, an 8x8 pattern can have up to 64 matching pixels, whereas a 24x8 pattern can have up to 192.

P6 is based on the total number of pixels in the pattern.

If you set it to 63, for instance, it means that at least 63 pixels must match the pattern, including the tolerance.

If you input a negative number for P6, such as "-15", it's treated as a percentage of the total pixel count, translating to "15% of the maximum pixels of that pattern".

If you leave it empty or set it to 0, the default value will be 85% of the pixel count in the pattern.

P4 denotes the minimum number of matches needed to accept a result.

Be careful not to set P6 too low, as it could potentially overwhelm the system with a massive number of results.

 

This command has some special features regarding the "Pixel-Hit Tolerance Parameters".

1.If you specify "0", the command will calculate the maximum possible number of hits for the loaded pattern and take 85% of that value.

2.If you specify a negative value like "-69", the command will also calculate the maximum possible number of hits for the loaded pattern and take that as 100%. In this example, it would be 69%, so if this is a 12x12 pattern and therefore has a maximum of 144 pixel-hits, 69% of that would be 99 pixels.

3.You can directly specify a positive value that is the exact number of needed pattern-pixels for the pattern to be considered as found.

4.The maximum number of found results is limited by the setting of "MaxResults" using the ANA.SetData command.

5.Due to the use of multiple CPU cores at different places at the same time, there is no guarantee in which order matches are returned.

6.The command will leave a 0/1 on the TOS. As always, a 0 means error, while a 1 means "all fine". For example, if one of the IR's does not exist, then you will get a result "0" on TOS. The program will not generate an error message.

 
Get the result on TOS

This command will compare a rectangular Area in an IR with the given Pattern.

The result will be the number of Pixel-Hits and 0/1  if the Pattern will match at that place, on TOS.

 

 

Example

 

' To compare a rectangular area in IR 0 with the pattern in IR 1 at position (10, 20)
' with a color tolerance of 5 and requiring at least 50 pixel hits, use the following command:

ANA.CompareBlock|0|1|10|20|5|50|1

 

 

 

Remarks

Speed Considerations:

1. The Command is "Multithreaded" and works best with a Multicore CPU.

2. The Command will need a lot of CPU-Power, it may also use the GPU at some point internally.

3. Generally the Command is very fast even in very large windows, as long as the Computer has a modern CPU.

4. The larger the Pattern, the slower the process.

5. Currently it may speed up the process, if you have the pattern touch the upper left corner. This may change in the future.

6. If a Pattern is very slow, just record another Pattern. And try this again.

7. A pattern that is completely empty will not work as there is nothing to recognize in it.

 

Do not use ".jpg" Images or images that are compressed with Artefacts. Generally use ".bmp" or ".png" Images. Otherwise the result will be hard to predict.

 

Limitations:

 

The resolution of the Pattern-Images that can be used is limited to those resolutions that can be saved with the "Human Eye-Recorder"-Tool.

 

 

See also:

 

    ANA_FindPattern