possible bug -contrast-stretch IM 6.7.8.7 Q16

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 -contrast-stretch IM 6.7.8.7 Q16

Post by fmw42 »

IM 6.7.8.7 Q16 Mac OSX Snow Leopard

-contrast-stretch is not behaving as it used to before IM 6.7.7.8. It seems to be converting the image to linear space? Is this the desired behavior? To fix the problem I have to add -set colorspace RGB before -contrast-stretch.

Input:
Image


IM 6.7.8.7
convert monet3.jpg -contrast-stretch 1%,1% monet3_cs_im.jpg
Image

IM 6.7.4.10
im6 convert monet3.jpg -contrast-stretch 1%,1% monet3_cs_im6.jpg
Image

IM 6.7.6.10
imo convert monet3.jpg -contrast-stretch 1%,1% monet3_cs_imo.jpg
Image
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -contrast-stretch IM 6.7.8.7 Q16

Post by magick »

Contrast is behaving properly but differently from previous versions. You can recover the older behavior with
  • convert monet3.jpg -colorspace RGB -contrast-stretch 1%,1% -colorspace sRGB monet3_cs_im.jpg
Contrast stretch analyzes the grayscale histogram of the image. Your image is in the sRGB colorspace, so it first removes the gamma function which as expected returns a different grayscale histogram than previous releases. Previous releases of IM assumed linear RGB so decompanding was not necessary.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -contrast-stretch IM 6.7.8.7 Q16

Post by fmw42 »

magick wrote:Contrast is behaving properly but differently from previous versions. You can recover the older behavior with
  • convert monet3.jpg -colorspace RGB -contrast-stretch 1%,1% -colorspace sRGB monet3_cs_im.jpg
Contrast stretch analyzes the grayscale histogram of the image. Your image is in the sRGB colorspace, so it first removes the gamma function which as expected returns a different grayscale histogram than previous releases. Previous releases of IM assumed linear RGB so decompanding was not necessary.
OK. Thanks.
Post Reply