"Conversion of RGB to Other Color Spaces" (command-li...html

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Dabrosny
Posts: 111
Joined: 2013-10-02T10:49:39-07:00
Authentication code: 6789
Location: New York, US

"Conversion of RGB to Other Color Spaces" (command-li...html

Post by Dabrosny »

It appears to me that the symbols R, G, and B in the list of formulas in the -colorspace entry of command-line-options.html are being used to represent somewhat different things in different places.

For example, the XYZ and sRGB formulas are correct only if the symbols R,G,B refer to the linear R709,G709,B709 using the rec709 primary-red, primary-blue, and primary-green chromaticities (which I see can be specified in the image and in the miff format). XYZ *can* be defined in terms of other linear RGB colorspaces, but then the coefficients appearing in the formulas would have to be changed from their current rec709 linear coefficients (rec709 happens to be unique in that they defined their nonlinear luma coefficients to equal their linear coefficients).

But on the other hand, for Rec601YCbCr, the Luma Y is defined in terms of the same symbols R,G,B, but the fomulas are only correct if these symbols actually represent the nonlinear R'601, G'601, B'601 (which in turn are defined by the rec601 compression nonlinearity formula applied to linear R601, G601, and B601 which are defined using the rec601 chromaticities).

Do those particular examples implement what I have above, or if not, what do they implement?

Can these formulas be clarified by using distinct names when they refer to different quantities that themselves may be calculated in a different way?
-Dabrosny [Using IM7.0.6 or higher, Q16 HDRI x64 native executable, command line, often invoked from cygwin bash/sh (as of Aug. 2017)]
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: "Conversion of RGB to Other Color Spaces" (command-li...

Post by fmw42 »

Those formulae were added by me simply to explain the mixing ratios. Before that there was no detailed table at all. I do not know enough about the actual details to specify or clarify. You would have to look at the code to find out more. see colorspace.c and enhance.c in the section grayscaleImage.

I actually submitted another topic on the Developers forum at viewtopic.php?f=2&t=24260 to find out if some of the colorspace names were duplicates of the same colorspace or were actually distinct, but I have not yet had a reply.

I am pretty sure that rec709luma is the Y from the non-linear YCbCr and that rec709luminance is the Y from the linear YCbCr.
Post Reply