RGB JPEG to CMYK JEPEG looks much too dark and blurry

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dschroeder
Posts: 6
Joined: 2013-01-08T04:42:06-07:00
Authentication code: 6789

RGB JPEG to CMYK JEPEG looks much too dark and blurry

Post 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).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo »

Can you supply the image?

You are deliberately ignoring any embedded profile. That might cause the darkness problem.
snibgo's IM pages: im.snibgo.com
dschroeder
Posts: 6
Joined: 2013-01-08T04:42:06-07:00
Authentication code: 6789

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

Post by dschroeder »

I have uploaded the source image here. Even if I remove "+profile icm" from the command the result does not change.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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".
snibgo's IM pages: im.snibgo.com
dschroeder
Posts: 6
Joined: 2013-01-08T04:42:06-07:00
Authentication code: 6789

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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?
snibgo's IM pages: im.snibgo.com
dschroeder
Posts: 6
Joined: 2013-01-08T04:42:06-07:00
Authentication code: 6789

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

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

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Last edited by fmw42 on 2013-05-27T17:15:26-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

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

Post 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
Post Reply