L in HCL is not Luminance! (my error)

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

L in HCL is not Luminance! (my error)

Post by anthony » 2013-03-27T18:37:16-07:00

Well something is odd...

comparing the outputs of...
convert rose: -colorspace LAB txt: > t1
convert rose: -colorspace HCL txt: > t2


and I can see no channel value in one, matching the channel value in the other.
The first channel in t1 output, should be matching the third channel value in t2 output -- it doesn't
Though it does seem to have some type of correlation.

At least to my understanding of HCL!
See Wikipedia... http://en.wikipedia.org/wiki/CIELUV#Cyl ... esentation


The L channel should left AS-IS, just maped from first to third channel.


Hmmm looks like the conversion has 'gamma' effects in the L of HCL.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: L in HCL is not Luminance!

Post by henrywho » 2013-03-27T21:44:37-07:00

I am using Win32 Q16 static compile:

Code: Select all

Version: ImageMagick 6.8.3-5 2013-02-24 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2013 ImageMagick Studio LLC
Features: DPC OpenMP

Code: Select all

convert.exe rose: -set colorspace srgb -colorspace hcl -channel R -gamma 1 +channel -colorspace lab -channel R -separate -colorspace srgb rose_L_h_g1.png
convert.exe rose: -set colorspace srgb -colorspace hcl -channel G -gamma 1 +channel -colorspace lab -channel R -separate -colorspace srgb rose_L_c_g1.png
convert.exe rose: -set colorspace srgb -colorspace hcl -channel B -gamma 1 +channel -colorspace lab -channel R -separate -colorspace srgb rose_L_l_g1.png
convert.exe rose: -set colorspace srgb                                              -colorspace lab -channel R -separate -colorspace srgb rose_L.png
convert.exe rose: -set colorspace srgb -colorspace hcl -channel R -gamma 2 +channel -colorspace lab -channel R -separate -colorspace srgb rose_L_h_g2.png
convert.exe rose: -set colorspace srgb -colorspace hcl -channel G -gamma 2 +channel -colorspace lab -channel R -separate -colorspace srgb rose_L_c_g2.png
I observed:
1) rose_L.png, rose_L_l_g1.png, rose_L_h_g1.png and rose_L_c_g1.png look almost the same. => This is expected.
2) rose_L_h_g2.png and rose_L_c_g2.png are rather different from rose_L.png. => This is not expected.

User avatar
magick
Site Admin
Posts: 11063
Joined: 2003-05-31T11:32:55-07:00

Re: L in HCL is not Luminance!

Post by magick » 2013-03-28T04:26:40-07:00

HCL in ImageMagick is hue, chroma, and lightness. There are other interpretations where the L corresponds to the L in Lab. You may be looking for the LCH colorspace which uses the L from Lab and chroma and hue. If you think HCL is wrong in ImageMagick, we need references to the correct algorithm to use as a basis for correcting the ConvertRGBToHCL() and ConvertHCLtoRGB() methods in magick/gem.c.

User avatar
fmw42
Posts: 25556
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: L in HCL is not Luminance!

Post by fmw42 » 2013-03-28T11:34:15-07:00

I also thought than HCL was using luma. It would be beneficial to have LCH where L is the same as in LAB (presumably luma). Lightness only considers the min and max (R,G,B) so is less precise than luma.

Just as another note, the following uses the average (R,G,B) for L in their HCL.
http://muscle.ercim.eu/images/DocumentP ... ry_PRL.pdf

This reference use YCH where Y is luma as in YIQ. If we use this, perhaps it would be called HCY to keep the order consistent
http://campusv.uaem.mx/cicos/imagenes/m ... culo21.pdf
Last edited by fmw42 on 2013-03-28T11:45:10-07:00, edited 1 time in total.

User avatar
magick
Site Admin
Posts: 11063
Joined: 2003-05-31T11:32:55-07:00

Re: L in HCL is not Luminance!

Post by magick » 2013-03-28T11:43:27-07:00

ImageMagick already supports the LCH colorspace.

User avatar
fmw42
Posts: 25556
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: L in HCL is not Luminance!

Post by fmw42 » 2013-03-28T11:47:06-07:00

magick wrote:ImageMagick already supports the LCH colorspace.
can it be called from the -define modulate:colorspace=LCH -modulate ...

User avatar
magick
Site Admin
Posts: 11063
Joined: 2003-05-31T11:32:55-07:00

Re: L in HCL is not Luminance!

Post by magick » 2013-03-28T12:58:39-07:00

No. Modulate supports HCL, HSB, HSL, and HWB.

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: L in HCL is not Luminance!

Post by anthony » 2013-04-02T22:44:30-07:00

magick wrote:HCL in ImageMagick is hue, chroma, and lightness. There are other interpretations where the L corresponds to the L in Lab. You may be looking for the LCH colorspace which uses the L from Lab and chroma and hue. If you think HCL is wrong in ImageMagick, we need references to the correct algorithm to use as a basis for correcting the ConvertRGBToHCL() and ConvertHCLtoRGB() methods in magick/gem.c.

HCL is meant to be equivalent to cylic LAB! as in LCHab...

The channels is only ordered in HCL order to make it similar to HSL and HSB, so that -modulate can also use that colorspace without change.

At no time was a LCH colorspace requested as such a cyclic colorspace could not be used with modulate! Though you added it at the same as HCL. I always just assumed they were equivalent with just a re-ordering or color channels. A 'lightness' version was never requested or brought up in that discussion.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

User avatar
magick
Site Admin
Posts: 11063
Joined: 2003-05-31T11:32:55-07:00

Re: L in HCL is not Luminance!

Post by magick » 2013-04-03T05:41:09-07:00

We'll support HCL in perhaps a week or two. Stand by...

henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: L in HCL is not Luminance!

Post by henrywho » 2013-05-09T21:02:01-07:00

magick wrote:We'll support HCL in perhaps a week or two. Stand by...
Is it implemented in 6.8.5.5? :o

User avatar
fmw42
Posts: 25556
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: L in HCL is not Luminance!

Post by fmw42 » 2013-05-09T21:49:04-07:00

henrywho wrote:
magick wrote:We'll support HCL in perhaps a week or two. Stand by...
Is it implemented in 6.8.5.5? :o
HCL in 6.8.5.5 is the same as it was (L=Y). see http://en.wikipedia.org/wiki/HSL_and_HSV

HCLp (L=Y) is new in 6.8.5.5 and is the projected version of HCL. See viewtopic.php?f=2&t=21663&p=88915&hilit=HCL#p88915 It seems to be a better match to HCL in Photoshop.

LCHab and LHuv are available in 6.8.5.5 with L from LAB and LUV, respectively using cylindrical coordinates and I think they are now correct. Anthony can confirm further.

HCLab and HCLuv, do not seem to do anything as far as I can tell in 6.8.5.5

User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: L in HCL is not Luminance! (my error)

Post by anthony » 2013-05-09T23:27:57-07:00

HCLab and HCLuv no longer exist, and probably never really did exist (my bad)

I have not verified that LCHab and LCHuv are correct, and last I looked, Hue was not continuious..

Nope... Hues are still not continuous. and the Hue angles are wrong..
(red is where blue should be, and a green-blue discontinuation along the Hue wrap around point)

LCH is currently equivalent to LCHab (I believe it was supposed to be LCHuv)

There is some type of discontinuation in the darker colors of LCHuv, but I am starting to think it may be because I am directly generating colors in LCHuv colorspace and these fully saturated (chroma) colors don't exist in real life. Looking for better ways of demonstrating the colorspace.

LCHab does not seem to have that effect.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Post Reply