pbmclean
Remove dead columns from Portable Bitmap images
TLDR
Clean up a PBM image by erasing isolated black and white pixels
Clean up only black/white pixels
Specify the minimum number of neighbouring pixels of the same color in order for a pixel not to be considered isolated
SYNOPSIS
pbmclean [-1] [-2] [-all] [-white] [-black] [-keepblack] [-keepwhite] [-verbose]
PARAMETERS
-1
Cleans pixels connected to at most one other pixel.
-2
(Default) Cleans pixels connected to at most two other pixels.
-all
Removes all pixels not connected to the border of the image.
-white
(Default) Changes isolated black pixels to white.
-black
Changes isolated white pixels to black.
-keepblack
Removes isolated white pixels while keeping isolated black pixels.
-keepwhite
Removes isolated black pixels while keeping isolated white pixels.
-verbose
Prints processing information to standard error.
DESCRIPTION
pbmclean is a utility from the Netpbm package designed to clean up Portable BitMap (PBM) images by removing isolated pixels or small groups of pixels. It reads a PBM image from standard input and writes the cleaned image to standard output. This command is particularly useful for reducing "noise" or artifacts in scanned or converted monochrome images. It identifies pixels based on their connectivity to neighboring pixels. By default, it removes black pixels that are isolated or only connected to one other pixel. Users can specify different connectivity rules, choose to remove isolated white pixels instead, or even preserve certain types of isolated pixels. Its primary function is to enhance the visual clarity of monochrome images by smoothing out unwanted single-pixel disruptions.
CAVEATS
pbmclean operates exclusively on PBM (Portable BitMap) format. While it's part of the Netpbm suite which handles other formats (PGM, PPM), pbmclean is specific to 1-bit monochrome images.
The definition of "isolated" depends on the chosen connectivity (-1, -2) and whether a pixel is connected to the image border (-all). Misunderstanding these options can lead to unexpected image modifications.
It processes input from stdin and writes to stdout, requiring redirection for file operations.
I/O HANDLING
pbmclean reads its input PBM image from standard input and writes the processed PBM image to standard output. This allows it to be easily integrated into shell pipelines, for example: cat image.pbm | pbmclean > cleaned_image.pbm
or scanimage --format=pbm | pbmclean -all > borderless.pbm
.
HISTORY
pbmclean is a component of the Netpbm graphics suite, which originated from Jef Poskanzer's Pbmplus utilities. The Netpbm project has been continuously developed since the early 1990s, providing a robust and flexible set of command-line tools for manipulating various image formats, particularly the portable pixmap formats (PBM, PGM, PPM). pbmclean itself is an older, established tool within this suite, serving its specific purpose of image noise reduction for monochrome bitmaps. Its design reflects the Unix philosophy of small, specialized tools that do one thing well.