Page 1 of 1

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

Posted: 2009-03-24T17:54:46-07:00
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?

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

Posted: 2009-03-25T16:49:14-07:00
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!

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

Posted: 2009-03-25T17:09:45-07:00
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!

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

Posted: 2009-04-21T17:36:13-07:00
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%.

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

Posted: 2009-04-22T00:46:41-07:00
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.