{
    "mode": "man",
    "parameter": "pnmpsnr",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pnmpsnr/1/json",
    "generated": "2026-06-16T10:11:31Z",
    "synopsis": "pnmpsnr [pnmfile1] [pnmfile2]",
    "sections": {
        "NAME": {
            "content": "pnmpsnr - compute the difference between two portable anymaps\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pnmpsnr [pnmfile1] [pnmfile2]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Reads  two  PBM, PGM, or PPM files, or PAM equivalents, as input.  Prints the peak signal-to-\nnoise ratio (PSNR) difference between the two images.  This metric is typically used in image\ncompression papers to rate the distortion between original and decoded image.\n\nIf  the  inputs are PBM or PGM, pnmpsnr prints the PSNR of the luminance only.  Otherwise, it\nprints the separate PSNRs of the luminance, and chrominance (Cb and  Cr)  components  of  the\ncolors.\n\nThe PSNR of a given component is the ratio of the mean square difference of the component for\nthe two images to the maximum mean square difference that can exist betwee  any  two  images.\nIt is expressed as a decibel value.\n\nThe mean square difference of a component for two images is the mean square difference of the\ncomponent value, comparing each pixel with the pixel in the same position of the other image.\nFor the purposes of this computation, components are normalized to the scale [0..1].\n\nThe maximum mean square difference is identically 1.\n\nSo  the  higher  the  PSNR, the closer the images are.  A luminance PSNR of 20 means the mean\nsquare difference of the luminances of the pixels is 100 times less than the maximum possible\ndifference, i.e. 0.01.\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "pnm(5)\n\n\n\n04 March 2001                                 pnmpsnr(1)",
            "subsections": []
        }
    },
    "summary": "pnmpsnr - compute the difference between two portable anymaps",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "pnm",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/pnm/5/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Compute the difference between two images.",
        "examples": [
            {
                "description": "Compute the difference, i.e. the peak signal-to-noise ratio (PSNR) between two images",
                "command": "pnmpsnr {{path/to/file1.pnm}} {{path/to/file2.pnm}}"
            },
            {
                "description": "Compare the color components rather than the luminance and chrominance components of the images",
                "command": "pnmpsnr {{path/to/file1.pnm}} {{path/to/file2.pnm}} -rgb"
            },
            {
                "description": "Run in comparison mode, i.e. only output `nomatch` or `match` depending on whether the computing PSNR exceeds `n` or not",
                "command": "pnmpsnr {{path/to/file1.pnm}} {{path/to/file2.pnm}} -target {{n}}"
            },
            {
                "description": "Run in comparison mode and compare the individual image components, i.e. Y, Cb, and Cr, to the corresponding thresholds",
                "command": "pnmpsnr {{path/to/file1.pnm}} {{path/to/file2.pnm}} -target1 {{threshold_Y}} -target2 {{threshold_Cb}} -target3 {{threshold_Cr}}"
            },
            {
                "description": "Run in comparison mode and compare the individual image components, i.e. red, green, and blue to the corresponding thresholds",
                "command": "pnmpsnr {{path/to/file1.pnm}} {{path/to/file2.pnm}} -rgb -target1 {{threshold_red}} -target2 {{threshold_green}} -target3 {{threshold_blue}}"
            },
            {
                "description": "Produce machine-readable output",
                "command": "pnmpsnr {{path/to/file1.pnm}} {{path/to/file2.pnm}} -machine"
            }
        ]
    }
}