Resize/Quantize breaks in certain colorspaces

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
SineSwiper
Posts: 23
Joined: 2011-07-19T04:20:20-07:00
Authentication code: 8675308

Resize/Quantize breaks in certain colorspaces

Post by SineSwiper »

IM (using 6.6.9-7) seems to have some major problems with resizing or any sort of color quantization when using certain colorspaces, especially the Luma-based ones. Here's the code used:

Code: Select all

convert -list colorspace | while read CS; do echo $CS && convert -monitor Lenna.png -depth 32 -colorspace $CS -resize 239x227! label:$CS -gravity Center -append -depth 8 -colorspace RGB $CS.png; done
The effect is some sharp discoloration, using primary colors to fill in certain colors. It's possible that these "certain colors" are outside of the gamut of sRGB, but it shouldn't be replacing them with obvious 255-type colors, and instead find the closest approx. color. In two cases, the colorspace simply tinted the entire image for no reason. (Not just single-channel greyscale colorspaces, but ones that are capable of color pictures.)

The affected colorspaces are: HSB, HWB, Lab (primary color replacements), HSL, YPbPr (tinting). The Lab one is especially problematic because it SHOULD be used for color quantization, but is now crippled with this problem. Here's an example of the problem.

EDIT: YCC seems to also have some gamma problems. It's slightly darker than the rest.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Resize/Quantize breaks in certain colorspaces

Post by anthony »

Resize assumes the image is in some linear colorspace.

PNG will not same in any colorspace other than RGB (actually assumed to be sRGB)

See Resize with Colorspace correction..
http://www.imagemagick.org/Usage/resize ... colorspace


Colorspace handling in IM is going to be worked on of IMv7 mostly to make it understand that most images read in are in a non-linear sRGB colorspace! and make -colorspace sRGB to actually mean that the image IS in sRGB colorspace.

Their are similar issues involving s-grayscale and linear-grayscale.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply