Page 1 of 1

Compare 2 images, and export the difference to txt file

Posted: 2018-07-22T20:38:14-07:00
by philhung
Hi All,

I use the command to find the difference between the below 2 images

https://photos.app.goo.gl/HzrdYycdhgbBacZ19
https://photos.app.goo.gl/9ckbkprJwezqDCJM7

Code: Select all

Compare -compose src c:\black1.png c:\black2.png c:\black_diff.png
the below is the output image
https://photos.app.goo.gl/UwNqWWgN3cXWQNjL7

and I want to convert that output image with difference only to be txt file for data processing by the below 2 commands.

output file size very large...

Code: Select all

convert c:\black_diff.png -transparent "#CCCCCC" sparse-color: c:\a.txt
output file contains nothing...

Code: Select all

convert c:\black_diff.png -transparent "#CCCCCC" sparse-color: > c:\b.txt
thanks for your help in advance!!!

Re: Compare 2 images, and export the difference to txt file

Posted: 2018-07-23T02:45:18-07:00
by snibgo
black_diff.png already has transparency, and the search for opaque pixels #CCCCCC finds none. You can "-alpha off" to remove any transparency.

Re: Compare 2 images, and export the difference to txt file

Posted: 2018-07-26T02:32:40-07:00
by philhung
Many thanks for your reply.
I still have few questions

1. how we know that black_dif.png with transparency?? is it I use Compare to find the difference??
2. I tried the below command with -alpha off, just want to make sure my understanding is correct

Code: Select all

convert c:\black_diff.png -transparent "#CCCCCC" -alpha off sparse-color: > c:\b.txt
thanks!!

Re: Compare 2 images, and export the difference to txt file

Posted: 2018-07-26T04:32:55-07:00
by snibgo
You should turn alpha off before the search:

Code: Select all

convert c:\black_diff.png -alpha off -transparent "#CCCCCC" sparse-color: > c:\b.txt

Re: Compare 2 images, and export the difference to txt file

Posted: 2018-07-29T22:50:47-07:00
by philhung
many thanks for your support!!!