possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

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

possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by fmw42 »

There appears to be a slight difference between -colorspace gray and -grayscale rec601luma in IM 6.8.5.10 beta. The -grayscale result matches older versions of IM. So the odd one is -colorspace gray. You will need to download my images and flicker them to see the differences. Or create your own from the commands below.

In the -colorspace gray example the red hat is slightly darker.

Input:
Image


imb convert redhat.jpg -colorspace gray 1tmp68510.jpg
Image


imb convert redhat.jpg -grayscale rec601luma 2tmp68510.jpg
Image


im68410 convert redhat.jpg -set colorspace RGB -colorspace gray 1tmp68410.jpg
Image


im67410 convert redhat.jpg -set colorspace RGB -colorspace gray 1tmp67410.jpg
Image
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by magick »

Try -grayscale rec709luma. Does that fix the problem?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by fmw42 »

magick wrote:Try -grayscale rec709luma. Does that fix the problem?

The issue is that -colorspace gray in IM 6.8.5.10 does not match -colorspace gray from earlier versions of IM. However, -grayscale rec601luma does match those older versions properly.

What appears to be the case is that -colorspace gray in 6.8.5.10 seems to match -grayscale rec709luma rather than -grayscale rec601luma.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by fmw42 »

Any verification on this issue?

In the released version of IM 6.8.5.10, it still appears that -colorspace gray is using rec709luma mixing rather than rec601luma mixing.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by magick »

Try -intensity Rec609Luma -colorspace gray or -colorspace Rec601Luma. As you have seen, resolving all these various colorspace issues in the last few months has generated a few side-effect issues. What we've found is that the various colorspace methods in the MagickCore API are often utilized such that if we fix one problem, it causes a side-effect elsewhere. Our preference now is to stabilize and encourage the use of command-line parameters to return the results that meet your requirements.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by fmw42 »

Here is a set of tests of all the combinations of comparing -colorspace gray to -grayscale and -intensity.

Image


# create images
convert zelda3.jpg -colorspace gray 2zelda3_cgray.jpg
convert zelda3.jpg -colorspace rec601luma 2zelda3_c601.jpg
convert zelda3.jpg -colorspace rec709luma 2zelda3_c709.jpg
convert zelda3.jpg -grayscale rec601luma 2zelda3_g601.jpg
convert zelda3.jpg -grayscale rec709luma 2zelda3_g709.jpg
convert zelda3.jpg -intensity rec601luma 2zelda3_i601.jpg
convert zelda3.jpg -intensity rec709luma 2zelda3_i709.jpg


# compare images
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_c601.jpg null:
1457 (0.0222324)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_c709.jpg null:
0 (0)

compare -metric rmse 2zelda3_cgray.jpg 2zelda3_g601.jpg null:
8573.72 (0.130827)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_g709.jpg null:
8573.72 (0.130827)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_i601.jpg null:
8573.72 (0.130827)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_i709.jpg null:
8573.72 (0.130827)

The only match is between -colorspace gray and -colorspace rec709luma

It would seem that -colorspace gray does not match well to either -grayscale or -intensity.

Correct me if I am wrong, but should not -colorspace gray match -colorspace rec601luma (not rec709luma) and also match -grayscale rec601luma and -intensity rec601luma.



Furthermore -grayscale and -intensity are generating color images and not grayscale

compare -metric rmse zelda3.jpg 2zelda3_g601.jpg null:
165.8 (0.00252994)

Looks almost like a no-op
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by magick »

-intensity is a setting. -grayscale returns grayscale for me:
  • -> convert logo: -grayscale rec709luma info:
    logo: GIF 640x480 640x480+0+0 8-bit Gray 28.6KB 0.550u 0:00.060
Use -intensity Rec601Luma -colorspace gray to return Rec601Luma.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by fmw42 »

I ran the tests again. I am not sure what went wrong before, but now I do not get color results. Must have been some typo or copy/paste error.

Anyway, there are still problems.

1) -colorspace gray does not match -colorspace rec601luma, but instead matches -colorspace rec709luma

2) -colorspace gray seems to match all the 709 options, but not the rec601luma options, which it should be matching.

From the options page on colorspace at http://www.imagemagick.org/script/comma ... colorspace

Gray
Gray = 0.298839*R+0.586811*G+0.114350*B

Rec601Luma
Gray = 0.298839*R+0.586811*G+0.114350*B

Rec709Luma
Gray=0.21260*R+0.71520*G+0.07220*B

So -colorspace gray should match -colorspace rec601luma and not -colorspace rec709luma

Here are the tests:


convert zelda3.jpg -colorspace gray 2zelda3_cgray.jpg
convert zelda3.jpg -colorspace rec601luma 2zelda3_c601.jpg
convert zelda3.jpg -colorspace rec709luma 2zelda3_c709.jpg
convert zelda3.jpg -grayscale rec601luma 2zelda3_g601.jpg
convert zelda3.jpg -grayscale rec709luma 2zelda3_g709.jpg
convert zelda3.jpg -intensity rec601luma -colorspace gray 2zelda3_i601.jpg
convert zelda3.jpg -intensity rec709luma -colorspace gray 2zelda3_i709.jpg


ccompare -metric rmse 2zelda3_cgray.jpg 2zelda3_c601.jpg null:
1457 (0.0222324)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_c709.jpg null:
0 (0)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_g601.jpg null:
1457 (0.0222324)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_g709.jpg null:
0 (0)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_i601.jpg null:
1457 (0.0222324)
compare -metric rmse 2zelda3_cgray.jpg 2zelda3_i709.jpg null:
0 (0)


Conclusion: -colorspace gray is using the wrong default mixing ratio.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by fmw42 »

For anyone interested, this is not a bug. IM recently changed the default -colorspace gray from rec601luma to rec709luma to conform better to sRGB standards (between IM 6.8.5.4 and 6.8.5.5) . A brief reference can be found at http://en.wikipedia.org/wiki/HSL_and_HSV under lightness.
Last edited by fmw42 on 2013-06-27T20:07:28-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Post by anthony »

While updating IM Examples, Grayscaling Images
http://www.imagemagick.org/Usage/color_mods/#grayscale

I found out the -fx function intensity
1/ does not correspond to either rec709luma or rec601luma
2/ is not effected by -intensity setting.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply