coordinates of two images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
adelina
Posts: 18
Joined: 2011-08-03T04:01:45-07:00
Authentication code: 8675308

coordinates of two images

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: coordinates of two images

Post 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"
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: coordinates of two images

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: coordinates of two images

Post 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.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: coordinates of two images

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: coordinates of two images

Post 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.
adelina
Posts: 18
Joined: 2011-08-03T04:01:45-07:00
Authentication code: 8675308

Re: coordinates of two images

Post by adelina »

I want the coordinates of every pixel that are different between two same size images.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: coordinates of two images

Post 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
Post Reply