My script srchImg.bat searches for a subimage within a large image.
Calling the script will return a single result. It won't return multiple results. It does contain facilities (siDELTEMPSRC etc) to reduce processing if a second search, with a different subimage, is done on the same large image. But if you want to find all the exact matches of a subimage within a large image, the script won't do that. It could be modified to do that. Or it could be called multiple times, changing the large image between calls to black-out the previous found result, but that would be very inefficient.
It speeds up processing when the sub-image is fairly large, eg 100x100 or larger. It gives no acceleration when the sub-image is less than 10x10.
As I explain on my page, it can theoretically find a match that isn't the best possible match, but I've never seen that happen in ordinary photographs.
Your sub_image_water.png is only 5x3 pixels, so is too small for srchImg.bat to be helpful.
Where zurich.png is your street map of Zurich, 1024x632 pixels:
Code: Select all
compare -metric RMSE -subimage-search zurich.png sub_image_water.png zurich_water.png
This takes about 14 seconds. zurich_water-1.png is:
The best matches are shown in lighter tones. A perfect match would be white, but there are no perfect matches.
Your sub_image_water.png is almost a constant colour. We can find its mean colour, scale it to the same size as zurich.png, and find the difference:
Code: Select all
convert sub_image_water.png -scale 1x1! -scale 1024x632! zurich.png -compose Difference -composite -negate -grayscale Average zurich_water_2.png
I negate and grayscale for easy comparison. Again, near-white is water. This takes 0.12 seconds. We have improved performance by a factor of 100. It is also less blurred.
If you want to find occurrences of a particular colour in a large image, "-composite" is very much quicker than "-subimage-search".