{
    "content": [
        {
            "type": "text",
            "text": "# pamditherbw (man)\n\n## NAME\n\npamditherbw - dither grayscale image to black and white\n\n## DESCRIPTION\n\nThis program is part of Netpbm(1).\n\n## TLDR\n\n> Apply dithering to a greyscale image, i.e. turn it into a pattern of black and white pixels that look the same as the original greyscale.\n\n- Read a PGM image, apply dithering and save it to a file:\n  `pamditherbw {{path/to/image.pgm}} > {{path/to/file.pgm}}`\n- Use the specified quantization method:\n  `pamditherbw -{{floyd|fs|atkinson|threshold|hilbert|...}} {{path/to/image.pgm}} > {{path/to/file.pgm}}`\n- Use the atkinson quantization method and the specified seed for a pseudo-random number generator:\n  `pamditherbw {{-a|-atkinson}} {{-r|-randomseed}} {{1337}} {{path/to/image.pgm}} > {{path/to/file.pgm}}`\n- Specify the thresholding value for quantization methods that perform some sort of thresholding:\n  `pamditherbw -{{fs|atkinson|thresholding}} {{-va|-value}} {{0.3}} {{path/to/image.pgm}} > {{path/to/file.pgm}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS** (1 subsections)\n- **DESCRIPTION**\n- **OPTIONS** (7 subsections)\n- **REFERENCES**\n- **SEE ALSO**\n- **HISTORY** (1 subsections)\n- **AUTHOR**\n- **DOCUMENT SOURCE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "pamditherbw",
        "section": "",
        "mode": "man",
        "summary": "pamditherbw - dither grayscale image to black and white",
        "synopsis": "",
        "tldr_summary": "Apply dithering to a greyscale image, i.e. turn it into a pattern of black and white pixels that look the same as the original greyscale.",
        "tldr_examples": [
            {
                "description": "Read a PGM image, apply dithering and save it to a file",
                "command": "pamditherbw {{path/to/image.pgm}} > {{path/to/file.pgm}}"
            },
            {
                "description": "Use the specified quantization method",
                "command": "pamditherbw -{{floyd|fs|atkinson|threshold|hilbert|...}} {{path/to/image.pgm}} > {{path/to/file.pgm}}"
            },
            {
                "description": "Use the atkinson quantization method and the specified seed for a pseudo-random number generator",
                "command": "pamditherbw {{-a|-atkinson}} {{-r|-randomseed}} {{1337}} {{path/to/image.pgm}} > {{path/to/file.pgm}}"
            },
            {
                "description": "Specify the thresholding value for quantization methods that perform some sort of thresholding",
                "command": "pamditherbw -{{fs|atkinson|thresholding}} {{-va|-value}} {{0.3}} {{path/to/image.pgm}} > {{path/to/file.pgm}}"
            }
        ],
        "tldr_source": "official",
        "flags": [
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "Also available are simple thresholding (-threshold); Bayer's ordered dither (-dither8) with a 16x16 matrix; \u001b]8;;http://www.tinrocket.com/projects/programming/graphics/00158/\u001b\\ Atkinson\u001b]8;;\u001b\\ ; and three different sizes of 45-degree clustered-dot dither (-clus‐ ter3, -cluster4, -cluster8). A space filling curve halftoning method using the Hilbert curve is also available (-hilbert). Floyd-Steinberg or Atkinson will almost always give the best looking results; however, look‐ ing good is not always what you want. For instance, you can use thresholding in a pipeline with the pnmconvol, for tasks such as edge and peak detection. And clustered-dot dithering gives a newspaper-ish look, a useful special effect. Floyd-Steinberg is by far the more traditional, but \u001b]8;;http://www.tinrocket.com/projects/programming/graphics/00158/\u001b\\ some claim\u001b]8;;\u001b\\ Atkinson works better. The Hilbert curve method is useful for processing images before display on devices that do not render individual pixels distinctly (like laser printers). This dithering method can give better results than the dithering usually done by the laser printers themselves. The"
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "scaled to fit on a laser printer page (2400 x 3000 pixels for an A4 300 dpi page), and then dithered to a PBM image before being converted to a postscript file. A printing pipeline might look something like: pamscale -xysize 2400 3000 image.pgm | pamditherbw -hilbert | \\ pamtopnm | pnmtops -scale 0.25 > image.ps"
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "thresholding. It should be a real number between 0 and 1. Above 0.5 means darker im‐ ages; below 0.5 means lighter."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "used. This is usually an integer between 2 and 100 (default 5). Smaller clump sizes smear the image less and are less grainy, but seem to lose some grey scale linearity."
            },
            {
                "flag": "",
                "long": null,
                "arg": null,
                "description": "The Floyd-Steiberg and Atkinson methods use random numbers to diffuse the error. This is the seed for the random number generator. The other methods do not employ random numbers and ignore this option. Use this to ensure you get the same image on separate invocations. By default, pamditherbw uses a seed derived from the time of day and process ID, which gives you fairly uncorrelated results in multiple invocations. This option was new in Netpbm 10.45 (December 2008)."
            }
        ],
        "examples": [],
        "see_also": [
            {
                "name": "pamtopnm",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pamtopnm/1/json"
            },
            {
                "name": "pgmtopgm",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pgmtopgm/1/json"
            },
            {
                "name": "pbmtopgm",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pbmtopgm/1/json"
            },
            {
                "name": "pamthreshold",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pamthreshold/1/json"
            },
            {
                "name": "pbmreduce",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pbmreduce/1/json"
            },
            {
                "name": "pnmconvol",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pnmconvol/1/json"
            },
            {
                "name": "scale",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/scale/1/json"
            },
            {
                "name": "pam",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pam/1/json"
            },
            {
                "name": "pnm",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pnm/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "pamditherbw",
                        "lines": 14
                    }
                ]
            },
            {
                "name": "DESCRIPTION",
                "lines": 29,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 4,
                "subsections": [
                    {
                        "name": "Quantization Method",
                        "lines": 1
                    },
                    {
                        "name": "-fs",
                        "lines": 16
                    },
                    {
                        "name": "-clump",
                        "lines": 9
                    },
                    {
                        "name": "Other Options",
                        "lines": 1
                    },
                    {
                        "name": "-value",
                        "lines": 4
                    },
                    {
                        "name": "-clump",
                        "lines": 4
                    },
                    {
                        "name": "-randomseed=_",
                        "lines": 15
                    }
                ]
            },
            {
                "name": "REFERENCES",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "HISTORY",
                "lines": 8,
                "subsections": [
                    {
                        "name": "-atkinson",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "DOCUMENT SOURCE",
                "lines": 6,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "pamditherbw - dither grayscale image to black and white\n\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "",
                "subsections": [
                    {
                        "name": "pamditherbw",
                        "content": "[-floyd | -fs | -atkinson | -threshold | -hilbert | -dither8 | -d8 | -cluster3 | -c3 | -clus‐\nter4 | -c4 | -cluster8 | -c8]\n\n[-value val]\n\n[-clump size]\n\n[-randomseed=integer]\n\n[pamfile]\n\nAll options can be abbreviated to their shortest unique prefix.\n\n"
                    }
                ]
            },
            "DESCRIPTION": {
                "content": "This program is part of Netpbm(1).\n\npamditherbw  dithers  a  grayscale  image.  Dithering means turning each shade of gray into a\npattern of black and white pixels that, from a distance, look the same as the gray.\n\nThe input should be a PGM image or a PAM image of tuple type GRAYSCALE.  However, pamditherbw\ndoesn't check, so if you feed it e.g. a PPM image, it will produce arbitrary  results  (actu‐\nally,  it  just takes the first channel of whatever you give it and treats it as if it repre‐\nsented gray levels).\n\nThe output is a PAM with tuple type BLACKANDWHITE.  You can turn this into a PBM (if you need\nto use it with an older program that doesn't understand PAM) with pamtopnm.\n\nTo do the opposite of dithering, you can usually just scale the image down and then  back  up\nagain  with  pamscale, possibly smoothing or blurring the result with pnmsmooth or pnmconvol.\nOr use the special case program pbmtopgm.\n\nTo dither a color image (to reduce the number of pixel colors), use ppmdither.\n\nAnother way to convert a grayscale image to a black and white image is thresholding.  Thresh‐\nolding is simply replacing each grayscale pixel with a black  or  white  pixel  depending  on\nwhether  its  brightness  is  above or below a threshold.  That threshold might vary.  Simple\nthresholding is a degenerate case of dithering, so pamditherbw does very simple  thresholding\nwith its -threshold option.  But pamthreshold does more sophisticated thresholding.\n\nIf all you want is to change a PGM image with maxval 1 to a PBM image, pamtopnm will do that.\n\n\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "In  addition  to  the options common to all programs based on libnetpbm (most notably -quiet,\nsee \u001b]8;;index.html#commonoptions\u001b\\ Common Options\u001b]8;;\u001b\\ ), pamditherbw recognizes the following command line options:\n\n",
                "subsections": [
                    {
                        "name": "Quantization Method",
                        "content": "The default quantization method is boustrophedonic Floyd-Steinberg error diffusion (-floyd or"
                    },
                    {
                        "name": "-fs",
                        "content": "Also available are simple thresholding (-threshold); Bayer's ordered dither (-dither8) with a\n16x16 matrix; \u001b]8;;http://www.tinrocket.com/projects/programming/graphics/00158/\u001b\\ Atkinson\u001b]8;;\u001b\\ ; and three different sizes of 45-degree clustered-dot dither (-clus‐\nter3, -cluster4, -cluster8).\n\nA space filling curve halftoning method using the Hilbert curve is also available (-hilbert).\n\nFloyd-Steinberg or Atkinson will almost always give the best looking results; however,  look‐\ning  good  is not always what you want.  For instance, you can use thresholding in a pipeline\nwith the pnmconvol, for tasks such as edge and peak detection.  And  clustered-dot  dithering\ngives a newspaper-ish look, a useful special effect.\n\nFloyd-Steinberg is by far the more traditional, but \u001b]8;;http://www.tinrocket.com/projects/programming/graphics/00158/\u001b\\ some claim\u001b]8;;\u001b\\  Atkinson works better.\n\nThe  Hilbert  curve  method is useful for processing images before display on devices that do\nnot render individual pixels distinctly (like laser printers).   This  dithering  method  can\ngive  better  results  than the dithering usually done by the laser printers themselves.  The"
                    },
                    {
                        "name": "-clump",
                        "content": "scaled  to  fit on a laser printer page (2400 x 3000 pixels for an A4 300 dpi page), and then\ndithered to a PBM image before being converted to a postscript  file.   A  printing  pipeline\nmight look something like:\n\npamscale -xysize 2400 3000 image.pgm | pamditherbw -hilbert |  \\\npamtopnm | pnmtops -scale 0.25 > image.ps\n\n\n"
                    },
                    {
                        "name": "Other Options",
                        "content": ""
                    },
                    {
                        "name": "-value",
                        "content": "thresholding.  It should be a real number between 0 and 1.  Above 0.5 means darker im‐\nages; below 0.5 means lighter.\n\n"
                    },
                    {
                        "name": "-clump",
                        "content": "used.   This is usually an integer between 2 and 100 (default 5).  Smaller clump sizes\nsmear the image less and are less grainy, but seem to lose some grey scale linearity.\n\n"
                    },
                    {
                        "name": "-randomseed=_",
                        "content": "The Floyd-Steiberg and Atkinson methods use random numbers to diffuse the error.  This\nis the seed for the random number generator.  The other methods do not  employ  random\nnumbers and ignore this option.\n\nUse this to ensure you get the same image on separate invocations.\n\nBy default, pamditherbw uses a seed derived from the time of day and process ID, which\ngives you fairly uncorrelated results in multiple invocations.\n\nThis option was new in Netpbm 10.45 (December 2008).\n\n\n\n\n"
                    }
                ]
            },
            "REFERENCES": {
                "content": "The  only  reference  you need for this stuff is \"Digital Halftoning\" by Robert Ulichney, MIT\nPress, ISBN 0-262-21009-6.\n\nThe Hilbert curve space filling method is taken from \"Digital Halftoning with  Space  Filling\nCurves\"  by  Luiz  Velho,  Computer Graphics Volume 25, Number 4, proceedings of SIGRAPH '91,\npage 81. ISBN 0-89791-436-8\n\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "pamtopnm(1), pgmtopgm(1),  pbmtopgm(1),  pamthreshold(1),  pbmreduce(1),  pnmconvol(1),  pam‐\nscale(1), pam(1), pnm(1),\n\n",
                "subsections": []
            },
            "HISTORY": {
                "content": "pamditherbw  was new in Netpbm 10.23 (July 2004), but is essentially the same program as pgm‐\ntopbm that has existed practically since the beginning.  pamditherbw differs from its  prede‐\ncessor in that it properly adds brightnesses (using gamma transformations; pgmtopbm just adds\nthem linearly) and that it accepts PAM input in addition to PGM and PBM and produces PAM out‐\nput.\n\npamditherbw obsoletes pgmtopbm.\n",
                "subsections": [
                    {
                        "name": "-atkinson",
                        "content": ""
                    }
                ]
            },
            "AUTHOR": {
                "content": "Copyright (C) 1989 by Jef Poskanzer.\n",
                "subsections": []
            },
            "DOCUMENT SOURCE": {
                "content": "This  manual  page  was  generated by the Netpbm tool 'makeman' from HTML source.  The master\ndocumentation is at\n\nhttp://netpbm.sourceforge.net/doc/pamditherbw.html\n\nnetpbm documentation                         10 May 2010                  Pamditherbw User Manual(1)",
                "subsections": []
            }
        }
    }
}