possible bug -intensity IM 6.8.7.3 Q16 Mac OSX
Posted: 2013-10-25T18:46:09-07:00
I believe there may be a bug when trying to convert a linear gray image to non-linear using -intensity rec709luma -colorspace gray. It does no recognize the input as linear unless -set colorspace RGB is used before -intensity. I would think that having gamma=1 in the input image would be enough for -intensity to know it is linear and do the proper conversion to non-linear.
# create comparison non-linear gray
convert -size 100x100 xc:gray -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: nonlineargray.png
0.494118 0.454545 sRGB Grayscale
# convert non-linear gray to linear gray (works fine)
convert -size 100x100 xc:gray -intensity rec709luminance -colorspace gray -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: lineargray.png
0.208637 1 Gray Grayscale
# attempt to convert linear gray to non-linear (fails)
convert lineargray.png -intensity rec709luma -colorspace gray -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: nonlineargray2.png
0.208637 1 Gray Grayscale
# attempt again convert linear gray to non-linear but add -set colorspace RGB (works)
convert lineargray.png -set colorspace RGB -intensity rec709luma -colorspace gray -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: nonlineargray3.png
0.494118 0.454545 Gray Grayscale
# convert linear gray to non-linear gray using -colorspace sRGB
convert lineargray.png -colorspace sRGB -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: nonlineargray4.png
0.494118 0.454545 sRGB Grayscale
# create comparison non-linear gray
convert -size 100x100 xc:gray -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: nonlineargray.png
0.494118 0.454545 sRGB Grayscale
# convert non-linear gray to linear gray (works fine)
convert -size 100x100 xc:gray -intensity rec709luminance -colorspace gray -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: lineargray.png
0.208637 1 Gray Grayscale
# attempt to convert linear gray to non-linear (fails)
convert lineargray.png -intensity rec709luma -colorspace gray -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: nonlineargray2.png
0.208637 1 Gray Grayscale
# attempt again convert linear gray to non-linear but add -set colorspace RGB (works)
convert lineargray.png -set colorspace RGB -intensity rec709luma -colorspace gray -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: nonlineargray3.png
0.494118 0.454545 Gray Grayscale
# convert linear gray to non-linear gray using -colorspace sRGB
convert lineargray.png -colorspace sRGB -format "%[fx:mean] %[gamma] %[colorspace] %[type]\n" -write info: nonlineargray4.png
0.494118 0.454545 sRGB Grayscale