Compare colors aren't correct for CMYK source images

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
simon.h
Posts: 3
Joined: 2018-02-26T02:08:28-07:00
Authentication code: 1152

Compare colors aren't correct for CMYK source images

Post by simon.h »

Hi everyone,

I have a problem when using the compare command with CMYK input images. It seems that the highlight and lowlight colors of the compare result are inverted or converted incorrectly. The red highlight color becomes cyan and the white transparent lowlight color becomes black(?) transparent. Also if I define a highlight color by name i.e. "seagreen" the compare result shows the wrong color as well.

I tested it with two different ImageMagick versions:

ImageMagick 6.8.6-10 2017-07-17 Q16 / Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)
-> CORRECT

ImageMagick 7.0.7-4 Q16 x86_64 2017-09-29 / Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)
-> NOT CORRECT

The former version is the one we are currently using the latter one is the version we want to upgrade to but has the described issue. You can download my test data using the following link:

CompareTest.zip

I used the following commands:

Code: Select all

compare -metric AE CompareTest_A.jpg CompareTest_B.jpg CompareTest_OUT.jpg.pdf
compare -metric AE CompareTest_A.pdf CompareTest_B.pdf CompareTest_OUT.pdf.pdf
compare -metric AE CompareTest_A.tif CompareTest_B.tif CompareTest_OUT.tif.pdf

compare -metric AE -highlight-color seagreen CompareTest_A.jpg CompareTest_B.jpg CompareTest_OUT-seagreen.jpg.pdf
compare -metric AE -highlight-color seagreen CompareTest_A.pdf CompareTest_B.pdf CompareTest_OUT-seagreen.pdf.pdf
compare -metric AE -highlight-color seagreen CompareTest_A.tif CompareTest_B.tif CompareTest_OUT-seagreen.tif.pdf
Can anyone reproduce the problem or know how to solve it? Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Compare colors aren't correct for CMYK source images

Post by fmw42 »

What values did you get that tell you they are different? Why do all your outputs have PDF suffixes?

Have you tried comparing in sRGB colorspace? Color inversion is an indication of that problem or possibly the viewer cannot handle it. Is your output image CMYK or RGB?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Compare colors aren't correct for CMYK source images

Post by fmw42 »

I have checked with IM 6.8.6.8, 6.9.9.35 and 7.0.7.23. All produce the same metric scores. All images display correctly in Imagemagick display. But the 7.0.7.23 version display inverted when using Mac Preview, whereas the others display properly in Mac Preview.

These were my commands:

Code: Select all

compare -metric AE CompareTest_A.jpg CompareTest_B.jpg -format "\n" CompareTest_OUT_69935.jpg
compare -metric AE CompareTest_A.pdf CompareTest_B.pdf -format "\n" CompareTest_OUT_69935.pdf
compare -metric AE CompareTest_A.tif CompareTest_B.tif -format "\n" CompareTest_OUT_69935.tif


im7 magick compare -metric AE CompareTest_A.jpg CompareTest_B.jpg -format "\n" CompareTest_OUT_70723.jpg
im7 magick compare -metric AE CompareTest_A.pdf CompareTest_B.pdf -format "\n" CompareTest_OUT_70723.pdf
im7 magick compare -metric AE CompareTest_A.tif CompareTest_B.tif -format "\n" CompareTest_OUT_70723.tif


im68610 compare -metric AE CompareTest_A.jpg CompareTest_B.jpg -format "\n" CompareTest_OUT_68610.jpg
im68610 compare -metric AE CompareTest_A.pdf CompareTest_B.pdf -format "\n" CompareTest_OUT_68610.pdf
im68610 compare -metric AE CompareTest_A.tif CompareTest_B.tif -format "\n" CompareTest_OUT_68610.tif


The compare output images for IM 6.9.9.35 and IM 7.0.7.23 do show different verbose information about the color channel statistics


6.9.9.35

Code: Select all

Image: CompareTest_OUT_69935.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1890x1417+0+0
  Resolution: 118x118
  Print size: 16.0169x12.0085
  Units: PixelsPerCentimeter
  Colorspace: CMYK
  Type: ColorSeparation
  Base type: Undefined
  Endianess: Undefined
  Depth: 8-bit
  Channel depth:
    cyan: 8-bit
    magenta: 8-bit
    yellow: 8-bit
    black: 8-bit
  Channel statistics:
    Pixels: 2678130
    Cyan:
      min: 0  (0)
      max: 44 (0.172549)
      mean: 21.1234 (0.0828368)
      standard deviation: 19.8929 (0.0780113)
      kurtosis: -1.98163
      skewness: -0.116133
      entropy: 0.214268
    Magenta:
      min: 0  (0)
      max: 247 (0.968627)
      mean: 27.6319 (0.10836)
      standard deviation: 38.3535 (0.150406)
      kurtosis: 12.9604
      skewness: 3.17549
      entropy: 0.210162
    Yellow:
      min: 0  (0)
      max: 255 (1)
      mean: 7.07962 (0.0277632)
      standard deviation: 39.3774 (0.154421)
      kurtosis: 28.276
      skewness: 5.46216
      entropy: 0.0483358
    Black:
      min: 0  (0)
      max: 27 (0.105882)
      mean: 0.792447 (0.00310763)
      standard deviation: 4.37953 (0.0171746)
      kurtosis: 26.5912
      skewness: 5.34687
      entropy: 0.0823198

7.0.7.23

Code: Select all

Image: CompareTest_OUT_70723.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 1890x1417+0+0
  Resolution: 118x118
  Print size: 16.0169x12.0085
  Units: PixelsPerCentimeter
  Colorspace: CMYK
  Type: ColorSeparation
  Base type: Undefined
  Endianess: Undefined
  Depth: 8-bit
  Channel depth:
    cyan: 8-bit
    magenta: 8-bit
    yellow: 8-bit
    black: 1-bit
  Channel statistics:
    Pixels: 2678130
    Cyan:
      min: 189  (0.741176)
      max: 247 (0.968627)
      mean: 224.757 (0.8814)
      standard deviation: 20.0312 (0.0785537)
      kurtosis: -1.94528
      skewness: -0.109149
      entropy: 0.22037
    Magenta:
      min: 0  (0)
      max: 247 (0.968627)
      mean: 218.7 (0.857645)
      standard deviation: 43.8421 (0.17193)
      kurtosis: 15.6772
      skewness: -3.67337
      entropy: 0.211097
    Yellow:
      min: 18  (0.0705882)
      max: 209 (0.819608)
      mean: 198.45 (0.778235)
      standard deviation: 28.1069 (0.110223)
      kurtosis: 29.4565
      skewness: -5.54747
      entropy: 0.206011
    Black:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: nan
So something is different between IM 7 and IM 6.
simon.h
Posts: 3
Joined: 2018-02-26T02:08:28-07:00
Authentication code: 1152

Re: Compare colors aren't correct for CMYK source images

Post by simon.h »

The PDF suffix is just related to our use case. But the problem also occurs with the other output formats jpg and tif.

Indeed I use macOS (10.12.6) to review the output files but I also use Photoshop to display the compare results and it shows wrong colors too. The output images are CMYK. When comparing RGB images there seems to be no problems regarding the compare result colors.

Also if I take the compare results of both ImageMagick versions and compare these again (using version 6.8.6) every pixel is highlighted red in the output image. So as you also said, there is a difference.
Post Reply