Comment 3 for bug 878864

Revision history for this message
Nicole Demers (nicole-a-demers) wrote : Re: [request] want Pattern.anySize() and Pattern.anyColor()

I know this is a bit late, but here it goes:

There is an algorithm for image stretching that generates a larger image pattern from a smaller one that could then be used to match from for anySize(). The pixels in the smaller image are sent to their relative positions in the larger version of the image.

Imagine each [value] is a pixel:

Image pixels are pulled from (Source):
[red] [red]
[red] [blu]

Larger image pixels are drawn into:
[red] [red] [red]
[red] [red] [red]
[red] [red] [blu]
[red] [red] [blu]

or

[red] [red] [red] [red]
[red] [red] [red] [red]
[red] [red] [blu] [blu]
[red] [red] [blu] [blu]

The most important thing is to consistently round up or down every time when calculating the pixel to get your colour from.

Algorithm Steps:
1. Generate a new image, the destination, in the size you require
2. Iterate over destination's pixels, calculating the source pixel to get your colour value from
3. Set the colour value in destination based on the source calculation

This would generate an image that can be used to match whatever size you need.

If you don't know the size it might be possible to use template matching to find similar patterns to your search image on the screen then generate images in the correct size based on the template matches and try to find using a differently sized version of the pattern to match. The processing time might be a bit slow. (Very, very slow)