Page 1 of 1

possible bug -colorspace gray 6.8.5.10 beta Q16 Mac OSX

Posted: 2013-06-03T16:32:50-07:00
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

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

Posted: 2013-06-04T04:07:41-07:00
by magick
Try -grayscale rec709luma. Does that fix the problem?

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

Posted: 2013-06-04T09:33:43-07:00
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.

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

Posted: 2013-06-05T14:05:23-07:00
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.

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

Posted: 2013-06-06T06:02:13-07:00
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.

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

Posted: 2013-06-06T10:16:31-07:00
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

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

Posted: 2013-06-06T12:33:59-07:00
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.

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

Posted: 2013-06-06T14:49:53-07:00
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.

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

Posted: 2013-06-16T14:54:33-07:00
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.

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

Posted: 2013-06-26T17:58:12-07:00
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.