Luv colorspace showing errors

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

Luv colorspace showing errors

Post by anthony »

The LUV colorspace is in some cases showing errors. basically for very very dark/bright pixels, you can get a negated result.
This is not the case with the very similar LAB colorspace.

For example resizing the earth lights image in LAB produces a good image...

Code: Select all

  convert earth_lights_4800.tif -colorspace Lab     -resize 500    \
          -colorspace sRGB  earth_lights_lab.png
Image

BUT doing this in LUV colorspace results in some VERY bright pixels where none should appear. These pixel should be near black, as it is in the previous example.

Code: Select all

convert earth_lights_4800.tif -colorspace Luv     -resize 500    \
          -colorspace sRGB  earth_lights_luv.png
Image


Compare the images and look at the pixels for Falkland islands in south Atlantic, for Nauru in the West Pacific, along the edge of the artic icecap, and two bright pixels in Russia.

Basically while LUV colorspace seems to be working, there is some error at extreme values.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Luv colorspace showing errors

Post by fmw42 »

try it in HDRI

PM from Magick:
Note, there is still a slight differential when using LUV without HDRI-enabled.  This is due to the scaling / clamping required for LUV, see http://framewave.sourceforge.net/Manual ... 00330.html.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Luv colorspace showing errors

Post by anthony »

I can't see anything in there that can cause a clamping issue. But then the formula is for the to LUV direction
it is more likely to be the reverse that is the problem.

Of course this is actually mapping sRGB -> RGB -> XYZ -> LUV so that is a long chain of conversions to apply.

The reverse from the function list
http://framewave.sourceforge.net/Manual ... rames.html
using the second LUVtoRGB group also appears to be relatively straight forward.
http://framewave.sourceforge.net/Manual ... 0060_00340

Of course clamping is applied before mapping the values back to the final unsigned 16bit integers (last step in the above chain) bout that should not cause a sudden negation of the color.
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: Luv colorspace showing errors

Post by henrywho »

Seems pure LUV roundtrip is okay .... but not if resizing is done under LUV

viewtopic.php?f=3&t=21664
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Luv colorspace showing errors

Post by anthony »

I would expect there and back working. But inverting LUV colors that don't convert well to RGB is not a good solution.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply