compare subimage-search returns me different start-coordinates for the found image
Posted: 2018-11-16T02:44:53-07:00
I have two images. Both are black/white images and generated by “convert orig_x.png -threshold 90% x_threshold_90.png”. The results are two black images with a white line:
- A_threshold_90.png has a line from y-coordinate 644 – 645
- B_threshold_90.png has a line from y-coordinate 643 – 644
Then I generate a 3rd image with a white line of 1293x1 by:
convert -size 1293x1 xc:white whiteLine1293x1pixel.png
In last step, I try to find the image “findThisLine.png” in my threshold-generated images. My wish is to find the y-coordinate of the white line:
compare -metric rmse -subimage-search A_threshold_90.png whiteLine1293x1pixel.png diff.png
0 (0) @ 627,644
compare -metric rmse -subimage-search B_threshold_90.png whiteLine1293x1pixel.png diff.png
0 (0) @ 627,644
As you can see, I get the response for y=644 on each image. Only if I try this again with a 2-pixel wide subimage, than I get the right response:
compare -metric rmse -subimage-search A_threshold_90.png whiteLine1293x2pixel.png diff.png
0 (0) @ 627,644
compare -metric rmse -subimage-search B_threshold_90.png whiteLine1293x2pixel.png diff.png
0 (0) @ 627,643
Using the 2 pixel wide line for search is not possible in my use case. Why ever, the response by searching for 1-pixel line is the upper part of in one image and the lower part in the second image. Can anyone tell me where my mistake is?
- A_threshold_90.png has a line from y-coordinate 644 – 645
- B_threshold_90.png has a line from y-coordinate 643 – 644
Then I generate a 3rd image with a white line of 1293x1 by:
convert -size 1293x1 xc:white whiteLine1293x1pixel.png
In last step, I try to find the image “findThisLine.png” in my threshold-generated images. My wish is to find the y-coordinate of the white line:
compare -metric rmse -subimage-search A_threshold_90.png whiteLine1293x1pixel.png diff.png
0 (0) @ 627,644
compare -metric rmse -subimage-search B_threshold_90.png whiteLine1293x1pixel.png diff.png
0 (0) @ 627,644
As you can see, I get the response for y=644 on each image. Only if I try this again with a 2-pixel wide subimage, than I get the right response:
compare -metric rmse -subimage-search A_threshold_90.png whiteLine1293x2pixel.png diff.png
0 (0) @ 627,644
compare -metric rmse -subimage-search B_threshold_90.png whiteLine1293x2pixel.png diff.png
0 (0) @ 627,643
Using the 2 pixel wide line for search is not possible in my use case. Why ever, the response by searching for 1-pixel line is the upper part of in one image and the lower part in the second image. Can anyone tell me where my mistake is?