documentation question in -threshold IM 6.4.4.-6

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

documentation question in -threshold IM 6.4.4.-6

Post by fmw42 »

The documentation for -threshold at http://www.imagemagick.org/script/comma ... #threshold says:

"If only a single 0 is provided, auto-thresholding will be performed."

Can someone tell me how auto-thresholding works or point me to the specific c code in the IM source code? When I do -threshold 0 all I get is a totally white image.

convert rose: -threshold 0 rose_auto_thresh.png
convert logo: -threshold 0 logo_auto_thresh.png

both result in a totally white image!!!

Also, while looking at the code in threshold.c, I see listed an A d a p t i v e T h r e s h o l d I m a g e, but I do not see any IM option at http://www.imagemagick.org/script/comma ... ptions.php for any such thing. What happened to this?

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

Re: documentation question in -threshold IM 6.4.4.-6

Post by anthony »

The manual is wrong. the command is right. Otherwise it makes it hard to seperate pure black pixels from non-black pixels.
See IM examples, Quantization, for reference to its proper behaviour.
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: documentation question in -threshold IM 6.4.4.-6

Post by fmw42 »

anthony wrote:The manual is wrong. the command is right. Otherwise it makes it hard to seperate pure black pixels from non-black pixels.
See IM examples, Quantization, for reference to its proper behaviour.

OK, I have edited the documentation to remove the inaccurate line.

Also is there any autothresholding function and is there any adaptive thresholding function (there is code for the latter, but no option listed)?

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

Re: documentation question in -threshold IM 6.4.4.-6

Post by anthony »

One 'auto thresholding' method is to reduce the image to two colors without dither.

I look at this in IM examples, quantization, Two color quantization
http://www.imagemagick.org/Usage/quantize/#two_color
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: documentation question in -threshold IM 6.4.4.-6

Post by fmw42 »

anthony wrote:One 'auto thresholding' method is to reduce the image to two colors without dither.

I look at this in IM examples, quantization, Two color quantization
http://www.imagemagick.org/Usage/quantize/#two_color
How does -monochrome handle its thresholding? Does it dither? Either way, your approach with -colors 2 seems to produce a better result.

The reason I am asking about auto thresholding is that I am looking into scripting some various approaches to see how they work.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: documentation question in -threshold IM 6.4.4.-6

Post by anthony »

-monocrome dithers always. It currently ignores the -dther setting.

It works by first grayscaling the image, then doing a two color gray colorspace quantization. See IM examples, Quantization
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply