possible bug gradient: -threshold IM 6.8.5.4 Q16 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.
Locked
User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug gradient: -threshold IM 6.8.5.4 Q16 Mac OSX

Post by fmw42 »

Is this a bug or just a color management issue?


This does not produce and 50-50 black and white image

convert -size 256x256 gradient: -threshold 50% show:


But this does

convert -size 256x256 gradient: -set colorspace RGB -threshold 50% show:

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

Re: possible bug gradient: -threshold IM 6.8.5.4 Q16 Mac OSX

Post by anthony »

I would have expected the first to be correct. threshold in sRGB colorspace.

I would also expect this to produce a 50-50% in linear grayscale colorspace (FAILS)

Code: Select all

convert -size 100x100 gradient:'gray(0)-gray(100%)' -threshold 50% -colorspace sRGB show:
and this... (WORKS)

Code: Select all

convert -size 100x100 gradient:'gray(0)-gray(100%)' -set colorspace RGB -threshold 50% -colorspace sRGB show:
The same goes for this 'sRGB to linear RGB' conversion (WORKS)

Code: Select all

convert -size 100x100 gradient: -set colorspace RGB -threshold 50% -colorspace sRGB show:
Threshold should be on 'values' and not have any colorspace dependencies. It is highly mathematical.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

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

Re: possible bug gradient: -threshold IM 6.8.5.4 Q16 Mac OSX

Post by fmw42 »

Yes, I did all those tests, too. I was surprised by the failures, also. I did not show them as I was trying to keep the test cases as simple as possible.

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

Re: possible bug gradient: -threshold IM 6.8.5.4 Q16 Mac OSX

Post by snibgo »

I would hope the results of the following would be the same:

Code: Select all

"%IM%convert" -size 100x100 gradient: %cs1% -threshold 50%% g1.png
"%IM%convert" -size 100x100 gradient: %cs1% -level 50%%,50%% g2.png
"%IM%convert" -size 100x100 gradient: %cs1% -level-colors gray(50%%),gray(50%%) g3.png
"%IM%convert" -size 100x100 gradient: %cs1% -contrast-stretch 50%%,50%% g4.png

"%IM%convert" xc:Black xc:White -append bwmap.png
"%IM%convert" -size 100x100 gradient: +dither -remap bwmap.png g5.png
For IM v6.8.5-0 in Windows they are visually the same, except for threshold.

Another difference: g4.png has the gamma "1", where all the others have gamma 0.4545.
snibgo's IM pages: im.snibgo.com

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

Re: possible bug gradient: -threshold IM 6.8.5.4 Q16 Mac OSX

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.5-5 Beta available by sometime tomorrow. Thanks.

Locked