{
    "content": [
        {
            "type": "text",
            "text": "# pnmcolormap (man)\n\n## NAME\n\npnmcolormap - create quantization color map for a portable anymap\n\n## SYNOPSIS\n\npnmcolormap   [-center|-meancolor|-meanpixel]  [-spreadbrightness|-spreadluminosity]  [-sort]\n[-square] ncolors|all [pnmfile]\nAll options can be abbreviated to their shortest unique prefix.  You may use two hyphens  in‐\nstead  of  one  to designate an option.  You may use either white space or an equals sign be‐\ntween an option name and its value.\n\n## DESCRIPTION\n\nReads a PNM image as input.  Chooses ncolors colors to best represent the image, maps the ex‐\nisting colors to the new ones, and writes a PNM color map defining them as output.\n\n## TLDR\n\n> Create quantization color map for a PNM image.\n\n- Generate an image using only `n_colors` or less colors as close as possible to the input image:\n  `pnmcolormap {{n_colors}} {{path/to/input.pnm}} > {{path/to/output.ppm}}`\n- Use the splitspread strategy for determining the output colors, possibly producing a better result for images with small details:\n  `pnmcolormap {{-splits|-splitspread}} {{n_colors}} {{path/to/input.pnm}} > {{path/to/output.ppm}}`\n- Sort the resulting colormap, which is useful for comparing colormaps:\n  `pnmcolormap {{-so|-sort}} {{path/to/input.pnm}} > {{path/to/output.ppm}}`\n\n*Source: tldr-pages*\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **PARAMETERS** (8 subsections)\n- **QUANTIZATION METHOD** (2 subsections)\n- **REFERENCES**\n- **SEE ALSO**\n- **AUTHOR**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "pnmcolormap",
        "section": "",
        "mode": "man",
        "summary": "pnmcolormap - create quantization color map for a portable anymap",
        "synopsis": "pnmcolormap   [-center|-meancolor|-meanpixel]  [-spreadbrightness|-spreadluminosity]  [-sort]\n[-square] ncolors|all [pnmfile]\nAll options can be abbreviated to their shortest unique prefix.  You may use two hyphens  in‐\nstead  of  one  to designate an option.  You may use either white space or an equals sign be‐\ntween an option name and its value.",
        "tldr_summary": "Create quantization color map for a PNM image.",
        "tldr_examples": [
            {
                "description": "Generate an image using only `n_colors` or less colors as close as possible to the input image",
                "command": "pnmcolormap {{n_colors}} {{path/to/input.pnm}} > {{path/to/output.ppm}}"
            },
            {
                "description": "Use the splitspread strategy for determining the output colors, possibly producing a better result for images with small details",
                "command": "pnmcolormap {{-splits|-splitspread}} {{n_colors}} {{path/to/input.pnm}} > {{path/to/output.ppm}}"
            },
            {
                "description": "Sort the resulting colormap, which is useful for comparing colormaps",
                "command": "pnmcolormap {{-so|-sort}} {{path/to/input.pnm}} > {{path/to/output.ppm}}"
            }
        ],
        "tldr_source": "official",
        "flags": [],
        "examples": [],
        "see_also": [
            {
                "name": "pnmremap",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pnmremap/1/json"
            },
            {
                "name": "pnmquant",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pnmquant/1/json"
            },
            {
                "name": "ppmquantall",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ppmquantall/1/json"
            },
            {
                "name": "pnmdepth",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/pnmdepth/1/json"
            },
            {
                "name": "ppmdither",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ppmdither/1/json"
            },
            {
                "name": "ppmquant",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/ppmquant/1/json"
            },
            {
                "name": "ppm",
                "section": "5",
                "url": "https://www.chedong.com/phpMan.php/man/ppm/5/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 22,
                "subsections": []
            },
            {
                "name": "PARAMETERS",
                "lines": 7,
                "subsections": [
                    {
                        "name": "-sort",
                        "lines": 4
                    },
                    {
                        "name": "-square",
                        "lines": 6
                    },
                    {
                        "name": "-verbose",
                        "lines": 3
                    },
                    {
                        "name": "-center",
                        "lines": 1
                    },
                    {
                        "name": "-meancolor",
                        "lines": 1
                    },
                    {
                        "name": "-meanpixel",
                        "lines": 1
                    },
                    {
                        "name": "-spreadbrightness",
                        "lines": 1
                    },
                    {
                        "name": "-spreadluminosity",
                        "lines": 4
                    }
                ]
            },
            {
                "name": "QUANTIZATION METHOD",
                "lines": 14,
                "subsections": [
                    {
                        "name": "-spreadbrightness",
                        "lines": 9
                    },
                    {
                        "name": "-center",
                        "lines": 1
                    }
                ]
            },
            {
                "name": "REFERENCES",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "pnmcolormap - create quantization color map for a portable anymap\n\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "pnmcolormap   [-center|-meancolor|-meanpixel]  [-spreadbrightness|-spreadluminosity]  [-sort]\n[-square] ncolors|all [pnmfile]\n\nAll options can be abbreviated to their shortest unique prefix.  You may use two hyphens  in‐\nstead  of  one  to designate an option.  You may use either white space or an equals sign be‐\ntween an option name and its value.\n\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Reads a PNM image as input.  Chooses ncolors colors to best represent the image, maps the ex‐\nisting colors to the new ones, and writes a PNM color map defining them as output.\n\nYou  can  use this map as input to pnmremap on the same input image to quantize the colors in\nthat image, I.e.  produce a similar image with fewer colors.  pnmquant does both the  pnmcol‐‐\normap and pnmremap steps for you.\n\nA  PNM  colormap  is  a  PNM image of any dimensions that contains at least one pixel of each\ncolor in the set of colors it represents.\n\nThe quantization method is Heckbert's \"median cut\".  See the section QUANTIZATION METHOD.\n\nIf the input image is a PPM, the output image is a PPM.  If the input image is a PBM or  PGM,\nthe output colormap is a PGM.  Note that a colormap of a PBM image is not very interesting.\n\nThe  colormap generally has the same maxval as the input image, but pnmcolormap may reduce it\nif there are too many colors in the input, as part of its quantization algorithm.\n\nIf you want to create a colormap without basing it on the colors in an input image, see  ppm‐‐\ncolors.\n\n",
                "subsections": []
            },
            "PARAMETERS": {
                "content": "The  single parameter, which is required, is the number of colors you want in the output col‐\normap.  pnmcolormap may produce a color map with slightly fewer colors than  that.   You  may\nspecify all to get a colormap of every color in the input image (no quantization).\n\n\nOPTIONS\n",
                "subsections": [
                    {
                        "name": "-sort",
                        "content": "then the green, then the blue in ascending order.  This is an insertion sort, so it is\nnot  very fast on large colormaps.  Sorting is useful because it allows you to compare\ntwo sets of colors.\n"
                    },
                    {
                        "name": "-square",
                        "content": "By default, pnmcolormap produces as the color map a PPM image with  one  row  and  one\ncolumn for each color in the colormap.  This option causes pnmcolormap instead to pro‐\nduce a PPM image that is within one row or column of being square, with multiple  pix‐\nels  of  the  same  color as necessary to create a number of pixels which is a perfect\nsquare.\n"
                    },
                    {
                        "name": "-verbose",
                        "content": "This option causes pnmcolormap to display messages to Standard Error about the quanti‐\nzation.\n"
                    },
                    {
                        "name": "-center",
                        "content": ""
                    },
                    {
                        "name": "-meancolor",
                        "content": ""
                    },
                    {
                        "name": "-meanpixel",
                        "content": ""
                    },
                    {
                        "name": "-spreadbrightness",
                        "content": ""
                    },
                    {
                        "name": "-spreadluminosity",
                        "content": "These options control the quantization algorithm.  See QUANTIZATION METHOD below.\n\n\n"
                    }
                ]
            },
            "QUANTIZATION METHOD": {
                "content": "A  quantization method is a way to choose which colors, being fewer in number than in the in‐\nput, you want in the output.  pnmcolormap uses Heckbert's \"median cut\" quantization method.\n\nThis method involves separating all the colors into \"boxes,\" each holding colors that  repre‐\nsent  about  the  same number of pixels.  You start with one box and split boxes in two until\nthe number of boxes is the same as the number of colors you want in the  output,  and  choose\none color to represent each box.\n\nWhen  you split a box, you do it so that all the colors in one sub-box are \"greater\" than all\nthe colors in the other.  \"Greater,\" for a particular box, means it is brighter in the  color\ncomponent (red, green, blue) which has the largest spread in that box.  pnmcolormap gives you\ntwo ways to define \"largest spread.\":  1) largest spread of brightness; 2) largest spread  of\ncontribution  to the luminosity of the color.  E.g. red is weighted much more than blue.  Se‐\nlect among these with the -spreadbrightness and -spreadluminosity options.   The  default  is",
                "subsections": [
                    {
                        "name": "-spreadbrightness",
                        "content": "pnmcut  provides three ways of choosing a color to represent a box: 1) the center color - the\ncolor halfway between the greatest and least colors in the box, using the above definition of\n\"greater\";  2)  the  mean of the colors (each component averaged separately by brightness) in\nthe box; 3) the mean weighted by the number of pixels of a color in the image.\n\nNote that in all three methods, there may be colors in the output which do not appear in  the\ninput at all.\n\nSelect  among  these  with  the  -center, -meancolor, and -meanpixel options.  The default is"
                    },
                    {
                        "name": "-center",
                        "content": ""
                    }
                ]
            },
            "REFERENCES": {
                "content": "\"Color Image Quantization for Frame Buffer Display\" by Paul Heckbert, SIGGRAPH  '82  Proceed‐\nings, page 297.\n\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "pnmremap(1), pnmquant(1), ppmquantall(1), pnmdepth(1), ppmdither(1), ppmquant(1), ppm(5)\n\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Copyright (C) 1989, 1991 by Jef Poskanzer.  Copyright (C) 2001 by Bryan Henderson.\n\n\n\n12 December 2001                            pnmcolormap(1)",
                "subsections": []
            }
        }
    }
}