Page 1 of 1

coordinates of two images

Posted: 2011-08-08T05:18:19-07:00
by adelina
Hi,I need to find the coordinates of two images to find the differences between them to see if they shift or not.

Re: coordinates of two images

Posted: 2011-08-08T10:04:33-07:00
by fmw42
Please clarify in more detail what you are trying to do? Do you want the coordinates of every pixel that are different between two same size images? Or are you trying to find the best match of a smaller image where it matches best inside a larger image?

For the latter, see

compare -metric rmse -subimage-search largeimage smallimage resultimages

where resultimages will be either two image -0 and -1 or two frames (but you only specify the name), depending upon format. The second image will be the match score result and the brightest pixel will be the location of the best match. The best match will also be returned as text to the terminal.

see example at viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076 but note that since then the -subimage-search needs to be added to the command


For the former, see http://www.imagemagick.org/Usage/compare/

Once you get the red/white image or black/white image (see examples above), you can convert that image to txt format to get all the say red value coordinates. see http://www.imagemagick.org/Usage/files/#txt

convert red_white_image txt:- | grep "red"

Re: coordinates of two images

Posted: 2011-08-08T17:08:53-07:00
by anthony
fmw42 wrote:convert red_white_image txt:- | grep "red"
This may not work with a normal "compare" image result. The color is not pure red, but a red tint of one of the images.

Re: coordinates of two images

Posted: 2011-08-08T17:15:52-07:00
by fmw42
anthony wrote:
fmw42 wrote:convert red_white_image txt:- | grep "red"
This may not work with a normal "compare" image result. The color is not pure red, but a red tint of one of the images.
I understand. That is why I specifically pointed to your processing to extract the binary mask as either red/white or black/white.

Re: coordinates of two images

Posted: 2011-08-08T17:47:49-07:00
by anthony
Fair enough...

I just wanted to point out the 'normal' compare is not pure red-white or black-white, as it did not seem clear.

Re: coordinates of two images

Posted: 2011-08-08T17:49:41-07:00
by fmw42
anthony wrote:Fair enough...

I just wanted to point out the 'normal' compare is not pure red-white or black-white, as it did not seem clear.

OK. Thanks. Fair enough.

Re: coordinates of two images

Posted: 2011-08-09T00:17:14-07:00
by adelina
I want the coordinates of every pixel that are different between two same size images.

Re: coordinates of two images

Posted: 2011-08-09T09:30:38-07:00
by fmw42
adelina wrote:I want the coordinates of every pixel that are different between two same size images.

see
http://www.imagemagick.org/Usage/compare/#difference
http://www.imagemagick.org/Usage/files/#txt

Example:


Image

Image


convert cyclops.png cyclops3.png \
-compose difference -composite \
-colorspace gray -threshold 0 \
txt:- | grep "white"


49,49: (255,255,255) #FFFFFF white
50,49: (255,255,255) #FFFFFF white
51,49: (255,255,255) #FFFFFF white
49,50: (255,255,255) #FFFFFF white
50,50: (255,255,255) #FFFFFF white
51,50: (255,255,255) #FFFFFF white
49,51: (255,255,255) #FFFFFF white
50,51: (255,255,255) #FFFFFF white
51,51: (255,255,255) #FFFFFF white