Page 1 of 1

subimage with different size

Posted: 2013-12-29T04:58:30-07:00
by betty1978
hello,
i have a problem and i can't find a solution. I created a marker, and i want to search this marker on a Pictue. I think the Problem is the different size from the marker in my image or i need another marker for ImageMagick.

This is the created marker:
Image

And this is my Picture:
Image

I convert the image with follow Command:

Code: Select all

convert original1.png -colorspace Gray -negate -edge 1 -negate original.png
The result is this image:
Image

Now i search the marker with this Command:

Code: Select all

compare -metric rmse -subimage-search original.png maske.png result.png
17735.4 (0.270625) @ 234,198

Image

This position is wrong, and i make a new Image with this Command

Code: Select all

convert original1.png -fuzz 20% -fill black -opaque "#3b3b38" -fuzz 20% -fill white -opaque "#989692" test.png
The result is:
Image

Code: Select all

compare -metric rmse -subimage-search test.png maske.png result1.png
17861.8 (0.272554) @ 230,87

Image

The same Problem, now is the position on top from my marker.
Has anyone any idea what can i do?

Re: subimage with different size

Posted: 2013-12-29T06:31:55-07:00
by snibgo
betty1978 wrote:I think the Problem is the different size from the marker in my image ...
Yes, that is the main problem. IM won't automatically resize images to search for a match. If you place one image over the other, you can see that if one corner mark lines up, the others won't.

One trick is to look for small distinctive features. The diagonal cross is distinctive. So crop to that, and then search:

Code: Select all

convert maske.png -gravity center -crop 50%%x50%%+0+0 m.png

compare -metric rmse -subimage-search original.png m.png result.png
The result is then correct.