possible bug -black-threshold & -white-threshold IM 6.5.0-6

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 -black-threshold & -white-threshold IM 6.5.0-6

Post by fmw42 »

IM 6.5.0-6 Q16 Mac OSX Tiger

The docs at http://www.imagemagick.org/script/comma ... #threshold imply that -threshold is channel sensitive.

However, -black-threshold and -white-threshold don't say one way or the other.

The following does not seem to work right to me if they are channel sensitive.

convert -size 256x256 gradient:red-black gradr.png
Image

convert gradr.png -channel red -black-threshold 25% +channel gradr_bt25.png
Image

convert gradr.png -channel red -white-threshold 75% +channel gradr_wt75.png
Image

Should this work or not? Or am I misinterpreting something or making an error?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug -black-threshold & -white-threshold IM 6.5.0-6

Post by anthony »

They should be channel sensitive, but as only the red channel is in use (all other channels have 0 values) it should not matter for this image.

However does not look like the black-threshold is correct. The threshold point should be in the same place in BOTH images, but containing the unmodified gradient below that point in one and above that point in the other.

I really should document these with examples in IM examples. Probably by adding a second 'threhold' discussion in Colors, directly after 'negate', with a different enphesis to its discussion in Quantization as a very primative color reduction/dither operator. Maybe one day!
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: possible bug -black-threshold & -white-threshold IM 6.5.0-6

Post by fmw42 »

anthony wrote:They should be channel sensitive, but as only the red channel is in use (all other channels have 0 values) it should not matter for this image.

However does not look like the black-threshold is correct. The threshold point should be in the same place in BOTH images, but containing the unmodified gradient below that point in one and above that point in the other.

Black threshold was 25% and white threshold was 75%. Why should they be at the same place?

The black threshold should be at 25%, but appears more like 75%. It should really be black up to a quarter from the bottom and red gradient from there to top.

The white threshold is wrong also as compare shows it to be identical to the original gradr.png

So both black-threshold and white-threshold seem bogus!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -black-threshold & -white-threshold IM 6.5.0-6

Post by magick »

Given a channel of red and a threshold of 25%, black thresholding compares the grayscale value of each pixel to the threshold and if its less it sets the red channel of the pixel to 0. If you want to just threshold the red channel you need to specify the threshold like this: 25%,0%,0%.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug -black-threshold & -white-threshold IM 6.5.0-6

Post by anthony »

That sounds very odd behaviour.

A gray threshold for just the red channel!

I would expect gray to be used for the default (all channels, including the 'default channel flag') Forcing the result to be black and white for color images.

But if the user specified channels (no default channel flag is present) then individual channels will be used for BOTH the test and the action.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply