Can someone explain why the following occurs?
compare -metric rmse -subimage-search A.bmp B.bmp C.bmp
Where A.bmp is 175x335 pixels (114 dpi) and B.bmp is 16x16 pixels (114dpi)
We expect 2 output files, and find:
C-0.bmp (size 175x335)
C-1.bmp (size 160x320) ??
I would have expected C-1.bmp to be 175x335 pixels, so why is it smaller? Is this because we are only comparing 1/2 of the B.bmp file at the edges of A.bmp? Notice that the size is approximately size A - size B.
How can I get C-1.bmp to properly remap to the original 175x335 size of A.bmp image? In other words, I need the exact pixel locations to match. I assume that C-1.bmp got trimmed about 8 units all around each edge.
Later on I do some HMT kernal work and will need exact pixel alignment. Is there an easy way to add back a gray scale 8 pixel border to C-1.bmp so it resumes the original 175x335 pixel size?
Thanks for your help, I just discovered this problem when doing some image scanning work with a Macro Editor.
Randall
compare -metric rsme -subimage search oddity
-
- Posts: 2
- Joined: 2013-05-29T15:41:08-07:00
- Authentication code: 6789
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: compare -metric rsme -subimage search oddity
The second image was not trimmed.
The second image is the match score image. It only covers the size of the first image less the second, because it is looking at every position of the second image that is contained within the first image. That is every position for the top left corner of the second image such that the the second image does not go outside the first image.
You can add back a gray border by using
convert C-1.bmp -background gray50 -gravity northwest -extent 175x335 resultimage
But mid gray probably should be black, since that means no match. Note zero is no match and white is perfect match.
The second image is the match score image. It only covers the size of the first image less the second, because it is looking at every position of the second image that is contained within the first image. That is every position for the top left corner of the second image such that the the second image does not go outside the first image.
You can add back a gray border by using
convert C-1.bmp -background gray50 -gravity northwest -extent 175x335 resultimage
But mid gray probably should be black, since that means no match. Note zero is no match and white is perfect match.
-
- Posts: 2
- Joined: 2013-05-29T15:41:08-07:00
- Authentication code: 6789
Re: compare -metric rsme -subimage search oddity
Thanks for your reply, I actually figured out how to grab the C-0.bmp and convert it to gray54 since that was the actual output from the compare command, and then overlay the C-1.bmp on top of the gray background using the -gravity center command, as you demonstrated.
It might be worthwhile to add some information to the command line information about this as it caught me by surprise.
Thanks
It might be worthwhile to add some information to the command line information about this as it caught me by surprise.
Thanks