PAMTHRESHOLD(1)

πŸ“¦
version 11.13.03 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– pamthreshold β€” threshold grayscale image to black and white πŸ’–

okay bestie so this is the Pamthreshold User Manual, page one of the General Commands Manual section, and it's about to change your whole image-editing life, no cap. grab a snack, we're turning gray pixels into black-and-white ones ✨


🌸 NAME 🌸

pamthreshold β€” threshold grayscale image to black and white


πŸŽ€ SYNOPSIS πŸŽ€

pamthreshold [-simple] [-local=widthxheight] [-dual=widthxheight]
[-threshold=threshold] [-contrast=threshold] [inputpamfile]

Quick housekeeping, because abbreviations are iconic:

  • Minimum unique abbreviations of options? Totally acceptable. iykyk.
  • You can use double hyphens instead of a single hyphen to denote options. --simple? valid. slay.
  • You can also use white space in place of the equals sign to separate an option name from its value. so -local 5x5 is giving exactly what -local=5x5 is giving.

πŸ¦‹ DESCRIPTION πŸ¦‹

This program is part of Netpbm(1). πŸ’«

pamthreshold thresholds a grayscale image. And what even is thresholding? It's literally dividing the image into background and foreground by comparing every single pixel to a thresholding value. every one. the whole vibe check, pixel by pixel.

The input should be a PGM image or a PAM image of tuple type GRAYSCALE or GRAYSCALE_ALPHA. BUT β€” and this is the messy part, bestie β€” pamthreshold doesn't check. she just takes the first channel and thresholds it as if it were grayscale samples, and if there's a second channel, she processes it as if it's a transparency (alpha) channel. so if you feed her, like, a PPM image? she'll run. she'll work. but the results are gonna be probably useless. πŸ™ˆ don't do that to her.

The output is a PAM with tuple type BLACKANDWHITE or BLACKANDWHITE_ALPHA, depending on whether the input has a transparency channel. You can turn this into a PBM β€” if you need to use it with an older program that doesn't understand PAM, or you can't afford the 8X amount of space that PAM uses for the image β€” with pamtopnm. πŸ’…

The output is to Standard Output. obviously.

When the input has a transparency channel, pamthreshold includes a transparency channel in the output too, queen behavior. Since the output has maxval 1, that transparency channel can only indicate fully transparent or fully opaque β€” no in-between, it's giving binary. pamthreshold makes it fully transparent where the input is more than half transparent, and fully opaque where it isn't. simple as that.

the transparency function was new in Netpbm 10.43 (June 2008). before that, pamthreshold straight up ignores any transparency channel in the input. not a vibe, but history is history.

Another way to convert a grayscale image to black and white is to dither. Dithering is using clustered black and white pixels such that if you step back and look at the picture, you see varying levels of gray. pamditherbw does dithering. different method, different era. πŸ‘‘


✨ OPTIONS ✨

In addition to the options common to all programs based on libnetpbm β€” most notably -quiet, see Common Options β€” pamthreshold recognizes the following command line options:

Without any options, pamthreshold uses a method based on the iterative algorithm found in the wikipedia article Thresholding (image processing) to compute the thresholding value. (this version of the Wikipedia article was current at the time of this writing.) She uses this threshold to globally threshold the image. This should work well for most images, fr fr. The program issues a message telling you what threshold it used, because she wants you to know. (Netpbm messages go to Standard Error, and you can turn them off with the Netpbm common option -quiet. shhh.)

Options -simple, -local, and -dual select other methods. choose your fighter 🫢

  • -simple β€” This selects simple or global thresholding, i.e. pamthreshold compares every pixel to the threshold you specify with -threshold. Those with a brightness greater than or equal to the threshold become white; the others become black. This works well for black and white text pages scanned with a flatbed scanner, and it's faster than the default method that iteratively determines the thresholding value first. speed + simplicity = iconic combo.
  • -local=widthxheight β€” This selects local adaptive thresholding (also known as dynamic thresholding) using the neighborhood which is the square width pixels wide and height pixels high centered on the pixel in question. pamthreshold computes the threshold individually for each pixel of the image. This can accommodate changing lighting conditions in the image, which is lowkey genius. Depending on the size of the neighborhood this can be quite slow though. bestie. be patient. πŸ•°οΈ
  • -dual=widthxheight β€” This selects a dual thresholding algorithm using a global threshold for low contrast neighborhoods and local thresholding otherwise. This can preserve larger back- respectively foreground areas than local adaptive thresholding. This algorithm was proposed in the paper "An Approach To Licence Plate Recognition" by J.R. Parker and Pavol Federl. academic baddie energy πŸ“š
  • -threshold=threshold β€” This sets the thresholding value for simple or local thresholding. The value is a floating point number in the range [0, 1] directly proportional to the Netpbm sample values, where 0 corresponds to black and 1 to the maxval of the image.

If you don't specify this option, pamthreshold uses a threshold of 0.5.

Without -simple, -local, or -dual, this option is meaningless. it's just sitting there. doing nothing. πŸ’€

The meaning of the threshold depends upon the kind of thresholding you do (as determined by other options). Roughly, pixels at least as bright as the threshold become white in the output while others become black.

  • -contrast=threshold β€” This sets the threshold to determine if a neighborhood has low contrast or not, for dual thresholding. The value is a floating point number in the range [0, 1].

If you don't specify this option, pamthreshold uses a contrast threshold of 0.05. Without -dual this option is meaningless. πŸ™ƒ


🌈 SEE ALSO 🌈

pamditherbw(1), ppmtopgm(1), pamtopnm(1), pam(1)

go read those next, bestie, the lore is deep πŸ“–


🧚 HISTORY 🧚

pamthreshold was new in Netpbm 10.34 (June 2006). a legend was born that day ✨


πŸ‘‘ AUTHOR πŸ‘‘

pamthreshold is Copyright © 2006 by Erik Auerswald and released under the GPL(1). protecting the queen's legacy, as she deserves 🫢


πŸ’œ DOCUMENT SOURCE πŸ’œ

This manual page was generated by the Netpbm tool makeman from HTML source. The master documentation is at

http://netpbm.sourceforge.net/doc/pamthreshold.html

and that's the whole page, babe πŸ’– this was generated as part of the netpbm documentation, dated 06 June 2007, from the Pamthreshold User Manual, section 1 of the General Commands Manual. now go threshold something and make it iconic. periodt. πŸ’…πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from