LinuxCommandLibrary

pamfunc

Test Pluggable Authentication Module (PAM) configuration

TLDR

Apply the specified arithmetic function with n as the second argument to each sample in the specified PAM image

$ pamfunc -[multiplier|divisor|adder|subtractor|min|max] [n] [path/to/input.pam] > [path/to/output.pam]
copy

Apply the specified bit string function with n as the second argument to each sample in the specified PAM image
$ pamfunc -[andmask|ormask|xormask|shiftleft|shiftright] [n] [path/to/input.pam] > [path/to/output.pam]
copy

SYNOPSIS

pamfunc [--function=] [--truecolor] [--verbose] [--maxval=] [--tupletype=] [<input_image_file>]

PARAMETERS

--function=<function_name>
    Specifies the mathematical function to apply to each sample. Examples include: abs, ceil, floor, exp, log, log10, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, sqrt, cbrt, round, trunc.

--truecolor
    Allows the output image to be truecolor, even if the input image is grayscale or black and white. This affects how color components are handled during processing.

--verbose
    Prints informative messages and progress updates to standard error during the command's execution.

--maxval=<maxval>
    Sets the maximum sample value for the output image. By default, the output image will have the same maximum value as the input image.

--tupletype=<tupletype>
    Specifies the tuple type for the output image, such as RGB, GRAYSCALE, etc. This influences the interpretation of the image's pixel data.

DESCRIPTION

pamfunc is a specialized invocation of the pamarith Netpbm program, designed to apply a mathematical function to each individual sample (pixel component) of a Netpbm image. It serves as a powerful utility for performing element-wise transformations on image data. The command reads a single Netpbm image – which can be in PBM, PGM, PPM, or PAM format – from standard input by default, or from a specified file, and then outputs the transformed image to standard output.

The core functionality is driven by the --function option, which allows users to specify a wide array of standard mathematical operations such as absolute value (abs), ceiling (ceil), floor (floor), exponential (exp), logarithm (log), trigonometric functions (sin, cos, tan), inverse trigonometric functions, hyperbolic functions, and roots (sqrt, cbrt). For color images, pamfunc applies the chosen function independently to the red, green, and blue components of each pixel. This enables precise control over image intensity, contrast, and other visual attributes through mathematical modeling. Its integration within the Netpbm suite makes it highly interoperable with other image manipulation tools via piping.

CAVEATS

pamfunc is primarily a symbolic link to pamarith, defaulting to the 'func' operation. Functions are applied independently to each color component for color images. Care must be taken with input values that might lead to undefined or non-finite results for certain mathematical functions (e.g., negative numbers for log or sqrt), as these are often clamped or result in 0 in the output.

INPUT/OUTPUT

By default, pamfunc reads a single Netpbm image from standard input. If an <input_image_file> is specified, it reads from that file instead. The processed image is always written to standard output, making it highly suitable for piping with other Netpbm utilities.

SAMPLE PROCESSING

For color images (PPM or PAM formats), the specified mathematical function is applied separately and independently to each of the red, green, and blue color components of every pixel. For grayscale (PGM) or black and white (PBM) images, the function operates on the single sample value per pixel.

HISTORY

pamfunc is an integral part of the Netpbm project, a venerable suite of command-line tools for manipulating graphics files that originated in the early days of Unix. While the core functionality for arithmetic and functional operations resides within pamarith, pamfunc was created as a convenient symbolic link. This allows users to easily access the single-image mathematical transformation capabilities of pamarith by simply invoking pamfunc, reflecting the long-standing need for element-wise image processing operations in various applications.

SEE ALSO

pamarith(1), netpbm(1), pam(5), pgm(5), ppm(5)

Copied to clipboard