Page 1 of 1

RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-24T06:43:35-07:00
by dschroeder
Hello,

we are trying to convert a RGB JPEG image to "colorspace CMYK" with the following command:

Code: Select all

$ convert -quality 100 input.jpg +profile icm -colorspace CMYK output.jpg
The resulting image looks extremely blurry and much too dark.
We are using ImageMagick 6.8.3.

Is there any way to produce results similar to ImageMagick 6.7.6 without the use of color profiles?
We recently Upgraded our Version to produce TIFF images in gray colorspace (link).

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-24T06:59:42-07:00
by snibgo
Can you supply the image?

You are deliberately ignoring any embedded profile. That might cause the darkness problem.

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-24T07:49:40-07:00
by dschroeder
I have uploaded the source image here. Even if I remove "+profile icm" from the command the result does not change.

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-24T09:44:00-07:00
by snibgo
The blur problem sounds like this: viewtopic.php?f=1&t=21934&p=93593 , and may be a bug.

I'm not convinced the darkening is wrong. IM converts sRGB->RGB->CMYK, and the results seem okay. If we complete the round trip ...

Code: Select all

convert output.jpg -colorspace sRGB -quality 100 o2.jpg
... we get back the tones we started with.

EDIT: In my manual cut-and-paste, I forgot to include "-colorspace sRGB".

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-27T03:13:21-07:00
by dschroeder
Okay, I confirm that converting with

Code: Select all

$ convert srgb_in.jpg -colorspace CMYK cmyk.jpg
and

Code: Select all

$ convert cmyk.jpg -colorspace sRGB srgb_out.jpg
result in the same tones.

ImageMagick (IM) 6.8
srgb_in.jpg and srgb_out.jpg have the same look.
Never the less the cmyk.jpg looks much too dark.

ImageMagick (IM) 6.7
srgb_in.jpg and srgb_out.jpg have the same look.
The cmyk.jpg result looks much brighter and more exactly.

It seems that there is something missing in the standard work flow of IM 6.8 like applying some gamma or something like that.

An other example:

Code: Select all

$ convert srgb_in.jpg -colorspace RGB rgb.jpg
$ convert rgb.jpg -colorspace CMYK cmyk.jpg
$ convert cmyk.jpg -colorspace sRGB srgb_out.jpg
In IM 6.7 the result looks like this. In IM 6.8 like that. The result in 6.7 is nearly the same like the source. In 6.8 the result does not match the source. Is it possible to get the same result in 6.8 like in 6.7?

EDIT: It seems like the sRGB->RGB conversion is the Problem. IM 6.7: rgb.jpg, IM 6.8: rgb.jpg

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-27T07:01:50-07:00
by snibgo
Which exact IM versions are you using? When I use 6.7.9-6 and 6.8.5-0 on Windows 7, the following ...

Code: Select all

"%IM%convert" srgb_in.jpg -colorspace CMYK cmyk679.jpg
"%IM%convert" cmyk679.jpg -colorspace sRGB srgb_out679.jpg

"%IMG685%convert" srgb_in.jpg -colorspace CMYK cmyk685.jpg
"%IMG685%convert" cmyk685.jpg -colorspace sRGB srgb_out685.jpg
... give me visually identical results.

Before about v6.7.9, sRGB/RGB was incorrect.

What software are you using to view the CMYK files? Do you know that its conversion from CMYK to RGB is correct?

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-27T08:18:43-07:00
by dschroeder
I am using Version 6.7.6-10 and Version 6.8.3-9 on Linux (x64).

Converting srgb_in.jpg with:

Code: Select all

$ convert srgb_in.jpg -colorspace RGB rgb.jpg
results in rgb.jpg with IM 6.7.6-10 and rgb.jpg with IM 6.8.3-9.

The "new" one is much too dark based on a comparison with:

Code: Select all

$ identify -verbose rgb.jpg
ImageMagick 6.7.6-10

Code: Select all

  Channel statistics:
    Red:
      min: 2 (0.00784314)
      max: 255 (1)
      mean: 133.027 (0.521675)
      standard deviation: 55.0611 (0.215926)
      kurtosis: -0.126029
      skewness: 0.221792
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 127.273 (0.499109)
      standard deviation: 68.1141 (0.267114)
      kurtosis: -1.00387
      skewness: 0.108367
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 148.466 (0.582221)
      standard deviation: 75.7242 (0.296958)
      kurtosis: -1.18457
      skewness: -0.406609
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 136.255 (0.534335)
      standard deviation: 66.8466 (0.262144)
      kurtosis: -0.890918
      skewness: -0.0541828
ImageMagick 6.8.3-9

Code: Select all

  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 74.1318 (0.290713)
      standard deviation: 61.811 (0.242396)
      kurtosis: 0.886192
      skewness: 1.3033
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 75.5948 (0.29645)
      standard deviation: 71.1728 (0.279109)
      kurtosis: -0.0588314
      skewness: 0.991768
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 103.01 (0.40396)
      standard deviation: 80.023 (0.313816)
      kurtosis: -1.26214
      skewness: 0.21345
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 84.2455 (0.330375)
      standard deviation: 71.3906 (0.279963)
      kurtosis: -0.367579
      skewness: 0.817872
The source image gives me:

Code: Select all

  Channel statistics:
    Red:
      min: 2 (0.00784314)
      max: 255 (1)
      mean: 132.935 (0.521314)
      standard deviation: 55.0972 (0.216067)
      kurtosis: -0.127459
      skewness: 0.222367
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 127.281 (0.499142)
      standard deviation: 68.1519 (0.267262)
      kurtosis: -1.00538
      skewness: 0.107592
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 148.398 (0.581951)
      standard deviation: 75.8519 (0.297459)
      kurtosis: -1.18251
      skewness: -0.408494
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 136.205 (0.534136)
      standard deviation: 66.9176 (0.262422)
      kurtosis: -0.891437
      skewness: -0.0551892

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-27T08:58:08-07:00
by snibgo
Yes, 6.7.6 was when IM was rather confused about RGB/sRGB.

If "in" is in colorspace sRGB, then "convert in -colorspace RGB out" should convert it to colorspace RGB. Approximately, this should convert values (from 0 to 1) by raising them to the power 2.2, which will lower them.

The source has overall mean 0.534136; raising to power 2.2 is 0.2485. This is much closer to the result you get from 6.8.3-9 than 6.7.6-10.

After doing the conversion, the pixel values are lowered, and the values represent RGB colorspace. Sadly, JPEG files don't seem to have a flag that says the values are RGB. So viewers think it is sRGB. As the values have been lowered, the image looks darker.

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-27T13:37:42-07:00
by GreenKoopa
I haven't been following this thread because I don't often work in CMYK, but I had a collision of two thoughts that MAY give a useful direction of inquiry concerning the blurring.

Thought 1: Your command doesn't do anything inter-pixel, so even a bug couldn't readily cause blur, so this is probably a channel sub-sampling issue when saving. Incorrect sub-sampling could be easily overlooked in jpeg's default Y'CBCR, but internal RGB or CMYK would show sub-sampling as clearly visible blurring.

Thought 2: I remember glancing something unexpected concerning sub-sampling. I didn't look into it because my process is usually jpeg -> png -> jpeg and this only shows up for jpeg -> jpeg. The documentation says that the default sub-sampling is based on the -quality setting, but it also says that the input jpeg's settings will be used for the output unless changed. So when you explicitly set -quality but do not explicitly set -sampling-factor, which controls the sub-sampling for the output?

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-27T17:09:09-07:00
by fmw42

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-27T17:14:46-07:00
by fmw42
I am using Version 6.7.6-10 and Version 6.8.3-9 on Linux (x64).
versions between 6.7.6.7 and 6.7.7.7 were when things were unstable regarding IM color space conversions. I would not tend to believe results in that range.

Note that -quality should be specified after reading the input jpg and before writing the output jpg.

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-27T18:30:35-07:00
by snibgo
Two other general points:

1. The OP mentions upgrading to make gray colorspace TIFFs. I suggest it is worth upgrading to 6.8.5, because that version (unlike 6.8.4, and versions back to 6.7.9) doesn't seem to make the assumption that greyscale images are RGB.

2. If any further processing it to be done to the images, I suggest avoiding JPG. The lossy compression used by JPG introduces artefacts that may be invisible in the JPG image, but become revealed by subsequent processing.

Re: RGB JPEG to CMYK JEPEG looks much too dark and blurry

Posted: 2013-05-28T03:11:41-07:00
by GreenKoopa
I confirmed my thoughts on the blur issue. To put my advice in a concrete example:

Code: Select all

convert wizard: in.jpg
convert in.jpg -colorspace CMYK -quality 92 out_blur.jpg
convert in.jpg -colorspace CMYK -quality 92 -sampling-factor 1x1 out_good.jpg
ImageMagick 6.8.5-6 2013-05-10 Q16 on Windows 7