{
    "mode": "man",
    "parameter": "pnmnlfilt",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pnmnlfilt/1/json",
    "generated": "2026-08-07T13:08:08Z",
    "synopsis": "pnmnlfilt alpha radius [pnmfile]",
    "sections": {
        "NAME": {
            "content": "pnmnlfilt  -  non-linear filters: smooth, alpha trim mean, optimal estimation smoothing, edge\nenhancement.\n\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pnmnlfilt alpha radius [pnmfile]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This program is part of Netpbm(1).\n\npnmnlfilt produces an output image where the pixels are a summary of multiple pixels near the\ncorresponding location in an input image.\n\nThis program works on multi-image streams.\n\nThis is something of a swiss army knife filter.  It has 3 distinct operating modes.   In  all\nof  the  modes  pnmnlfilt  examines each pixel in the image and processes it according to the\nvalues of it and its surrounding pixels.  Rather than using a  square  block  of  surrounding\npixels  (e.g.  the  subject  pixel and its 8 immediate neighbors, in a 3x3 square), pnmnlfilt\nuses 7 hexagonal areas.  You choose the size of the hexagons with the  radius  parameter.   A\nradius  value  of  1/3  means that the 7 hexagons essentially fit into the subject pixel (ie.\nthere will be no filtering effect).  A radius value of 1.0 means that the 7  hexagons  essen‐\ntially cover the 3x3 immediate neighbor square.\n\nYour choice of \"alpha\" parameter selects among the three modes.\n\n",
            "subsections": [
                {
                    "name": "Alpha trimmed mean filter (0.0 <= alpha <= 0.5)",
                    "content": "The value of the center pixel will be replaced by the mean of the 7 hexagon values, but the 7\nvalues are sorted by size and the top and bottom alpha portion of the 7 are excluded from the\nmean.  This implies that an alpha value of 0.0 gives the same sort of output as a normal con‐\nvolution  (ie.  averaging or smoothing filter), where radius will determine the \"strength\" of\nthe filter. A good value to start from for subtle filtering is alpha = 0.0, radius = 0.55 For\na more blatant effect, try alpha 0.0 and radius 1.0\n\nAn alpha value of 0.5 will cause the median value of the 7 hexagons to be used to replace the\ncenter pixel value. This sort of filter is good for eliminating \"pop\" or single  pixel  noise\nfrom  an  image  without spreading the noise out or smudging features on the image. Judicious\nuse of the radius parameter will fine tune the filtering. Intermediate values of  alpha  give\neffects  somewhere  between  smoothing  and  \"pop\"  noise reduction. For subtle filtering try\nstarting with values of alpha = 0.4, radius = 0.6 For a more blatant effect try alpha =  0.5,\nradius = 1.0\n\n"
                },
                {
                    "name": "Optimal estimation smoothing. (1.0 <= alpha <= 2.0)",
                    "content": "This type of filter applies a smoothing filter adaptively over the image.  For each pixel the\nvariance of the surrounding hexagon values is calculated, and the amount of smoothing is made\ninversely  proportional  to  it.  The idea is that if the variance is small then it is due to\nnoise in the image, while if the variance is large, it is because of \"wanted\" image features.\nAs usual the radius parameter controls the effective radius, but  it  probably  advisable  to\nleave  the radius between 0.8 and 1.0 for the variance calculation to be meaningful.  The al‐\npha parameter sets the noise threshold, over which less smoothing will be done.   This  means\nthat  small  values  of  alpha will give the most subtle filtering effect, while large values\nwill tend to smooth all parts of the image. You could start with values like alpha = 1.2, ra‐\ndius = 1.0 and try increasing or decreasing the alpha parameter to get  the  desired  effect.\nThis  type  of  filter is best for filtering out dithering noise in both bitmap and color im‐\nages.\n\n"
                },
                {
                    "name": "Edge enhancement. (-0.1 >= alpha >= -0.9)",
                    "content": "This is the opposite type of filter to the smoothing filter. It enhances edges. The alpha pa‐\nrameter controls the amount of edge enhancement, from subtle (-0.1) to  blatant  (-0.9).  The\nradius  parameter  controls  the effective radius as usual, but useful values are between 0.5\nand 0.9. Try starting with values of alpha = 0.3, radius = 0.8\n\n"
                },
                {
                    "name": "Combination use.",
                    "content": "The various modes of pnmnlfilt can be used one after the other to get the desired result. For\ninstance to turn a monochrome dithered image into a grayscale image you could try one or  two\npasses  of  the  smoothing  filter, followed by a pass of the optimal estimation filter, then\nsome subtle edge enhancement. Note that using edge enhancement is only likely  to  be  useful\nafter  one  of  the  non-linear filters (alpha trimmed mean or optimal estimation filter), as\nedge enhancement is the direct opposite of smoothing.\n\nFor reducing color quantization noise in images (ie. turning .gif  files  back  into  24  bit\nfiles)  you could try a pass of the optimal estimation filter (alpha 1.2, radius 1.0), a pass\nof the median filter (alpha 0.5, radius 0.55), and possibly a pass of  the  edge  enhancement\nfilter.  Several passes of the optimal estimation filter with declining alpha values are more\neffective than a single pass with a large alpha value.  As usual, there is a tradeoff between\nfiltering effectiveness and losing detail. Experimentation is encouraged.\n\n"
                }
            ]
        },
        "OPTIONS": {
            "content": "There  are  no command line options defined specifically for pnmnlfilt, but it recognizes the\noptions common to all programs based on libnetpbm (See \u001b]8;;index.html#commonoptions\u001b\\ Common Options\u001b]8;;\u001b\\ .)\n\n",
            "subsections": []
        },
        "REFERENCES": {
            "content": "The alpha-trimmed mean filter is based on the description in IEEE CG&A May 1990  Page  23  by\nMark  E.  Lee  and Richard A. Redner, and has been enhanced to allow continuous alpha adjust‐\nment.\n\nThe optimal estimation filter is taken from an article \"Converting Dithered  Images  Back  to\nGray  Scale\"  by Allen Stenger, Dr Dobb's Journal, November 1992, and this article references\n\"Digital Image Enhancement and Noise Filtering by Use of  Local  Statistics\",  Jong-Sen  Lee,\nIEEE Transactions on Pattern Analysis and Machine Intelligence, March 1980.\n\nThe edge enhancement details are from pgmenhance(1), which is taken from Philip R. Thompson's\n\"xim\"  program, which in turn took it from section 6 of \"Digital Halftones by Dot Diffusion\",\nD. E. Knuth, ACM Transaction on Graphics Vol. 6, No. 4, October 1987, which in  turn  got  it\nfrom two 1976 papers by J. F. Jarvis et. al.\n\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "The parameters are:\n\n\n\nalpha  The alpha value (described above), in decimal.  May be fractional.\n\n\nradius The radius (described above), in decimal.  May be fractional.\n\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pgmenhance(1), pnmconvol(1), pnm(1)\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Graeme W. Gill graeme@labtam.oz.au\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/pnmnlfilt.html\n\nnetpbm documentation                       24 October 2006                  Pnmnlfilt User Manual(1)",
            "subsections": []
        }
    },
    "summary": "pnmnlfilt  -  non-linear filters: smooth, alpha trim mean, optimal estimation smoothing, edge enhancement.",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "pgmenhance",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pgmenhance/1/json"
        },
        {
            "name": "pnmconvol",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnmconvol/1/json"
        },
        {
            "name": "pnm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/pnm/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Apply a non-linear filter onto a PNM image.",
        "examples": [
            {
                "description": "Apply the \"alpha trimmed mean\" filter with the specified alpha and radius values onto the PNM image",
                "command": "pnmnlfilt {{0.0..0.5}} {{radius}} {{path/to/image.pnm}} > {{path/to/output.pnm}}"
            },
            {
                "description": "Apply the \"optimal estimation smoothing\" filter with the specified noise threshold and radius onto the PNM image",
                "command": "pnmnlfilt {{1.0..2.0}} {{radius}} {{path/to/image.pnm}} > {{path/to/output.pnm}}"
            },
            {
                "description": "Apply the \"edge enhancement\" filter with the specified alpha and radius onto the PNM image",
                "command": "pnmnlfilt {{0.9..(-0.1)}} {{radius}} {{path/to/image.pnm}} > {{path/to/output.pnm}}"
            }
        ]
    }
}