Page 1 of 1

combining commands

Posted: 2015-10-15T06:12:50-07:00
by publikus
Hi
How can I combine these two imagemagick command into one. I want to compare two images by columns. I thing I'am wasting too much time to write results to a disk.

set /a "width = 1600"
set /a "height = 1200"
set /a "column = 5"
set /a "x = 0"

:while1
if %x% < %width% (
set /a "x = x + %column%"
convert sample.mpc -crop %column%x%height%+%x%+0 sample/cropped%x%.mpc
convert test.mpc -crop %column%x%height%+%x%+0 test/cropped%x%.mpc
compare -metric AE -fuzz 2%% sample/cropped%x%.mpc test/cropped%x%.mpc null 2>>differences.txt
goto :while1
)

Thank you so much for your help!

Re: combining commands

Posted: 2015-10-15T06:46:03-07:00
by snibgo
You can combine these three ...

Code: Select all

convert sample.mpc -crop %column%x%height%+%x%+0 sample/cropped%x%.mpc

convert test.mpc -crop %column%x%height%+%x%+0 test/cropped%x%.mpc

compare -metric AE -fuzz 2%% sample/cropped%x%.mpc test/cropped%x%.mpc null 2>>differences.txt
... into one convert. (Windows BAT syntax, untested.)

Code: Select all

convert ^
  ( sample.mpc -crop %column%x%height%+%x%+0 ) ^
  ( test.mpc -crop %column%x%height%+%x%+0 ) ^
  -metric AE ^
  -compare ^
  -format %%[distortion] ^
  info: >>differences.txt
(Untested.)

A "for" loop is probably quicker than "goto".

The loop could create a script file that builds just one convert command that reads sample.mpc and test.mpc just once, then does multiple crops (on clones) and comparisons. That would be massively quicker.

Re: combining commands

Posted: 2015-10-15T07:13:56-07:00
by publikus
Thank you very much!
I'am going to try it out.

Re: combining commands

Posted: 2015-10-15T12:31:13-07:00
by publikus
not working... :(

Re: combining commands

Posted: 2015-10-15T14:10:55-07:00
by publikus
I cant do this without writing converted images to disk.

Re: combining commands

Posted: 2015-10-15T14:58:20-07:00
by snibgo
Do you get any error messages? What is "not working"? What version IM are you on? If it is old, "convert" may not have the "-compare" operator. In that case, as you care only about how many pixels are different, you can "-compose Difference -composite" and change non-black into white and find the mean. This gives the proportion of pixels that are different. Multiply by W*H to get the number that have changed.

Re: combining commands

Posted: 2015-10-15T16:01:41-07:00
by publikus
It's OK! You syntax is working.
I did make a mistake :)
Thank you one more time!