Page 1 of 1

possible MPC format bug IM 6.8.3.6

Posted: 2013-03-04T16:57:06-07:00
by fmw42
Mac OSX Snow Leopard


convert -version
Version: ImageMagick 6.8.3-6 2013-02-27 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC Modules
Delegates: bzlib fftw fontconfig freetype gslib jng jp2 jpeg lcms lqr lzma openexr png ps tiff x xml zlib


The following two sets of commands produce quite different results and I believe the issue is with MPC.

The MIFF results match those using PNG. You will note that the first two lines produce the same sets of unique colors and the images look the same for the first line. So it would appear to be something in the last line.

# good
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -write show: 1tmp1.miff
convert 1tmp1.miff -unique-colors txt:- | tail -n +2 | tr -cs ".0-9\n" " " | cut -d' ' -f3
convert 1tmp1.miff -channel rgba -fill white -opaque "gray(170)" -fill none +opaque white show:

# bad
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -write show: 1tmp1.mpc
convert 1tmp1.mpc -unique-colors txt:- | tail -n +2 | tr -cs ".0-9\n" " " | cut -d' ' -f3
convert 1tmp1.mpc -channel rgba -fill white -opaque "gray(170)" -fill none +opaque white show:

Re: possible MPC format bug IM 6.8.3.6

Posted: 2013-03-04T18:30:01-07:00
by magick
Both PNG and MIFF force a depth of 8 whereas the MPC format does not, it stays at 16 bits for ImageMagick Q16:

Code: Select all

convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB 1tmp1.miff
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB 1tmp1.png
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB 1tmp1.mpc
compare -metric rmse 1tmp1.png 1tmp1.miff null:
0 (0)
compare -metric rmse 1tmp1.mpc 1tmp1.miff null:
99.6065 (0.0015199)
Add -depth 8 to your command line to get identical results:

Code: Select all

convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -depth 8 1tmp1.miff
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -depth 8 1tmp1.png
convert rose: -set colorspace RGB -colorspace gray -posterize 6 -colorspace sRGB -depth 8 1tmp1.mpc
compare -metric rmse 1tmp1.png 1tmp1.miff null:
0 (0)
compare -metric rmse 1tmp1.mpc 1tmp1.miff null:
0 (0)

Re: possible MPC format bug IM 6.8.3.6

Posted: 2013-03-04T19:02:07-07:00
by fmw42
Thanks. That fixed it in my actual script as well.

Re: possible MPC format bug IM 6.8.3.6

Posted: 2013-03-21T18:52:50-07:00
by anthony
And this I have an objection to..


-depth here does not just set the output image depth (as a setting), but actually modifies the in memory image (reducing the pixel quality).

This means exactly where -depth occurs can have a big impact on image results, as it is actually an operator.