Page 1 of 1

[RESOLVED]possible bug -colorspace gray -colorspace RGB

Posted: 2013-10-16T14:33:48-07:00
by fmw42
IM 6.8.7.1 beta

I am not sure, but should not these two produce the same results:

-grayscale rec709luminance
and
-colorspace gray -colorspace RGB



# First, check that -colorspace gray, -colorspace rec709luma and -grayscale rec709luma are the same (which they are)

imbh convert rose: -colorspace gray rose_gray1.png
imbh convert rose: -colorspace rec709luma rose_gray2.png
imbh compare -metric rmse rose_gray1.png rose_gray2.png null:
0 (0)

imbh convert rose: -colorspace gray rose_gray1.png
imbh convert rose: -grayscale rec709luma rose_gray3.png
imbh compare -metric rmse rose_gray1.png rose_gray3.png null:
0 (0)


Now test the two commands:

imbh convert rose: -grayscale rec709luminance rose_linear1.png
Image: rose_linear1.png
Geometry: 70x46+0+0
Page geometry: 70x46+0+0
Class: PseudoClass
Colorspace: Gray
Type: Grayscale
Depth: 8/1-bit
Alpha: False
Channels: gray
Rendering intent: Undefined
Gamma: 1
Colors: 200
Gray:
min: 5 (0.0196078)
max: 255 (1)
mean: 49.9761 (0.195985)
standard deviation: 53.9087 (0.211407)




imbh convert rose: -colorspace gray -colorspace RGB rose_linear2.png
Image: rose_linear2.png
Geometry: 70x46+0+0
Page geometry: 70x46+0+0
Class: PseudoClass
Colorspace: Gray
Type: Grayscale
Depth: 8/1-bit
Alpha: False
Channels: gray
Rendering intent: Undefined
Gamma: 1
Colors: 203
Gray:
min: 5 (0.0196078)
max: 255 (1)
mean: 43.3106 (0.169845)
standard deviation: 54.5687 (0.213995)



I would think that these should be the same, but are not quite. The means and std are different.

imbh compare -metric rmse rose_linear2.png rose_linear1.png null:
2886.83 (0.0440501)

Re: possible bug -colorspace gray -colorspace RGB

Posted: 2013-10-16T15:34:56-07:00
by snibgo
"-colorspace gray" is same as "-grayscale Rec709Luma", not "-grayscale Rec709Luminance". I don't know if this behaviour is correct or not.

Re: possible bug -colorspace gray -colorspace RGB

Posted: 2013-10-16T15:59:30-07:00
by fmw42
snibgo wrote:"-colorspace gray" is same as "-grayscale Rec709Luma", not "-grayscale Rec709Luminance". I don't know if this behaviour is correct or not.
You are correct. With -colorspace gray -colorspace RGB, I was trying to generate a linear grayscale image from rec709luma that I thought would be the same as rec709luminance.

Re: possible bug -colorspace gray -colorspace RGB

Posted: 2013-10-17T09:59:35-07:00
by fmw42
From Magick:

1) convert rose: -grayscale rec709luminance rose_linear1.png
2) convert rose: -colorspace gray -colorspace RGB rose_linear2.png
3) compare -metric rmse rose_linear2.png rose_linear1.png null:
2886.83 (0.0440501)


These are correct and expected results.  1) first decompands each sRGB pixel component then computes linear gray as follows:

R=DecodePixelGamma(R');
G=DecodePixelGamma(G');
B=DecodePixelGamma(B');
I=0.212656*R+0.715158*G+0.072186*B


whereas 2) computes the luma gray first then decompands to return linear RGB.  So

G'=0.212656*R'+0.715158*G'+0.072186*B'

R'=G

G'=G

B'=G

R=DecodePixelGamma(R');
G=DecodePixelGamma(G');
B=DecodePixelGamma(B');



The correct equivalence to 1) is:

convert rose: -colorspace RGB -intensity Rec709luminance -colorspace gray rose_linear2.png

compare -metric rmse rose_linear2.png rose_linear1.png null:
0 (0)