possible bug LCH colorspace IM 6.8.4.6 Mac OSX

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
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug LCH colorspace IM 6.8.4.6 Mac OSX

Post by fmw42 »

I have been testing the following commands to compare LCH and HCL colorspaces. The following are simple round trips. It works fine for HCL but not for LCH.

This works fine for HCL

hue=1
chr=1
lum=1
convert rose: -set colorspace RGB -colorspace HCL -separate +channel \
\( -clone 0 -evaluate multiply $hue \) \
\( -clone 1 -evaluate multiply $chr \) \
\( -clone 2 -evaluate multiply $lum \) \
-delete 0-2 -set colorspace HCL -combine -colorspace RGB -set colorspace sRGB \
test_hcl_${hue}_${sat}_${lum}.png

Image


This is not correct for LCH

lum=1
chr=1
hue=1
convert rose: -set colorspace RGB -colorspace LCH -separate +channel \
\( -clone 0 -evaluate multiply $lum \) \
\( -clone 1 -evaluate multiply $chr \) \
\( -clone 2 -evaluate multiply $hue \) \
-delete 0-2 -set colorspace LCH -combine -colorspace RGB -set colorspace sRGB \
test_lch_${hue}_${sat}_${lum}.png

Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: possible bug LCH colorspace IM 6.8.4.6 Mac OSX

Post by snibgo »

Colorspaces that fail a simple round-trip test in v6.8.4-6 are: LCH, LMS, YCC, YIQ, YUV. Of these, YIQ and YUV aren't much worse than 1% off.

My simple test is ...

Code: Select all

convert hald:8 src.png
convert src.png -colorspace XXXX -colorspace sRGB result.png
compare -metric RMSE src.png result.png NULL:
... and I regard an RMSE > 0.01 (ie 1%) as a failure.
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug LCH colorspace IM 6.8.4.6 Mac OSX

Post by anthony »

I would just get rid of LCH colorspace -- it is just causing confusion.

HCL is meant to be equivalent to LCHab, but with a channel order equivalent to HSL and HSB so modulate can use it.


however I agree the above test in the original post from Fred should work as a round trip, but does not seem to.

of course in IMv7 the destination colorspace is an argument to -combine (as it should have been in the first place).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug LCH colorspace IM 6.8.4.6 Mac OSX

Post by magick »

We'll support HCL in perhaps a week or two. Stand by...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug LCH colorspace IM 6.8.4.6 Mac OSX

Post by fmw42 »

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

My interest in LCH is that the L be luma (such as in LAB or Y from YUV,etc) and not lightness. But if it still needs work, then perhaps you would also make it work with -modulate. You might also consider having the channel orders be HCY so that they now are consistent with HCL, HSL and HSB. But I can deal with it in either order.

Some references (though I am not sure how relevant):
http://chilliant.blogspot.com/2012/08/r ... -hlsl.html
http://api.kde.org/4.0-api/kdelibs-apid ... ource.html
http://statmath.wu-wien.ac.at/~zeileis/ ... l-2009.pdf
http://mmir.doc.ic.ac.uk/mmir2005/Camer ... ssaoui.pdf
http://en.wikipedia.org/wiki/CIELUV_color_space (see LCHuv)
http://cscheid.net/blog/hcl_color_space_blues
http://cran.r-project.org/web/packages/ ... (software)

The some of the reference says that HCL is obtained by simply transforming the UV coordinates of Luv to polar coordinates.

(There is also another colorspace that is LAB with ab convert to polar coordinates)


Some of these references indicate that LCH (HCY) may produce values out of gamut. If so then its utility may be limited?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug LCH colorspace IM 6.8.4.6 Mac OSX

Post by anthony »

Perhaps we need

HCL (cylindrical Lab)
HCLuv (cylindrical Luv)
HCY (cylindrical Yuv)

But Only the first is of interest to me. I just always assumed the L in HCL and Lab were equivalent as that is what was requested originally.

See, my discussion of the colorspace
http://www.imagemagick.org/Usage/color_ ... rwheel_HCL
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply