pamrecolor - alter colors without affecting luminance
pamrecolor [--colorspace=name] [--rmult=fraction] [--gmult=fraction] [--bmult=fraction] [--targetcolor=color] [--colorfile=file] [-randomseed=integer]
[infile]
Minimum unique abbreviation of option is acceptable. You may use double hyphens instead of single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value.
This program is part of Netpbm(1).
pamrecolor changes an image's colors to be as close as possible to given target colors but with the constraint that the luminance not be modified. That is, the original image and the target image will look identical if both are converted to grayscale (e.g. with ppmtopgm(1)). You can have pamrecolor select target colors randomly, specify a single hue for the entire image, or take the target colors from a target image.
pamrecolor works on pseudo-Netpbm images based on arbitrary color spaces. You can define the color space explicitly or choose one of many that pamrecolor knows by name.
The output is a PAM image on standard output. Options control the exact format of the PAM. If you want a PNM (PBM, PGM, or PPM) image, use pamtopnm(1) on the output. There is no need to convert if you will use the image as input to a current Netpbm program, but many other programs don't know what a PAM is.
In addition to the options common to all programs based on libnetpbm
(most notably -quiet, see
Common Options
), pamrecolor recognizes the following
command line options:
When you use this option, the input and output images are not true Netpbm images, because the Netpbm image format specifies a particular color space. Instead, you are using a variation on the format in which the sample values in the raster have different meaning. Many programs that ostensibly use Netpbm images actually use a variation with a different color space. For example, GIMP uses sRGB internally and if you have GIMP generate a Netpbm image file, it really generates a variation of the format that uses sRGB.
pamrecolor knows the following color spaces (name values):
The default is "ntsc" because this is the color space that the Netpbm formats and many graphics utilities use. As a counterexample, GIMP uses sRGB as its native color space.
The luminance values pamrecolor uses for each of the above come from Bruce Lindbloom's Computing RGB-to-XYZ and XYZ-to-RGB matrices" (1) page.
If you specify neither --targetcolor nor --colorfile, pamrecolor will randomly select a target color for each pixel of the input image.
You may not specify both -targetcolor and -colorfile.
If you specify neither --targetcolor nor --colorfile, pamrecolor will randomly select a target color for each pixel of the input image.
You may not specify both -targetcolor and -colorfile.
Use this to ensure you get the same image on separate invocations.
By default, pamrecolor 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.61 (December 2012).
This command tints an image yellow:
pamrecolor --targetcolor=yellow colorpic.pam > yellowpic.pam
This command takes the colors from colorpicture.ppm and applies them to graypicture.pgm:
pamrecolor --colorfile=colorpic.ppm graypic.pgm > colorizedpic.pam
The grayscale version of colorizedpic.pam will look just like graypic.pgm. Note that if you use a non-Netpbm tool to do the conversion to grayscale, you may additionally need to specify an appropriate --colorspace value for your conversion tool.
Here are a couple of fun special effects you can produce with pamrecolor:
Scott Pakin wrote pamrecolor in July 2010.
pamrecolor was new in Netpbm 10.52 (September 2010).
Copyright (C) 2010 Scott Pakin, scott+pbm@pakin.org.