Page 1 of 1

puzzled about luminance - possible bug

Posted: 2008-04-30T16:49:03-07:00
by fmw42
I just checked IM 6.4.1-0 Q16-hdri for channels:
(reference and follow-up to viewtopic.php?f=3&t=10984)

convert -list channel
All
Alpha
Black
Blue
Cyan
Default
Gray
Green
Hue
Index
Lightness
Luminance
Luminosity
Magenta
Matte
Opacity
Red
Saturation
Yellow

1) I see lightness, luminance and luminosity. I was under the impression that in -fx luminosity was replaced by lightness. Is there a difference here between these 3 channels? or at least between lightness and luminosity?

2) I tried to make a comparison as follows just for luminance:

convert rose: -channel luminance -fx "u" rose_channel_fx_luminance.png
convert rose: -fx "luminance" rose_fx_luminance.png
compare -metric rmse rose_channel_fx_luminance.png rose_fx_luminance.png null:
36451.2 (0.55621)

Should they be the same or am I misunderstanding how to do this.

3) Is there a colorspace equivalent to either of the above, e.g.

convert rose: -colorspace ??? -channel luminance -separate rose_luminance.png

and would this colorspace be Rec601Luma or Rec709Luma

4) or should either

convert rose: -colorspace Rec601Luma rose_luma601.png
or
convert rose: -colorspace Rec709Luma rose_luma601.png

match one of the following:

convert rose: -channel luminance -fx "u" rose_channel_fx_luminance.png
or
convert rose: -fx "luminance" rose_fx_luminance.png

This is low priority, but a clarification when convenient would be appreciated.

Thanks

Fred

Re: puzzled about luminance

Posted: 2008-04-30T17:05:30-07:00
by magick
Luminosity is deprecated. Luminance and lightness are aliases to the blue channel. For proper lightness you need to read the original image in the HSL colorspace or explicitly convert to the HSL colorspace. However, the -fx lightness operator does the colorspace conversion automatically with the ConvertRGBToHSL() method.

Re: puzzled about luminance

Posted: 2008-04-30T18:08:43-07:00
by fmw42
Thanks. But I am still puzzled by luminance.

1) It is the blue channel of what colorspace?
2) And does it have any relationship to Rec601Luma or Rec709Luma?

Your earlier note:
luma=Rec709LumaColorspace (e.g. 0.2126*red + 0.7152*green + 0.0722*blue).
and
-fx luminance (new) becomes 0.2126*red + 0.7152*green + 0.0722*blue
would seem to imply they are the same, but I am confused. Is rec709Luma a single channel colorspace or a 3 channel colorspace?

Would this imply:

convert rose: -colorspace rec709Luma -channel blue rose_lumnance.png

If so, then what is -channel luminance mean and how is it used?

3) And does -fx do the colorspace conversion as well for luminance (like for lightness)?

Sorry, this is very confusing to me.

Re: puzzled about luminance

Posted: 2008-04-30T18:51:54-07:00
by magick
ImageMagick supports up to 5 channels of color information and are labeled based on the colorspace:
  • channel 1: one of Red, Cyan, Hue, Grayscale, etc.
    2: Green, Magenta, Saturation, Grayscale, etc.
    3: Blue, Yellow, Lightness, Grayscale, etc.
    4: Alpha
    5: Index, Black
When you convert from RGB to Rec709Luma, the red, green, and blue channels are replaced with this value:
  • 0.2126*red + 0.7152*green + 0.0722*blue
The FX option assumes RGB and returns the following for luminence:
  • QuantumScale*0.2126*pixel.red+0.7152*pixel.green+0.0722*pixel.blue;
and L from HSL is returned for lightness.

Re: puzzled about luminance - possible bug

Posted: 2008-04-30T19:47:48-07:00
by fmw42
Sorry to keep pressing the issue, but by your statements, I would think that the following would create the same results:

convert rose: -colorspace Rec709Luma rose_Rec709Luma.png
convert rose: -fx "luminance" rose_fx_luminance.png

But they do not:

compare -metric rmse rose_Rec709Luma.png rose_fx_luminance.png null:
35967.2 (0.548825)

If I get verbose info:

convert rose_Rec709Luma.png -verbose info:
...
Colorspace: Gray
Depth: 16-bit
Channel depth:
gray: 16-bit
Channel statistics:
gray:
min: 9488 (0.144778)
max: 65535 (1)
mean: 25861.2 (0.394616)
standard deviation: 12281.8 (0.187408)

which looks reasonable, but

convert rose_fx_luminance.png -verbose info:
...
Type: Bilevel
Endianess: Undefined
Colorspace: Gray
Depth: 16/1-bit
Channel depth:
gray: 1-bit
Channel statistics:
gray:
min: 1 (1)
max: 1 (1)
mean: 1 (1)
standard deviation: -0 (-0)


does not appear reasonable as the resulting image has a constant value of 1!

Is this a bug? Am I doing something wrong with my convert statements? Have I misunderstood? Or is this due the my being on (IM 6.4.1-0) Q16-HDRI

Note: if I do the same with lightness:

convert rose: -fx "lightness" rose_fx_lightness.png
convert rose_fx_lightness.png -verbose info:
...
Colorspace: Gray
Depth: 16-bit
Channel depth:
gray: 16-bit
Channel statistics:
gray:
min: 9509 (0.145098)
max: 65535 (1)
mean: 29310.8 (0.447254)
standard deviation: 13019.8 (0.198669)

or if I do the same with intensity:

convert rose: -fx "intensity" rose_fx_intensity.png

convert rose_fx_intensity.png -verbose info:
...
Colorspace: Gray
Depth: 16-bit
Channel depth:
gray: 16-bit
Channel statistics:
gray:
min: 9578 (0.146151)
max: 65535 (1)
mean: 27020.2 (0.412302)
standard deviation: 12177.1 (0.18581)


I do not get the constant value of 1 like I do with luminance, above. So I am thinking that the -fx "luminance" result is a bug.

Thanks.

Fred

P.S. What then is the significance/use of -channel luminance? How is that used and how is it different from the above two approaches?

Re: puzzled about luminance - possible bug

Posted: 2008-05-01T10:09:30-07:00
by magick
We fixed an associative multiply problem when computing luminence for the -fx option in ImageMagick 6.4.1-1 Beta available sometime tomorrow.