Panda3D
|
The name of this class derives from the fact that we originally implemented it as a layer on top of the "pnm library", based on netpbm, which was built to implement pbm, pgm, and pbm files, and is the underlying support of a number of public-domain image file converters. More...
Public Types | |
enum | ColorType { CTInvalid = 0, CTGrayscale = 1, CTTwoChannel = 2, CTColor = 3, CTFourChannel = 4 } |
Public Member Functions | |
PNMImage () | |
PNMImage (Filename const filename, PNMFileType type) | |
PNMImage (PNMImage const copy) | |
PNMImage (int x_size, int y_size) | |
PNMImage (int x_size, int y_size, int num_channels, unsigned short int maxval, PNMFileType type) | |
PNMImage (Filename const filename) | |
PNMImage (int x_size, int y_size, int num_channels, unsigned short int maxval) | |
PNMImage (int x_size, int y_size, int num_channels) | |
addAlpha () | |
Adds an alpha channel to the image, if it does not already have one. | |
alphaFill (double alpha) | |
Sets the entire alpha channel to the given level. | |
alphaFill () | |
Sets the entire alpha channel to the given level. | |
alphaFillVal (unsigned short int alpha) | |
Sets the entire alpha channel to the given level. | |
alphaFillVal () | |
Sets the entire alpha channel to the given level. | |
blend (int x, int y, VBase3D const val, double alpha) | |
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value. | |
blend (int x, int y, double r, double g, double b, double alpha) | |
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value. | |
blendSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, double pixel_scale) | |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally. | |
blendSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size) | |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally. | |
blendSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size) | |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally. | |
blendSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom) | |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally. | |
blendSubImage (PNMImage const copy, int xto, int yto, int xfrom) | |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally. | |
blendSubImage (PNMImage const copy, int xto, int yto) | |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally. | |
boxFilter (double radius) | |
This flavor of box_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation. | |
boxFilter () | |
This flavor of box_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation. | |
boxFilterFrom (double radius, PNMImage const copy) | |
Makes a resized copy of the indicated image into this one using the indicated filter. | |
unsigned short int | clampVal (int input_value) |
A handy function to clamp values to [0..get_maxval()]. | |
clear (int x_size, int y_size, int num_channels) | |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions. | |
clear (int x_size, int y_size) | |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions. | |
clear () | |
Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc). | |
clear (int x_size, int y_size, int num_channels, unsigned short int maxval, PNMFileType type) | |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions. | |
clear (int x_size, int y_size, int num_channels, unsigned short int maxval) | |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions. | |
clearReadSize () | |
Undoes the effect of a previous call to set_read_size(). | |
copyChannel (PNMImage const copy, int src_channel, int dest_channel) | |
Copies a channel from one image into another. | |
copyChannel (PNMImage const copy, int xto, int yto, int cto, int xfrom, int yfrom, int cfrom, int x_size, int y_size) | |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone. | |
copyChannel (PNMImage const copy, int xto, int yto, int cto, int xfrom, int yfrom, int cfrom, int x_size) | |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone. | |
copyChannel (PNMImage const copy, int xto, int yto, int cto, int xfrom, int yfrom, int cfrom) | |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone. | |
copyChannel (PNMImage const copy, int xto, int yto, int cto, int xfrom, int yfrom) | |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone. | |
copyChannel (PNMImage const copy, int xto, int yto, int cto, int xfrom) | |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone. | |
copyChannel (PNMImage const copy, int xto, int yto, int cto) | |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone. | |
copyFrom (PNMImage const copy) | |
Makes this image become a copy of the other image. | |
copyHeaderFrom (PNMImageHeader const header) | |
Copies just the header information into this image. | |
copySubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size) | |
Copies a rectangular area of another image into a rectangular area of this image. | |
copySubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size) | |
Copies a rectangular area of another image into a rectangular area of this image. | |
copySubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom) | |
Copies a rectangular area of another image into a rectangular area of this image. | |
copySubImage (PNMImage const copy, int xto, int yto, int xfrom) | |
Copies a rectangular area of another image into a rectangular area of this image. | |
copySubImage (PNMImage const copy, int xto, int yto) | |
Copies a rectangular area of another image into a rectangular area of this image. | |
darkenSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, double pixel_scale) | |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
darkenSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size) | |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
darkenSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size) | |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
darkenSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom) | |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
darkenSubImage (PNMImage const copy, int xto, int yto, int xfrom) | |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
darkenSubImage (PNMImage const copy, int xto, int yto) | |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
expandBorder (int left, int right, int bottom, int top, VBase4D const color) | |
Expands the image by the indicated number of pixels on each edge. | |
fill (double gray) | |
Sets the entire image (except the alpha channel) to the given grayscale level. | |
fill () | |
Sets the entire image (except the alpha channel) to the given grayscale level. | |
fill (double red, double green, double blue) | |
Sets the entire image (except the alpha channel) to the given color. | |
fillVal (unsigned short int gray) | |
Sets the entire image (except the alpha channel) to the given grayscale level. | |
fillVal () | |
Sets the entire image (except the alpha channel) to the given grayscale level. | |
fillVal (unsigned short int red, unsigned short int green, unsigned short int blue) | |
Sets the entire image (except the alpha channel) to the given color. | |
double | fromVal (unsigned short int input_value) |
A handy function to scale values from [0..get_maxval()] to [0..1]. | |
gaussianFilter (double radius) | |
This flavor of gaussian_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation. | |
gaussianFilter () | |
This flavor of gaussian_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation. | |
gaussianFilterFrom (double radius, PNMImage const copy) | |
Makes a resized copy of the indicated image into this one using the indicated filter. | |
double | getAlpha (int x, int y) |
Returns the alpha component color at the indicated pixel. | |
unsigned short int | getAlphaVal (int x, int y) |
Returns the alpha component color at the indicated pixel. | |
double | getAverageGray () |
Returns the average grayscale component of all of the pixels in the image. | |
VBase3D | getAverageXel () |
Returns the average color of all of the pixels in the image. | |
VBase4D | getAverageXelA () |
Returns the average color of all of the pixels in the image, including the alpha channel. | |
double | getBlue (int x, int y) |
Returns the blue component color at the indicated pixel. | |
unsigned short int | getBlueVal (int x, int y) |
Returns the blue component color at the indicated pixel. | |
double | getBright (int x, int y) |
Returns the linear brightness of the given xel, as a double in the range 0..1. | |
double | getBright (int x, int y, double rc, double gc, double bc) |
This flavor of get_bright() works correctly only for color images. | |
double | getBright (int x, int y, double rc, double gc, double bc, double ac) |
This flavor of get_bright() works correctly only for four-channel images. | |
double | getChannel (int x, int y, int channel) |
Returns the nth component color at the indicated pixel. | |
unsigned short int | getChannelVal (int x, int y, int channel) |
Returns the nth component color at the indicated pixel. | |
ColorType | getColorType () |
Returns the image type of the image, as an enumerated value. | |
string | getComment () |
Gets the user comment from the file. | |
double | getGray (int x, int y) |
Returns the gray component color at the indicated pixel. | |
unsigned short int | getGrayVal (int x, int y) |
Returns the gray component color at the indicated pixel. | |
double | getGreen (int x, int y) |
Returns the green component color at the indicated pixel. | |
unsigned short int | getGreenVal (int x, int y) |
Returns the green component color at the indicated pixel. | |
unsigned short int | getMaxval () |
Returns the maximum channel value allowable for any pixel in this image; for instance, 255 for a typical 8-bit-per-channel image. | |
int | getNumChannels () |
Returns the number of channels in the image. | |
PixelSpec | getPixel (int x, int y) |
Returns the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object. | |
int | getReadXSize () |
Returns the requested x_size of the image if set_read_size() has been called, or the image x_size otherwise (if it is known). | |
int | getReadYSize () |
Returns the requested y_size of the image if set_read_size() has been called, or the image y_size otherwise (if it is known). | |
double | getRed (int x, int y) |
Returns the red component color at the indicated pixel. | |
unsigned short int | getRedVal (int x, int y) |
Returns the red component color at the indicated pixel. | |
PNMFileType | getType () |
If the file type is known (e.g. | |
VBase3D | getXel (int x, int y) |
Returns the RGB color at the indicated pixel. | |
VBase4D | getXelA (int x, int y) |
Returns the RGBA color at the indicated pixel. | |
pixel const | getXelVal (int x, int y) |
Returns the RGB color at the indicated pixel. | |
int | getXSize () |
Returns the number of pixels in the X direction. | |
int | getYSize () |
Returns the number of pixels in the Y direction. | |
bool | hasAlpha () |
Returns true if the image includes an alpha channel, false otherwise. | |
bool | hasReadSize () |
Returns true if set_read_size() has been called. | |
bool | hasType () |
Returns true if the PNMImageHeader knows what type it is, false otherwise. | |
bool | isGrayscale () |
Returns false if the image is a full-color image, and has red, green, and blue components; true if it is a grayscale image and has only a gray component. | |
bool | isValid () |
Returns true if the image has been read in or correctly initialized with a height and width. | |
lightenSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size, double pixel_scale) | |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
lightenSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size, int y_size) | |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
lightenSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom, int x_size) | |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
lightenSubImage (PNMImage const copy, int xto, int yto, int xfrom) | |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
lightenSubImage (PNMImage const copy, int xto, int yto, int xfrom, int yfrom) | |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
lightenSubImage (PNMImage const copy, int xto, int yto) | |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value). | |
makeGrayscale (double rc, double gc, double bc) | |
Converts the image from RGB to grayscale. | |
makeGrayscale () | |
Converts the image from RGB to grayscale. | |
makeHistogram (Histogram hist) | |
Computes a histogram of the colors used in the image. | |
PNMReader | makeReader (istream file, bool owns_file, Filename const filename, string magic_number, PNMFileType type) |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason. | |
PNMReader | makeReader (istream file, bool owns_file, Filename const filename, string magic_number) |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason. | |
PNMReader | makeReader (istream file, bool owns_file) |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason. | |
PNMReader | makeReader (Filename const filename) |
Returns a newly-allocated PNMReader of the suitable type for reading from the indicated image filename, or NULL if the filename cannot be read for some reason. | |
PNMReader | makeReader (istream file, bool owns_file, Filename const filename) |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason. | |
PNMReader | makeReader (istream file) |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason. | |
PNMReader | makeReader (istream file, bool owns_file, Filename const filename, string magic_number, PNMFileType type, bool report_unknown_type) |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason. | |
PNMReader | makeReader (Filename const filename, PNMFileType type, bool report_unknown_type) |
Returns a newly-allocated PNMReader of the suitable type for reading from the indicated image filename, or NULL if the filename cannot be read for some reason. | |
PNMReader | makeReader (Filename const filename, PNMFileType type) |
Returns a newly-allocated PNMReader of the suitable type for reading from the indicated image filename, or NULL if the filename cannot be read for some reason. | |
makeRgb () | |
Converts the image from grayscale to RGB. | |
PNMWriter | makeWriter (ostream file, bool owns_file, Filename const filename, PNMFileType type) |
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason. | |
PNMWriter | makeWriter (ostream file, bool owns_file) |
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason. | |
PNMWriter | makeWriter (Filename const filename) |
Returns a newly-allocated PNMWriter of the suitable type for writing an image to the indicated filename, or NULL if the filename cannot be written for some reason. | |
PNMWriter | makeWriter (ostream file) |
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason. | |
PNMWriter | makeWriter (ostream file, bool owns_file, Filename const filename) |
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason. | |
PNMWriter | makeWriter (Filename const filename, PNMFileType type) |
Returns a newly-allocated PNMWriter of the suitable type for writing an image to the indicated filename, or NULL if the filename cannot be written for some reason. | |
PNMImage | operator* (PNMImage const other) |
Returns a new PNMImage in which each pixel value from the left image is multiplied by each pixel value from the right image. | |
PNMImage | operator* (double multiplier) |
Multiplies every pixel value in the image by a constant floating-point multiplier value. | |
PNMImage | operator*= (PNMImage const other) |
Returns a new PNMImage in which each pixel value from the left image is multiplied by each pixel value from the right image. | |
PNMImage | operator*= (double multiplier) |
Multiplies every pixel value in the image by a constant floating-point multiplier value. | |
PNMImage | operator+ (VBase4D const other) |
Returns a new PNMImage in which the provided color is added to each pixel in the provided image. | |
PNMImage | operator+ (PNMImage const other) |
Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images. | |
PNMImage | operator+= (PNMImage const other) |
Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images. | |
PNMImage | operator+= (VBase4D const other) |
Returns a new PNMImage in which the provided color is added to each pixel in the provided image. | |
PNMImage | operator- (VBase4D const other) |
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image. | |
PNMImage | operator- (PNMImage const other) |
Returns a new PNMImage in which each pixel value from the right image is subtracted from each pixel value from the left image. | |
PNMImage | operator-= (VBase4D const other) |
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image. | |
PNMImage | operator-= (PNMImage const other) |
Returns a new PNMImage in which each pixel value from the right image is subtracted from each pixel value from the left image. | |
PNMImage | operator= (PNMImage const copy) |
pixel | operator[] (int y) |
Allows the PNMImage to appear to be a 2-d array of xels. | |
pixel const | operator[] (int y) |
Allows the PNMImage to appear to be a 2-d array of xels. | |
PNMImage | operator~ () |
Returns a new PNMImage that is the complement of the current PNMImage. | |
output (ostream out) | |
perlinNoiseFill (StackedPerlinNoise2 perlin) | |
Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2 object. | |
perlinNoiseFill (double sx, double sy) | |
Fills the image with a grayscale perlin noise pattern based on the indicated parameters. | |
perlinNoiseFill (double sx, double sy, int table_size, unsigned long int seed) | |
Fills the image with a grayscale perlin noise pattern based on the indicated parameters. | |
perlinNoiseFill (double sx, double sy, int table_size) | |
Fills the image with a grayscale perlin noise pattern based on the indicated parameters. | |
quickFilterFrom (PNMImage const copy, int xborder, int yborder) | |
Resizes from the given image, with a fixed radius of 0.5. | |
quickFilterFrom (PNMImage const copy) | |
Resizes from the given image, with a fixed radius of 0.5. | |
quickFilterFrom (PNMImage const copy, int xborder) | |
Resizes from the given image, with a fixed radius of 0.5. | |
bool | read (istream data, string filename) |
Reads the image data from the indicated stream. | |
bool | read (Filename const filename, PNMFileType type, bool report_unknown_type) |
Reads the indicated image filename. | |
bool | read (PNMReader reader) |
This flavor of read() uses an already-existing PNMReader to read the image file. | |
bool | read (Filename const filename, PNMFileType type) |
Reads the indicated image filename. | |
bool | read (istream data, string filename, PNMFileType type) |
Reads the image data from the indicated stream. | |
bool | read (Filename const filename) |
Reads the indicated image filename. | |
bool | read (istream data) |
Reads the image data from the indicated stream. | |
bool | read (istream data, string filename, PNMFileType type, bool report_unknown_type) |
Reads the image data from the indicated stream. | |
bool | readHeader (Filename const filename) |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc. | |
bool | readHeader (Filename const filename, PNMFileType type, bool report_unknown_type) |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc. | |
bool | readHeader (Filename const filename, PNMFileType type) |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc. | |
bool | readHeader (istream data, string filename, PNMFileType type, bool report_unknown_type) |
Reads the image header information only from the indicated stream. | |
bool | readHeader (istream data, string filename, PNMFileType type) |
Reads the image header information only from the indicated stream. | |
bool | readHeader (istream data) |
Reads the image header information only from the indicated stream. | |
bool | readHeader (istream data, string filename) |
Reads the image header information only from the indicated stream. | |
remixChannels (Mat4 const conv) | |
Transforms every pixel using the operation (Ro,Go,Bo) = conv.xform_point(Ri,Gi,Bi); Input must be a color image. | |
removeAlpha () | |
Removes the image's alpha channel, if it exists. | |
renderSpot (VBase4D const fg, VBase4D const bg, double min_radius, double max_radius) | |
Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage. | |
setAlpha (int x, int y, double a) | |
Sets the alpha component color only at the indicated pixel. | |
setAlphaVal (int x, int y, unsigned short int a) | |
Sets the alpha component color only at the indicated pixel. | |
setBlue (int x, int y, double b) | |
Sets the blue component color only at the indicated pixel. | |
setBlueVal (int x, int y, unsigned short int b) | |
Sets the blue component color only at the indicated pixel. | |
setChannel (int x, int y, int channel, double value) | |
Sets the nth component color at the indicated pixel. | |
setChannelVal (int x, int y, int channel, unsigned short int value) | |
Sets the nth component color at the indicated pixel. | |
setColorType (ColorType color_type) | |
Translates the image to or from grayscale, color, or four-color mode. | |
setComment (string comment) | |
Writes a user comment string to the image (header). | |
setGray (int x, int y, double gray) | |
Sets the gray component color at the indicated pixel. | |
setGrayVal (int x, int y, unsigned short int gray) | |
Sets the gray component color at the indicated pixel. | |
setGreen (int x, int y, double g) | |
Sets the green component color only at the indicated pixel. | |
setGreenVal (int x, int y, unsigned short int g) | |
Sets the green component color only at the indicated pixel. | |
setMaxval (unsigned short int maxval) | |
Rescales the image to the indicated maxval. | |
setNumChannels (int num_channels) | |
Changes the number of channels associated with the image. | |
setPixel (int x, int y, PixelSpec const pixel) | |
Sets the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object. | |
setReadSize (int x_size, int y_size) | |
Specifies the size to we'd like to scale the image upon reading it. | |
setRed (int x, int y, double r) | |
Sets the red component color only at the indicated pixel. | |
setRedVal (int x, int y, unsigned short int r) | |
Sets the red component color only at the indicated pixel. | |
setType (PNMFileType type) | |
Sets the file type of this PNMImage. | |
setXel (int x, int y, double r, double g, double b) | |
Changes the RGB color at the indicated pixel. | |
setXel (int x, int y, VBase3D const value) | |
Changes the RGB color at the indicated pixel. | |
setXel (int x, int y, double gray) | |
Changes all three color components at the indicated pixel to the same value. | |
setXelA (int x, int y, double r, double g, double b, double a) | |
Changes the RGBA color at the indicated pixel. | |
setXelA (int x, int y, VBase4D const value) | |
Changes the RGBA color at the indicated pixel. | |
setXelVal (int x, int y, unsigned short int r, unsigned short int g, unsigned short int b) | |
Changes the RGB color at the indicated pixel. | |
setXelVal (int x, int y, unsigned short int gray) | |
Changes all three color components at the indicated pixel to the same value. | |
setXelVal (int x, int y, pixel const value) | |
Changes the RGB color at the indicated pixel. | |
takeFrom (PNMImage orig) | |
Move the contents of the other image into this one, and empty the other image. | |
threshold (PNMImage const select_image, int channel, double threshold, PNMImage const lt, PNMImage const ge) | |
Selectively copies each pixel from either one source or another source, depending on the pixel value of the indicated channel of select_image. | |
unsigned short int | toVal (double input_value) |
A handy function to scale values from [0..1] to [0..get_maxval()]. | |
bool | write (PNMWriter writer) |
This flavor of write() uses an already-existing PNMWriter to write the image file. | |
bool | write (ostream data) |
Writes the image to the indicated ostream. | |
bool | write (ostream data, string filename, PNMFileType type) |
Writes the image to the indicated ostream. | |
bool | write (Filename const filename, PNMFileType type) |
Writes the image to the indicated filename. | |
bool | write (Filename const filename) |
Writes the image to the indicated filename. | |
bool | write (ostream data, string filename) |
Writes the image to the indicated ostream. | |
Static Public Member Functions | |
static bool | hasAlpha (ColorType color_type) |
This static variant of has_alpha() returns true if the indicated image type includes an alpha channel, false otherwise. | |
static bool | isGrayscale (ColorType color_type) |
This static variant of is_grayscale() returns true if the indicated image type represents a grayscale image, false otherwise. | |
static bool | readMagicNumber (istream file, basic_stringchar magic_number, int num_bytes) |
Ensures that the first n bytes of the file are read into magic_number. |
The name of this class derives from the fact that we originally implemented it as a layer on top of the "pnm library", based on netpbm, which was built to implement pbm, pgm, and pbm files, and is the underlying support of a number of public-domain image file converters.
Nowadays we are no longer derived directly from the pnm library, mainly to allow support of C++ iostreams instead of the C stdio FILE interface.
Conceptually, a PNMImage is a two-dimensional array of xels, which are the PNM-defined generic pixel type. Each xel may have a red, green, and blue component, or (if the image is grayscale) a gray component. The image may be read in, the individual xels manipulated, and written out again, or a black image may be constructed from scratch.
The image is of size XSize() by YSize() xels, numbered from top to bottom, left to right, beginning at zero.
Files can be specified by filename, or by an iostream pointer. The filename "-" refers to stdin or stdout.
enum ColorType [inherited] |
PNMImage | ( | ) |
PNMImage | ( | Filename const | filename, |
PNMFileType | type | ||
) |
addAlpha | ( | ) |
Adds an alpha channel to the image, if it does not already have one.
The alpha channel is initialized to zeros.
alphaFill | ( | double | alpha | ) |
Sets the entire alpha channel to the given level.
alphaFill | ( | ) |
Sets the entire alpha channel to the given level.
alphaFillVal | ( | unsigned short int | alpha | ) |
Sets the entire alpha channel to the given level.
alphaFillVal | ( | ) |
Sets the entire alpha channel to the given level.
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value.
An alpha of 1.0 is fully opaque and completely replaces whatever was there previously; alpha of 0.0 is fully transparent and does nothing.
Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value.
An alpha of 1.0 is fully opaque and completely replaces whatever was there previously; alpha of 0.0 is fully transparent and does nothing.
blendSubImage | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | x_size, | ||
int | y_size, | ||
double | pixel_scale | ||
) |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally.
If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* value of the source image before applying it to the target image.
If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates into copy_sub_image().
blendSubImage | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | x_size, | ||
int | y_size | ||
) |
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally.
If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* value of the source image before applying it to the target image.
If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates into copy_sub_image().
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally.
If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* value of the source image before applying it to the target image.
If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates into copy_sub_image().
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally.
If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* value of the source image before applying it to the target image.
If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates into copy_sub_image().
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally.
If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* value of the source image before applying it to the target image.
If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates into copy_sub_image().
Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally.
If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* value of the source image before applying it to the target image.
If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates into copy_sub_image().
boxFilter | ( | double | radius | ) |
This flavor of box_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation.
boxFilter | ( | ) |
This flavor of box_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation.
boxFilterFrom | ( | double | radius, |
PNMImage const | copy | ||
) |
Makes a resized copy of the indicated image into this one using the indicated filter.
The image to be copied is squashed and stretched to match the dimensions of the current image, applying the appropriate filter to perform the stretching.
A handy function to clamp values to [0..get_maxval()].
clear | ( | ) |
Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc).
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.
clear | ( | int | x_size, |
int | y_size, | ||
int | num_channels, | ||
unsigned short int | maxval, | ||
PNMFileType | type | ||
) |
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.
This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.
clearReadSize | ( | ) |
Undoes the effect of a previous call to set_read_size().
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone.
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone.
Copies a channel from one image into another.
Images must be the same size
copyChannel | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | cto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | cfrom, | ||
int | x_size, | ||
int | y_size | ||
) |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone.
copyChannel | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | cto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | cfrom, | ||
int | x_size | ||
) |
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone.
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone.
Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone.
copyFrom | ( | PNMImage const | copy | ) |
Makes this image become a copy of the other image.
copyHeaderFrom | ( | PNMImageHeader const | header | ) |
Copies just the header information into this image.
This will blow away any image data stored in the image. The new image data will be allocated, but left unitialized.
copySubImage | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | x_size, | ||
int | y_size | ||
) |
Copies a rectangular area of another image into a rectangular area of this image.
Both images must already have been initialized. The upper-left corner of the region in both images is specified, and the size of the area; if the size is omitted, it defaults to the entire other image, or the largest piece that will fit.
Copies a rectangular area of another image into a rectangular area of this image.
Both images must already have been initialized. The upper-left corner of the region in both images is specified, and the size of the area; if the size is omitted, it defaults to the entire other image, or the largest piece that will fit.
Copies a rectangular area of another image into a rectangular area of this image.
Both images must already have been initialized. The upper-left corner of the region in both images is specified, and the size of the area; if the size is omitted, it defaults to the entire other image, or the largest piece that will fit.
Copies a rectangular area of another image into a rectangular area of this image.
Both images must already have been initialized. The upper-left corner of the region in both images is specified, and the size of the area; if the size is omitted, it defaults to the entire other image, or the largest piece that will fit.
Copies a rectangular area of another image into a rectangular area of this image.
Both images must already have been initialized. The upper-left corner of the region in both images is specified, and the size of the area; if the size is omitted, it defaults to the entire other image, or the largest piece that will fit.
darkenSubImage | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | x_size, | ||
int | y_size, | ||
double | pixel_scale | ||
) |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image. The scale is applied with the center at 1.0: scaling the pixel value smaller brings it closer to 1.0.
darkenSubImage | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | x_size, | ||
int | y_size | ||
) |
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image. The scale is applied with the center at 1.0: scaling the pixel value smaller brings it closer to 1.0.
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image. The scale is applied with the center at 1.0: scaling the pixel value smaller brings it closer to 1.0.
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image. The scale is applied with the center at 1.0: scaling the pixel value smaller brings it closer to 1.0.
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image. The scale is applied with the center at 1.0: scaling the pixel value smaller brings it closer to 1.0.
Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image. The scale is applied with the center at 1.0: scaling the pixel value smaller brings it closer to 1.0.
Expands the image by the indicated number of pixels on each edge.
The new pixels are set to the indicated color.
If any of the values is negative, this actually crops the image.
fill | ( | double | gray | ) |
Sets the entire image (except the alpha channel) to the given grayscale level.
fill | ( | ) |
Sets the entire image (except the alpha channel) to the given grayscale level.
fill | ( | double | red, |
double | green, | ||
double | blue | ||
) |
Sets the entire image (except the alpha channel) to the given color.
fillVal | ( | unsigned short int | gray | ) |
Sets the entire image (except the alpha channel) to the given grayscale level.
fillVal | ( | ) |
Sets the entire image (except the alpha channel) to the given grayscale level.
Sets the entire image (except the alpha channel) to the given color.
double fromVal | ( | unsigned short int | input_value | ) |
A handy function to scale values from [0..get_maxval()] to [0..1].
gaussianFilter | ( | double | radius | ) |
This flavor of gaussian_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation.
gaussianFilter | ( | ) |
This flavor of gaussian_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation.
gaussianFilterFrom | ( | double | radius, |
PNMImage const | copy | ||
) |
Makes a resized copy of the indicated image into this one using the indicated filter.
The image to be copied is squashed and stretched to match the dimensions of the current image, applying the appropriate filter to perform the stretching.
Returns the alpha component color at the indicated pixel.
It is an error to call this unless has_alpha() is true. The value returned is a double in the range 0..1.
Returns the alpha component color at the indicated pixel.
It is an error to call this unless has_alpha() is true. The value returned is in the range 0..maxval.
double getAverageGray | ( | ) |
Returns the average grayscale component of all of the pixels in the image.
VBase3D getAverageXel | ( | ) |
Returns the average color of all of the pixels in the image.
VBase4D getAverageXelA | ( | ) |
Returns the average color of all of the pixels in the image, including the alpha channel.
Returns the blue component color at the indicated pixel.
The value returned is a double in the range 0..1.
Returns the blue component color at the indicated pixel.
The value returned is in the range 0..maxval.
This flavor of get_bright() works correctly only for color images.
It returns a single brightness value for the RGB color at the indicated pixel, based on the supplied weights for each component.
Returns the linear brightness of the given xel, as a double in the range 0..1.
This flavor of get_bright() returns the correct grayscale brightness level for both full-color and grayscale images.
This flavor of get_bright() works correctly only for four-channel images.
It returns a single brightness value for the RGBA color at the indicated pixel, based on the supplied weights for each component.
Returns the nth component color at the indicated pixel.
The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than accessing the component values directly by named methods. The value returned is a double in the range 0..1.
Returns the nth component color at the indicated pixel.
The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than accessing the component values directly by named methods. The value returned is in the range 0..maxval.
ColorType getColorType | ( | ) | [inherited] |
Returns the image type of the image, as an enumerated value.
This is really just the number of channels cast to the enumerated type.
string getComment | ( | ) | [inherited] |
Gets the user comment from the file.
Returns the gray component color at the indicated pixel.
This only has a meaningful value for grayscale images; for other image types, this returns the value of the blue channel only. However, also see the get_bright() function. The value returned is a double in the range 0..1.
Returns the gray component color at the indicated pixel.
This only has a meaningful value for grayscale images; for other image types, this returns the value of the blue channel only. However, also see the get_bright() function. The value returned is in the range 0..maxval.
Returns the green component color at the indicated pixel.
The value returned is a double in the range 0..1.
Returns the green component color at the indicated pixel.
The value returned is in the range 0..maxval.
unsigned short int getMaxval | ( | ) | [inherited] |
Returns the maximum channel value allowable for any pixel in this image; for instance, 255 for a typical 8-bit-per-channel image.
A pixel with this value is full on.
int getNumChannels | ( | ) | [inherited] |
Returns the number of channels in the image.
Returns the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object.
int getReadXSize | ( | ) |
Returns the requested x_size of the image if set_read_size() has been called, or the image x_size otherwise (if it is known).
int getReadYSize | ( | ) |
Returns the requested y_size of the image if set_read_size() has been called, or the image y_size otherwise (if it is known).
Returns the red component color at the indicated pixel.
The value returned is a double in the range 0..1.
Returns the red component color at the indicated pixel.
The value returned is in the range 0..maxval.
PNMFileType getType | ( | ) | [inherited] |
If the file type is known (e.g.
has_type() returns true), returns its PNMFileType pointer; otherwise, returns NULL.
Returns the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Returns the RGBA color at the indicated pixel.
Each component is a double in the range 0..1.
Returns the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
int getXSize | ( | ) | [inherited] |
Returns the number of pixels in the X direction.
This is one more than the largest allowable X coordinate.
int getYSize | ( | ) | [inherited] |
Returns the number of pixels in the Y direction.
This is one more than the largest allowable Y coordinate.
bool hasAlpha | ( | ) | [inherited] |
Returns true if the image includes an alpha channel, false otherwise.
Unlike is_grayscale(), if this returns false it is an error to call any of the functions accessing the alpha channel.
static bool hasAlpha | ( | ColorType | color_type | ) | [static, inherited] |
This static variant of has_alpha() returns true if the indicated image type includes an alpha channel, false otherwise.
bool hasReadSize | ( | ) |
Returns true if set_read_size() has been called.
bool hasType | ( | ) | [inherited] |
Returns true if the PNMImageHeader knows what type it is, false otherwise.
static bool isGrayscale | ( | ColorType | color_type | ) | [static, inherited] |
This static variant of is_grayscale() returns true if the indicated image type represents a grayscale image, false otherwise.
bool isGrayscale | ( | ) | [inherited] |
Returns false if the image is a full-color image, and has red, green, and blue components; true if it is a grayscale image and has only a gray component.
(The gray color is actually stored in the blue channel, and the red and green channels are ignored.)
bool isValid | ( | ) |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image.
lightenSubImage | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | x_size, | ||
int | y_size, | ||
double | pixel_scale | ||
) |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image.
lightenSubImage | ( | PNMImage const | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom, | ||
int | yfrom, | ||
int | x_size, | ||
int | y_size | ||
) |
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image.
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image.
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image.
Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value).
If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image.
makeGrayscale | ( | ) |
Converts the image from RGB to grayscale.
Any alpha channel, if present, is left undisturbed.
makeGrayscale | ( | double | rc, |
double | gc, | ||
double | bc | ||
) |
Converts the image from RGB to grayscale.
Any alpha channel, if present, is left undisturbed. The optional rc, gc, bc values represent the relative weights to apply to each channel to convert it to grayscale.
makeHistogram | ( | Histogram | hist | ) |
Computes a histogram of the colors used in the image.
PNMReader makeReader | ( | istream | file, |
bool | owns_file, | ||
Filename const | filename, | ||
string | magic_number, | ||
PNMFileType | type, | ||
bool | report_unknown_type | ||
) | [inherited] |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason.
owns_file should be set true if the PNMReader is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the file type.
If magic_number is nonempty, it is assumed to represent the first few bytes that have already been read from the file. Some file types may have difficulty if this is more than two bytes.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
PNMReader makeReader | ( | Filename const | filename, |
PNMFileType | type, | ||
bool | report_unknown_type | ||
) | [inherited] |
Returns a newly-allocated PNMReader of the suitable type for reading from the indicated image filename, or NULL if the filename cannot be read for some reason.
The filename "-" always stands for standard input. If type is specified, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
PNMReader makeReader | ( | Filename const | filename, |
PNMFileType | type | ||
) | [inherited] |
Returns a newly-allocated PNMReader of the suitable type for reading from the indicated image filename, or NULL if the filename cannot be read for some reason.
The filename "-" always stands for standard input. If type is specified, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
PNMReader makeReader | ( | Filename const | filename | ) | [inherited] |
Returns a newly-allocated PNMReader of the suitable type for reading from the indicated image filename, or NULL if the filename cannot be read for some reason.
The filename "-" always stands for standard input. If type is specified, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
PNMReader makeReader | ( | istream | file, |
bool | owns_file, | ||
Filename const | filename, | ||
string | magic_number, | ||
PNMFileType | type | ||
) | [inherited] |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason.
owns_file should be set true if the PNMReader is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the file type.
If magic_number is nonempty, it is assumed to represent the first few bytes that have already been read from the file. Some file types may have difficulty if this is more than two bytes.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
PNMReader makeReader | ( | istream | file, |
bool | owns_file, | ||
Filename const | filename, | ||
string | magic_number | ||
) | [inherited] |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason.
owns_file should be set true if the PNMReader is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the file type.
If magic_number is nonempty, it is assumed to represent the first few bytes that have already been read from the file. Some file types may have difficulty if this is more than two bytes.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason.
owns_file should be set true if the PNMReader is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the file type.
If magic_number is nonempty, it is assumed to represent the first few bytes that have already been read from the file. Some file types may have difficulty if this is more than two bytes.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
PNMReader makeReader | ( | istream | file | ) | [inherited] |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason.
owns_file should be set true if the PNMReader is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the file type.
If magic_number is nonempty, it is assumed to represent the first few bytes that have already been read from the file. Some file types may have difficulty if this is more than two bytes.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
PNMReader makeReader | ( | istream | file, |
bool | owns_file | ||
) | [inherited] |
Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason.
owns_file should be set true if the PNMReader is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the file type.
If magic_number is nonempty, it is assumed to represent the first few bytes that have already been read from the file. Some file types may have difficulty if this is more than two bytes.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMReader should be deleted when it is no longer needed.
makeRgb | ( | ) |
Converts the image from grayscale to RGB.
Any alpha channel, if present, is left undisturbed.
PNMWriter makeWriter | ( | Filename const | filename, |
PNMFileType | type | ||
) | [inherited] |
Returns a newly-allocated PNMWriter of the suitable type for writing an image to the indicated filename, or NULL if the filename cannot be written for some reason.
The filename "-" always stands for standard output. If type is specified, it is a suggestion for the file type to use.
The PNMWriter should be deleted when it is no longer needed.
PNMWriter makeWriter | ( | Filename const | filename | ) | [inherited] |
Returns a newly-allocated PNMWriter of the suitable type for writing an image to the indicated filename, or NULL if the filename cannot be written for some reason.
The filename "-" always stands for standard output. If type is specified, it is a suggestion for the file type to use.
The PNMWriter should be deleted when it is no longer needed.
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason.
owns_file should be set true if the PNMWriter is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the intended file type.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMWriter should be deleted when it is no longer needed.
PNMWriter makeWriter | ( | ostream | file | ) | [inherited] |
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason.
owns_file should be set true if the PNMWriter is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the intended file type.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMWriter should be deleted when it is no longer needed.
PNMWriter makeWriter | ( | ostream | file, |
bool | owns_file | ||
) | [inherited] |
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason.
owns_file should be set true if the PNMWriter is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the intended file type.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMWriter should be deleted when it is no longer needed.
PNMWriter makeWriter | ( | ostream | file, |
bool | owns_file, | ||
Filename const | filename, | ||
PNMFileType | type | ||
) | [inherited] |
Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason.
owns_file should be set true if the PNMWriter is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it.
The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the intended file type.
If type is non-NULL, it is a suggestion for the file type to use.
The PNMWriter should be deleted when it is no longer needed.
Returns a new PNMImage in which each pixel value from the left image is multiplied by each pixel value from the right image.
Note that the floating-point values in the 0..1 range are multiplied, not in the 0..maxval range. Only valid when both images have the same size.
PNMImage operator* | ( | double | multiplier | ) |
Multiplies every pixel value in the image by a constant floating-point multiplier value.
Returns a new PNMImage in which each pixel value from the left image is multiplied by each pixel value from the right image.
Note that the floating-point values in the 0..1 range are multiplied, not in the 0..maxval range. Only valid when both images have the same size.
PNMImage operator*= | ( | double | multiplier | ) |
Multiplies every pixel value in the image by a constant floating-point multiplier value.
Returns a new PNMImage in which the provided color is added to each pixel in the provided image.
Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images.
Only valid when both images have the same size.
Returns a new PNMImage in which the provided color is added to each pixel in the provided image.
Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images.
Only valid when both images have the same size.
Returns a new PNMImage in which each pixel value from the right image is subtracted from each pixel value from the left image.
Only valid when both images have the same size.
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image.
Returns a new PNMImage in which each pixel value from the right image is subtracted from each pixel value from the left image.
Only valid when both images have the same size.
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image.
output | ( | ostream | out | ) | [inherited] |
perlinNoiseFill | ( | StackedPerlinNoise2 | perlin | ) |
Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2 object.
Fills the image with a grayscale perlin noise pattern based on the indicated parameters.
Uses set_xel to set the grayscale values. The sx and sy parameters are in multiples of the size of this image. See also the PerlinNoise2 class in mathutil.
perlinNoiseFill | ( | double | sx, |
double | sy, | ||
int | table_size | ||
) |
Fills the image with a grayscale perlin noise pattern based on the indicated parameters.
Uses set_xel to set the grayscale values. The sx and sy parameters are in multiples of the size of this image. See also the PerlinNoise2 class in mathutil.
perlinNoiseFill | ( | double | sx, |
double | sy | ||
) |
Fills the image with a grayscale perlin noise pattern based on the indicated parameters.
Uses set_xel to set the grayscale values. The sx and sy parameters are in multiples of the size of this image. See also the PerlinNoise2 class in mathutil.
Resizes from the given image, with a fixed radius of 0.5.
This is a very specialized and simple algorithm that doesn't handle dropping below the Nyquist rate very well, but is quite a bit faster than the more general box_filter(), above. If borders are specified, they will further restrict the size of the resulting image. There's no point in using quick_box_filter() on a single image.
quickFilterFrom | ( | PNMImage const | copy | ) |
Resizes from the given image, with a fixed radius of 0.5.
This is a very specialized and simple algorithm that doesn't handle dropping below the Nyquist rate very well, but is quite a bit faster than the more general box_filter(), above. If borders are specified, they will further restrict the size of the resulting image. There's no point in using quick_box_filter() on a single image.
Resizes from the given image, with a fixed radius of 0.5.
This is a very specialized and simple algorithm that doesn't handle dropping below the Nyquist rate very well, but is quite a bit faster than the more general box_filter(), above. If borders are specified, they will further restrict the size of the resulting image. There's no point in using quick_box_filter() on a single image.
bool read | ( | Filename const | filename, |
PNMFileType | type, | ||
bool | report_unknown_type | ||
) |
Reads the indicated image filename.
If type is non-NULL, it is a suggestion for the type of file it is. Returns true if successful, false on error.
bool read | ( | istream | data | ) |
Reads the image data from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
bool read | ( | Filename const | filename | ) |
Reads the indicated image filename.
If type is non-NULL, it is a suggestion for the type of file it is. Returns true if successful, false on error.
bool read | ( | Filename const | filename, |
PNMFileType | type | ||
) |
Reads the indicated image filename.
If type is non-NULL, it is a suggestion for the type of file it is. Returns true if successful, false on error.
bool read | ( | istream | data, |
string | filename, | ||
PNMFileType | type | ||
) |
Reads the image data from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
bool read | ( | istream | data, |
string | filename | ||
) |
Reads the image data from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
bool read | ( | istream | data, |
string | filename, | ||
PNMFileType | type, | ||
bool | report_unknown_type | ||
) |
Reads the image data from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
bool read | ( | PNMReader | reader | ) |
This flavor of read() uses an already-existing PNMReader to read the image file.
You can get a reader via the PNMImageHeader.make_reader() methods. This is a good way to examine the header of a file (for instance, to determine its size) before actually reading the entire image.
The PNMReader is always deleted upon completion, whether succesful or not.
bool readHeader | ( | istream | data, |
string | filename, | ||
PNMFileType | type | ||
) | [inherited] |
Reads the image header information only from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
bool readHeader | ( | Filename const | filename, |
PNMFileType | type | ||
) | [inherited] |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc.
If successful, updates the header information and returns true; otherwise, returns false.
bool readHeader | ( | istream | data | ) | [inherited] |
Reads the image header information only from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
bool readHeader | ( | Filename const | filename | ) | [inherited] |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc.
If successful, updates the header information and returns true; otherwise, returns false.
bool readHeader | ( | Filename const | filename, |
PNMFileType | type, | ||
bool | report_unknown_type | ||
) | [inherited] |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc.
If successful, updates the header information and returns true; otherwise, returns false.
bool readHeader | ( | istream | data, |
string | filename | ||
) | [inherited] |
Reads the image header information only from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
bool readHeader | ( | istream | data, |
string | filename, | ||
PNMFileType | type, | ||
bool | report_unknown_type | ||
) | [inherited] |
Reads the image header information only from the indicated stream.
The filename is advisory only, and may be used to suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup).
Returns true if successful, false on error.
static bool readMagicNumber | ( | istream | file, |
basic_stringchar | magic_number, | ||
int | num_bytes | ||
) | [static, inherited] |
Ensures that the first n bytes of the file are read into magic_number.
If magic_number is initially nonempty, assumes these represent the first few bytes already extracted. Returns true if successful, false if an end of file or error occurred before num_bytes could be read.
remixChannels | ( | Mat4 const | conv | ) |
Transforms every pixel using the operation (Ro,Go,Bo) = conv.xform_point(Ri,Gi,Bi); Input must be a color image.
removeAlpha | ( | ) |
Removes the image's alpha channel, if it exists.
Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage.
If the PNMImage is non-square, this actually renders an ellipse.
The min_radius and max_radius are in the scale 0..1, where 1.0 means the full width of the image. If min_radius == max_radius, the edge is sharp (but still antialiased); otherwise, the pixels between min_radius and max_radius are smoothly blended between fg and bg colors.
Sets the alpha component color only at the indicated pixel.
It is an error to call this unless has_alpha() is true. The value given should be in the range 0..1.
Sets the alpha component color only at the indicated pixel.
It is an error to call this unless has_alpha() is true. The value given should be in the range 0..maxval.
Sets the blue component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Sets the blue component color only at the indicated pixel.
The value given should be in the range 0..maxval.
Sets the nth component color at the indicated pixel.
The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than setting the component values directly by named methods. The value given should be a double in the range 0..1.
Sets the nth component color at the indicated pixel.
The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than setting the component values directly by named methods. The value given should be in the range 0..maxval.
setColorType | ( | ColorType | color_type | ) |
Translates the image to or from grayscale, color, or four-color mode.
Grayscale images are converted to full-color images with R, G, B set to the original gray level; color images are converted to grayscale according to the value of Bright(). The alpha channel, if added, is initialized to zero.
setComment | ( | string | comment | ) | [inherited] |
Writes a user comment string to the image (header).
Sets the gray component color at the indicated pixel.
This is only meaningful for grayscale images; for other image types, this simply sets the blue component color. However, also see set_xel(), which can set all the component colors to the same grayscale level, and hence works correctly both for grayscale and color images. The value given should be a double in the range 0..1.
Sets the gray component color at the indicated pixel.
This is only meaningful for grayscale images; for other image types, this simply sets the blue component color. However, also see set_xel_val(), which can set all the component colors to the same grayscale level, and hence works correctly both for grayscale and color images. The value given should be in the range 0..maxval.
Sets the green component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Sets the green component color only at the indicated pixel.
The value given should be in the range 0..maxval.
setMaxval | ( | unsigned short int | maxval | ) |
Rescales the image to the indicated maxval.
setNumChannels | ( | int | num_channels | ) |
Changes the number of channels associated with the image.
The new number of channels must be an integer in the range 1 through 4, inclusive. This will allocate and/or deallocate memory as necessary to accomodate; see set_color_type().
Sets the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object.
Specifies the size to we'd like to scale the image upon reading it.
This will affect the next call to read(). This is usually used to reduce the image size, e.g. for a thumbnail.
If the file type reader supports it (e.g. JPEG), then this will scale the image during the read operation, consequently reducing memory and CPU utilization. If the file type reader does not support it, this will load the image normally, and them perform a linear scale after it has been loaded.
Sets the red component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Sets the red component color only at the indicated pixel.
The value given should be in the range 0..maxval.
setType | ( | PNMFileType | type | ) | [inherited] |
Sets the file type of this PNMImage.
This will be the default type used when an image is read, if the type cannot be determined by magic number or inferred by extension, or the type used when the image is written, if the type cannot be inferred from the filename extension.
Changes all three color components at the indicated pixel to the same value.
The value is a double in the range 0..1.
Changes the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Changes the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Changes the RGBA color at the indicated pixel.
Each component is a double in the range 0..1.
Changes the RGBA color at the indicated pixel.
Each component is a double in the range 0..1.
Changes the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
Changes all three color components at the indicated pixel to the same value.
The value is in the range 0..maxval.
Changes the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
takeFrom | ( | PNMImage | orig | ) |
Move the contents of the other image into this one, and empty the other image.
threshold | ( | PNMImage const | select_image, |
int | channel, | ||
double | threshold, | ||
PNMImage const | lt, | ||
PNMImage const | ge | ||
) |
Selectively copies each pixel from either one source or another source, depending on the pixel value of the indicated channel of select_image.
For each pixel (x, y):
s = select_image.get_channel(x, y). Set this image's (x, y) to:
lt.get_xel(x, y) if s <= threshold, or
ge.get_xel(x, y) if s > threshold
Any of select_image, lt, or ge may be the same PNMImge object as this image, or the same as each other; or they may all be different. All images must be the same size.
unsigned short int toVal | ( | double | input_value | ) |
A handy function to scale values from [0..1] to [0..get_maxval()].
bool write | ( | PNMWriter | writer | ) |
This flavor of write() uses an already-existing PNMWriter to write the image file.
You can get a writer via the PNMImageHeader.make_writer() methods.
The PNMWriter is always deleted upon completion, whether succesful or not.
bool write | ( | ostream | data, |
string | filename, | ||
PNMFileType | type | ||
) |
Writes the image to the indicated ostream.
The filename is advisory only, and may be used suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of image file to write.
bool write | ( | Filename const | filename | ) |
Writes the image to the indicated filename.
If type is non-NULL, it is a suggestion for the type of image file to write.
bool write | ( | ostream | data, |
string | filename | ||
) |
Writes the image to the indicated ostream.
The filename is advisory only, and may be used suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of image file to write.
bool write | ( | Filename const | filename, |
PNMFileType | type | ||
) |
Writes the image to the indicated filename.
If type is non-NULL, it is a suggestion for the type of image file to write.
bool write | ( | ostream | data | ) |
Writes the image to the indicated ostream.
The filename is advisory only, and may be used suggest a type if it has a known extension.
If type is non-NULL, it is a suggestion for the type of image file to write.