|
|
|
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...
#include "pnmImage.h"
List of all members.
Public Member Functions |
|
| PNMImage (const Filename &filename, PNMFileType *type=NULL) |
|
| PNMImage (int x_size, int y_size, int num_channels=3, xelval maxval=255, PNMFileType *type=NULL) |
|
| PNMImage (const PNMImage ©) |
| void | add_alpha () |
| | Adds an alpha channel to the image, if it does not already have one.
|
| void | add_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, double pixel_scale=1.0) |
| | Behaves like copy_sub_image(), except the copy pixels are added to the pixels of the destination, after scaling by the specified pixel_scale.
|
| void | alpha_fill (double alpha=0.0) |
| | Sets the entire alpha channel to the given level.
|
| void | alpha_fill_val (xelval alpha=0) |
| | Sets the entire alpha channel to the given level.
|
| void | apply_exponent (double gray_exponent) |
| | Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
|
| void | apply_exponent (double gray_exponent, double alpha_exponent) |
| | Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
|
| void | apply_exponent (double red_exponent, double green_exponent, double blue_exponent) |
| | Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
|
| void | apply_exponent (double red_exponent, double green_exponent, double blue_exponent, double alpha_exponent) |
| | Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
|
| void | blend (int x, int y, const LRGBColord &val, double alpha) |
| | Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value.
|
| void | 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.
|
| void | blend_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, double pixel_scale=1.0) |
| | 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.
|
| void | box_filter (double radius=1.0) |
| | 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.
|
| void | box_filter_from (double radius, const PNMImage ©) |
| | Makes a resized copy of the indicated image into this one using the indicated filter.
|
| xelval | clamp_val (int input_value) const |
| | A handy function to clamp values to [0..get_maxval()].
|
| void | clear () |
| | Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc).
|
| void | clear (int x_size, int y_size, int num_channels=3, xelval maxval=255, PNMFileType *type=NULL) |
| | This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.
|
| void | clear_read_size () |
| | Undoes the effect of a previous call to set_read_size().
|
| void | copy_channel (const PNMImage ©, int src_channel, int dest_channel) |
| | Copies a channel from one image into another.
|
| void | copy_channel (const PNMImage ©, int xto, int yto, int cto, int xfrom=0, int yfrom=0, int cfrom=0, int x_size=-1, int y_size=-1) |
| | Copies just a single channel from the source image into a single channel of this image, leaving the remaining channels alone.
|
| void | copy_from (const PNMImage ©) |
| | Makes this image become a copy of the other image.
|
| void | copy_header_from (const PNMImageHeader &header) |
| | Copies just the header information into this image.
|
| void | copy_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1) |
| | Copies a rectangular area of another image into a rectangular area of this image.
|
| void | darken_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, double pixel_scale=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).
|
| void | do_fill_distance (int xi, int yi, int d) |
| | Recursively fills in the minimum distance measured from a certain set of points into the gray channel.
|
| void | expand_border (int left, int right, int bottom, int top, const LColord &color) |
| | Expands the image by the indicated number of pixels on each edge.
|
| void | fill (double red, double green, double blue) |
| | Sets the entire image (except the alpha channel) to the given color.
|
| void | fill (double gray=0.0) |
| | Sets the entire image (except the alpha channel) to the given grayscale level.
|
| void | fill_distance_inside (const PNMImage &mask, double threshold, int radius, bool shrink_from_border) |
| | Replaces this image with a grayscale image whose gray channel represents the linear Manhattan distance from the nearest dark pixel in the given mask image, up to the specified radius value (which also becomes the new maxval).
|
| void | fill_distance_outside (const PNMImage &mask, double threshold, int radius) |
| | Replaces this image with a grayscale image whose gray channel represents the linear Manhattan distance from the nearest white pixel in the given mask image, up to the specified radius value (which also becomes the new maxval).
|
| void | fill_val (xelval red, xelval green, xelval blue) |
| | Sets the entire image (except the alpha channel) to the given color.
|
| void | fill_val (xelval gray=0) |
| | Sets the entire image (except the alpha channel) to the given grayscale level.
|
| void | flip (bool flip_x, bool flip_y, bool transpose) |
| | Reverses, transposes, and/or rotates the image in-place according to the specified parameters.
|
| double | from_val (xelval input_value) const |
| | A handy function to scale values from [0..get_maxval()] to [0..1].
|
| void | gamma_correct (double from_gamma, double to_gamma) |
| | Assuming the image was constructed with a gamma curve of from_gamma in the RGB channels, converts it to an image with a gamma curve of to_gamma in the RGB channels.
|
| void | gamma_correct_alpha (double from_gamma, double to_gamma) |
| | Assuming the image was constructed with a gamma curve of from_gamma in the alpha channel, converts it to an image with a gamma curve of to_gamma in the alpha channel.
|
| void | gaussian_filter (double radius=1.0) |
| | 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.
|
| void | gaussian_filter_from (double radius, const PNMImage ©) |
| | Makes a resized copy of the indicated image into this one using the indicated filter.
|
| double | get_alpha (int x, int y) const |
| | Returns the alpha component color at the indicated pixel.
|
| xelval * | get_alpha_array () |
| | Directly access the underlying PNMImage array of alpha values.
|
| const xelval * | get_alpha_array () const |
| | Directly access the underlying PNMImage array of alpha values.
|
| xelval | get_alpha_val (int x, int y) const |
| | Returns the alpha component color at the indicated pixel.
|
| xel * | get_array () |
| | Directly access the underlying PNMImage array.
|
| const xel * | get_array () const |
| | Directly access the underlying PNMImage array.
|
| double | get_average_gray () const |
| | Returns the average grayscale component of all of the pixels in the image.
|
| LRGBColord | get_average_xel () const |
| | Returns the average color of all of the pixels in the image.
|
| LColord | get_average_xel_a () const |
| | Returns the average color of all of the pixels in the image, including the alpha channel.
|
| double | get_blue (int x, int y) const |
| | Returns the blue component color at the indicated pixel.
|
| xelval | get_blue_val (int x, int y) const |
| | Returns the blue component color at the indicated pixel.
|
| double | get_bright (int x, int y) const |
| | Returns the linear brightness of the given xel, as a double in the range 0..1.
|
| double | get_bright (int x, int y, double rc, double gc, double bc) const |
| | This flavor of get_bright() works correctly only for color images.
|
| double | get_bright (int x, int y, double rc, double gc, double bc, double ac) const |
| | This flavor of get_bright() works correctly only for four-channel images.
|
| double | get_channel (int x, int y, int channel) const |
| | Returns the nth component color at the indicated pixel.
|
| xelval | get_channel_val (int x, int y, int channel) const |
| | Returns the nth component color at the indicated pixel.
|
| double | get_gray (int x, int y) const |
| | Returns the gray component color at the indicated pixel.
|
| xelval | get_gray_val (int x, int y) const |
| | Returns the gray component color at the indicated pixel.
|
| double | get_green (int x, int y) const |
| | Returns the green component color at the indicated pixel.
|
| xelval | get_green_val (int x, int y) const |
| | Returns the green component color at the indicated pixel.
|
| PixelSpec | get_pixel (int x, int y) const |
| | Returns the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object.
|
| int | get_read_x_size () const |
| | 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 | get_read_y_size () const |
| | 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 | get_red (int x, int y) const |
| | Returns the red component color at the indicated pixel.
|
| xelval | get_red_val (int x, int y) const |
| | Returns the red component color at the indicated pixel.
|
| LRGBColord | get_xel (int x, int y) const |
| | Returns the RGB color at the indicated pixel.
|
| LColord | get_xel_a (int x, int y) const |
| | Returns the RGBA color at the indicated pixel.
|
| const xel & | get_xel_val (int x, int y) const |
| | Returns the RGB color at the indicated pixel.
|
| bool | has_read_size () const |
| | Returns true if set_read_size() has been called.
|
| bool | is_valid () const |
| | Returns true if the image has been read in or correctly initialized with a height and width.
|
| void | lighten_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, double pixel_scale=1.0) |
| | 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).
|
| void | make_grayscale () |
| | Converts the image from RGB to grayscale.
|
| void | make_grayscale (double rc, double gc, double bc) |
| | Converts the image from RGB to grayscale.
|
| void | make_histogram (Histogram &hist) |
| | Computes a histogram of the colors used in the image.
|
| void | make_rgb () |
| | Converts the image from grayscale to RGB.
|
| void | mult_sub_image (const PNMImage ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, double pixel_scale=1.0) |
| | Behaves like copy_sub_image(), except the copy pixels are multiplied to the pixels of the destination, after scaling by the specified pixel_scale.
|
| PNMImage | operator* (const PNMImage &other) const |
| | 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) const |
| | Multiplies every pixel value in the image by a constant floating-point multiplier value.
|
| PNMImage | operator* (const LColord &other) const |
| | Returns a new PNMImage in which the provided color is multiplied to each pixel in the provided image.
|
| void | operator*= (const PNMImage &other) |
| | Multiples each pixel in this image by each pixel value from the right image.
|
| void | operator*= (double multiplier) |
| | Multiplies every pixel value in the image by a constant floating-point multiplier value.
|
| void | operator*= (const LColord &other) |
| | Multiples the provided color to each pixel in this image.
|
| PNMImage | operator+ (const PNMImage &other) const |
| | Returns a new PNMImage in which each pixel value is the sum of the corresponding pixel values in the two given images.
|
| PNMImage | operator+ (const LColord &other) const |
| | Returns a new PNMImage in which the provided color is added to each pixel in the provided image.
|
| void | operator+= (const PNMImage &other) |
| | Sets each pixel value to the sum of the corresponding pixel values in the two given images.
|
| void | operator+= (const LColord &other) |
| | Adds the provided color to each pixel in this image.
|
| PNMImage | operator- (const PNMImage &other) const |
| | 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- (const LColord &other) const |
| | Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image.
|
| void | operator-= (const PNMImage &other) |
| | Subtracts each pixel from the right image from each pixel value in this image.
|
| void | operator-= (const LColord &other) |
| | Subtracts the provided color from each pixel in this image.
|
|
void | operator= (const PNMImage ©) |
| xel * | operator[] (int y) |
| | Allows the PNMImage to appear to be a 2-d array of xels.
|
| const xel * | operator[] (int y) const |
| | Allows the PNMImage to appear to be a 2-d array of xels.
|
| PNMImage | operator~ () const |
| | Returns a new PNMImage that is the complement of the current PNMImage.
|
| void | perlin_noise_fill (double sx, double sy, int table_size=256, unsigned long seed=0) |
| | Fills the image with a grayscale perlin noise pattern based on the indicated parameters.
|
| void | perlin_noise_fill (StackedPerlinNoise2 &perlin) |
| | Variant of perlin_noise_fill that uses an existing StackedPerlinNoise2 object.
|
| void | quick_filter_from (const PNMImage ©, int xborder=0, int yborder=0) |
| | Resizes from the given image, with a fixed radius of 0.5.
|
| bool | read (const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true) |
| | Reads the indicated image filename.
|
| bool | read (istream &data, const string &filename=string(), PNMFileType *type=NULL, bool report_unknown_type=true) |
| | Reads the image data from the indicated stream.
|
| bool | read (PNMReader *reader) |
| | This flavor of read() uses an already-existing PNMReader to read the image file.
|
| void | remix_channels (const LMatrix4 &conv) |
| | Transforms every pixel using the operation (Ro,Go,Bo) = conv.xform_point(Ri,Gi,Bi); Input must be a color image.
|
| void | remove_alpha () |
| | Removes the image's alpha channel, if it exists.
|
| void | render_spot (const LColord &fg, const LColord &bg, double min_radius, double max_radius) |
| | Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage.
|
| void | rescale (double min_val, double max_val) |
| | Rescales the RGB channel values so that any values in the original image between min_val and max_val are expanded to the range 0 .
|
| void | reverse_rows () |
| | Performs an in-place reversal of the row (y) data.
|
| void | set_alpha (int x, int y, double a) |
| | Sets the alpha component color only at the indicated pixel.
|
| void | set_alpha_array (xelval *alpha) |
| | Replaces the underlying PNMImage alpha array with the indicated pointer.
|
| void | set_alpha_val (int x, int y, xelval a) |
| | Sets the alpha component color only at the indicated pixel.
|
| void | set_array (xel *array) |
| | Replaces the underlying PNMImage array with the indicated pointer.
|
| void | set_blue (int x, int y, double b) |
| | Sets the blue component color only at the indicated pixel.
|
| void | set_blue_val (int x, int y, xelval b) |
| | Sets the blue component color only at the indicated pixel.
|
| void | set_channel (int x, int y, int channel, double value) |
| | Sets the nth component color at the indicated pixel.
|
| void | set_channel_val (int x, int y, int channel, xelval value) |
| | Sets the nth component color at the indicated pixel.
|
| void | set_color_type (ColorType color_type) |
| | Translates the image to or from grayscale, color, or four-color mode.
|
| void | set_gray (int x, int y, double gray) |
| | Sets the gray component color at the indicated pixel.
|
| void | set_gray_val (int x, int y, xelval gray) |
| | Sets the gray component color at the indicated pixel.
|
| void | set_green (int x, int y, double g) |
| | Sets the green component color only at the indicated pixel.
|
| void | set_green_val (int x, int y, xelval g) |
| | Sets the green component color only at the indicated pixel.
|
| void | set_maxval (xelval maxval) |
| | Rescales the image to the indicated maxval.
|
| void | set_num_channels (int num_channels) |
| | Changes the number of channels associated with the image.
|
| void | set_pixel (int x, int y, const PixelSpec &pixel) |
| | Sets the (r, g, b, a) pixel value at the indicated pixel, using a PixelSpec object.
|
| void | set_read_size (int x_size, int y_size) |
| | Specifies the size to we'd like to scale the image upon reading it.
|
| void | set_red (int x, int y, double r) |
| | Sets the red component color only at the indicated pixel.
|
| void | set_red_val (int x, int y, xelval r) |
| | Sets the red component color only at the indicated pixel.
|
| void | set_xel (int x, int y, const LRGBColord &value) |
| | Changes the RGB color at the indicated pixel.
|
| void | set_xel (int x, int y, double r, double g, double b) |
| | Changes the RGB color at the indicated pixel.
|
| void | set_xel (int x, int y, double gray) |
| | Changes all three color components at the indicated pixel to the same value.
|
| void | set_xel_a (int x, int y, const LColord &value) |
| | Changes the RGBA color at the indicated pixel.
|
| void | set_xel_a (int x, int y, double r, double g, double b, double a) |
| | Changes the RGBA color at the indicated pixel.
|
| void | set_xel_val (int x, int y, const xel &value) |
| | Changes the RGB color at the indicated pixel.
|
| void | set_xel_val (int x, int y, xelval r, xelval g, xelval b) |
| | Changes the RGB color at the indicated pixel.
|
| void | set_xel_val (int x, int y, xelval gray) |
| | Changes all three color components at the indicated pixel to the same value.
|
| xelval * | take_alpha_array () |
| | Returns the underlying PNMImage array and removes it from the PNMImage.
|
| xel * | take_array () |
| | Returns the underlying PNMImage array and removes it from the PNMImage.
|
| void | take_from (PNMImage &orig) |
| | Move the contents of the other image into this one, and empty the other image.
|
| void | threshold (const PNMImage &select_image, int channel, double threshold, const PNMImage <, const PNMImage &ge) |
| | Selectively copies each pixel from either one source or another source, depending on the pixel value of the indicated channel of select_image.
|
| xelval | to_val (double input_value) const |
| | A handy function to scale values from [0..1] to [0..get_maxval()].
|
| bool | write (const Filename &filename, PNMFileType *type=NULL) const |
| | Writes the image to the indicated filename.
|
| bool | write (ostream &data, const string &filename=string(), PNMFileType *type=NULL) const |
| | Writes the image to the indicated ostream.
|
| bool | write (PNMWriter *writer) const |
| | This flavor of write() uses an already-existing PNMWriter to write the image file.
|
Detailed Description
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.
Definition at line 57 of file pnmImage.h.
Member Function Documentation
| void PNMImage::add_sub_image |
( |
const PNMImage & |
copy, |
|
|
int |
xto, |
|
|
int |
yto, |
|
|
int |
xfrom = 0, |
|
|
int |
yfrom = 0, |
|
|
int |
x_size = -1, |
|
|
int |
y_size = -1, |
|
|
double |
pixel_scale = 1.0 |
|
) |
| |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
Definition at line 883 of file pnmImage.I.
References apply_exponent().
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
For a grayscale image, the blue_exponent value is used for the grayscale value, and red_exponent and green_exponent are unused.
Definition at line 898 of file pnmImage.I.
References apply_exponent().
| void PNMImage::apply_exponent |
( |
double |
red_exponent, |
|
|
double |
green_exponent, |
|
|
double |
blue_exponent, |
|
|
double |
alpha_exponent |
|
) |
| |
Adjusts each channel of the image by raising the corresponding component value to the indicated exponent, such that L' = L ^ exponent.
For a grayscale image, the blue_exponent value is used for the grayscale value, and red_exponent and green_exponent are unused.
Definition at line 1799 of file pnmImage.cxx.
References get_alpha(), get_gray(), get_xel(), get_xel_a(), PNMImageHeader::has_alpha(), set_alpha(), set_gray(), set_xel(), and set_xel_a().
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.
Definition at line 787 of file pnmImage.I.
Referenced by blend_sub_image().
| void PNMImage::blend |
( |
int |
x, |
|
|
int |
y, |
|
|
double |
r, |
|
|
double |
g, |
|
|
double |
b, |
|
|
double |
alpha |
|
) |
| |
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.
Definition at line 821 of file pnmImage.I.
References box_filter_from().
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.
Definition at line 537 of file pnm-image-filter.cxx.
Referenced by box_filter().
Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc).
Definition at line 50 of file pnmImage.cxx.
Referenced by clear(), GeoMipTerrain::clear_color_map(), copy_from(), copy_header_from(), PfmVizzer::make_displacement(), read(), TextureImage::release_source_image(), PfmFile::store(), PfmFile::store_mask(), and take_from().
| void PNMImage::copy_channel |
( |
const PNMImage & |
copy, |
|
|
int |
xto, |
|
|
int |
yto, |
|
|
int |
cto, |
|
|
int |
xfrom = 0, |
|
|
int |
yfrom = 0, |
|
|
int |
cfrom = 0, |
|
|
int |
x_size = -1, |
|
|
int |
y_size = -1 |
|
) |
| |
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.
Definition at line 884 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), PNMImageHeader::get_maxval(), get_xel(), get_xel_val(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
Referenced by blend_sub_image(), Texture::do_read_one(), and expand_border().
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.
Definition at line 1063 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), PNMImageHeader::get_maxval(), get_xel(), get_xel_val(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
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.
Definition at line 1686 of file pnmImage.cxx.
References alpha_fill(), copy_sub_image(), fill(), PNMImageHeader::get_maxval(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_type(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), and take_from().
| void PNMImage::fill |
( |
double |
red, |
|
|
double |
green, |
|
|
double |
blue |
|
) |
| [inline] |
Sets the entire image (except the alpha channel) to the given grayscale level.
Definition at line 129 of file pnmImage.I.
References fill().
Replaces this image with a grayscale image whose gray channel represents the linear Manhattan distance from the nearest dark pixel in the given mask image, up to the specified radius value (which also becomes the new maxval).
radius may range from 0 to maxmaxval; smaller values will compute faster. A dark pixel is defined as one whose pixel value is < threshold.
If shrink_from_border is true, then the mask image is considered to be surrounded by a border of dark pixels; otherwise, the border isn't considered.
This can be used, in conjunction with threshold, to shrink a mask image inwards by a certain number of pixels.
The mask image may be the same image as this one, in which case it is destructively modified by this process.
Definition at line 1433 of file pnmImage.cxx.
References fill_val(), get_gray_val(), PNMImageHeader::get_maxval(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and take_from().
Replaces this image with a grayscale image whose gray channel represents the linear Manhattan distance from the nearest white pixel in the given mask image, up to the specified radius value (which also becomes the new maxval).
radius may range from 0 to maxmaxval; smaller values will compute faster. A white pixel is defined as one whose pixel value is >= threshold.
This can be used, in conjunction with threshold, to grow a mask image outwards by a certain number of pixels.
The mask image may be the same image as this one, in which case it is destructively modified by this process.
Definition at line 1483 of file pnmImage.cxx.
References fill_val(), get_gray_val(), PNMImageHeader::get_maxval(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and take_from().
Sets the entire image (except the alpha channel) to the given grayscale level.
Definition at line 140 of file pnmImage.I.
References fill_val().
Reverses, transposes, and/or rotates the image in-place according to the specified parameters.
If flip_x is true, the x axis is reversed; if flip_y is true, the y axis is reversed. Then, if transpose is true, the x and y axes are exchanged. These parameters can be used to select any combination of 90-degree or 180-degree rotations and flips.
Definition at line 562 of file pnmImage.cxx.
Assuming the image was constructed with a gamma curve of from_gamma in the RGB channels, converts it to an image with a gamma curve of to_gamma in the RGB channels.
Does not affect the alpha channel.
Definition at line 846 of file pnmImage.I.
References apply_exponent().
Assuming the image was constructed with a gamma curve of from_gamma in the alpha channel, converts it to an image with a gamma curve of to_gamma in the alpha channel.
Does not affect the RGB channels.
Definition at line 859 of file pnmImage.I.
References apply_exponent().
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.
Definition at line 551 of file pnm-image-filter.cxx.
Referenced by gaussian_filter().
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.
Definition at line 631 of file pnmImage.I.
References from_val(), and get_alpha_val().
Referenced by add_sub_image(), apply_exponent(), blend(), blend_sub_image(), copy_sub_image(), osxGraphicsPipe::create_cg_image(), darken_sub_image(), Texture::do_read_one(), lighten_sub_image(), PfmFile::load(), mult_sub_image(), PNMTextGlyph::place(), ImageFile::read(), and threshold().
Directly access the underlying PNMImage array of alpha values.
Know what you are doing!
Definition at line 943 of file pnmImage.I.
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.
Definition at line 399 of file pnmImage.I.
Referenced by copy_channel(), copy_sub_image(), darken_sub_image(), get_alpha(), get_bright(), get_channel_val(), get_pixel(), get_xel_a(), lighten_sub_image(), set_maxval(), threshold(), and ImageFile::write().
Directly access the underlying PNMImage array.
Know what you are doing!
Definition at line 921 of file pnmImage.I.
Returns the average grayscale component of all of the pixels in the image.
Definition at line 1983 of file pnmImage.cxx.
References get_gray().
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.
Definition at line 742 of file pnmImage.I.
Referenced by make_grayscale(), and set_color_type().
| double PNMImage::get_bright |
( |
int |
x, |
|
|
int |
y, |
|
|
double |
rc, |
|
|
double |
gc, |
|
|
double |
bc, |
|
|
double |
ac |
|
) |
| const [inline] |
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.
Definition at line 713 of file pnmImage.I.
References from_val(), and get_channel_val().
Referenced by copy_channel().
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.
Definition at line 689 of file pnmImage.cxx.
References get_alpha_val(), get_blue_val(), get_green_val(), PNMImageHeader::get_num_channels(), and get_red_val().
Referenced by copy_channel(), Texture::do_read_one(), get_channel(), ImageFile::read(), and threshold().
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.
Definition at line 618 of file pnmImage.I.
References from_val(), and get_gray_val().
Referenced by apply_exponent(), GeoMipTerrain::calc_ambient_occlusion(), osxGraphicsPipe::create_cg_image(), Texture::do_read_one(), get_average_gray(), HeightfieldTesselator::get_elevation(), PfmFile::load(), ImageFile::read(), and rescale().
Returns the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 482 of file pnmImage.I.
References from_val(), get_blue_val(), get_green_val(), and get_red_val().
Referenced by add_sub_image(), apply_exponent(), blend(), blend_sub_image(), copy_sub_image(), darken_sub_image(), get_average_xel(), lighten_sub_image(), PfmFile::load(), mult_sub_image(), PNMTextGlyph::place(), ImageTransformColors::process_image(), rescale(), and threshold().
Returns true if the image has been read in or correctly initialized with a height and width.
If this returns false, virtually all member functions except clear() and read() are invalid function calls.
Definition at line 230 of file pnmImage.I.
Referenced by alpha_fill_val(), Texture::consider_rescale(), DestTextureImage::copy(), copy_channel(), copy_from(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), fill_val(), PfmFile::load(), PNMTextGlyph::place(), STBasicTerrain::read_height_map(), and write().
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.
Definition at line 1133 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), PNMImageHeader::get_maxval(), get_xel(), get_xel_val(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
| void PNMImage::mult_sub_image |
( |
const PNMImage & |
copy, |
|
|
int |
xto, |
|
|
int |
yto, |
|
|
int |
xfrom = 0, |
|
|
int |
yfrom = 0, |
|
|
int |
x_size = -1, |
|
|
int |
y_size = -1, |
|
|
double |
pixel_scale = 1.0 |
|
) |
| |
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.
Definition at line 1166 of file pnmImage.I.
| PNMImage PNMImage::operator* |
( |
double |
multiplier | ) |
const [inline] |
Multiplies every pixel value in the image by a constant floating-point multiplier value.
Definition at line 1179 of file pnmImage.I.
Returns a new PNMImage in which the provided color is multiplied to each pixel in the provided image.
Definition at line 1192 of file pnmImage.I.
| void PNMImage::operator*= |
( |
const PNMImage & |
other | ) |
|
Multiples each pixel in this image 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.
Definition at line 2153 of file pnmImage.cxx.
References from_val(), and to_val().
| void PNMImage::operator*= |
( |
double |
multiplier | ) |
|
Multiplies every pixel value in the image by a constant floating-point multiplier value.
Definition at line 2184 of file pnmImage.cxx.
References clamp_val().
| void PNMImage::operator*= |
( |
const LColord & |
other | ) |
|
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.
Definition at line 1108 of file pnmImage.I.
Returns a new PNMImage in which the provided color is added to each pixel in the provided image.
Definition at line 1121 of file pnmImage.I.
| void PNMImage::operator+= |
( |
const PNMImage & |
other | ) |
|
Sets each pixel value to the sum of the corresponding pixel values in the two given images.
Only valid when both images have the same size.
Definition at line 2040 of file pnmImage.cxx.
References clamp_val().
| void PNMImage::operator+= |
( |
const LColord & |
other | ) |
|
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.
Definition at line 1136 of file pnmImage.I.
Returns a new PNMImage in which the provided color is subtracted from each pixel in the provided image.
Definition at line 1149 of file pnmImage.I.
| void PNMImage::operator-= |
( |
const PNMImage & |
other | ) |
|
Subtracts each pixel from the right image from each pixel value in this image.
Only valid when both images have the same size.
Definition at line 2107 of file pnmImage.cxx.
References clamp_val().
| void PNMImage::operator-= |
( |
const LColord & |
other | ) |
|
Subtracts the provided color from each pixel in this image.
Definition at line 2139 of file pnmImage.cxx.
| xel * PNMImage::operator[] |
( |
int |
y | ) |
[inline] |
| const xel * PNMImage::operator[] |
( |
int |
y | ) |
const [inline] |
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.
Definition at line 1738 of file pnmImage.cxx.
References PerlinNoise2::noise(), and set_xel().
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.
Definition at line 790 of file pnm-image-filter.cxx.
References Thread::consider_yield(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), and set_alpha_val().
Referenced by Texture::consider_rescale(), DestTextureImage::copy(), Texture::do_load_one(), Texture::do_read_one(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), Texture::generate_simple_ram_image(), and read().
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.
Definition at line 238 of file pnmImage.cxx.
References clear(), and PNMImageHeader::make_reader().
Referenced by Texture::do_read_one(), osxGraphicsStateGuardian::draw_resize_box(), ImageReader::handle_args(), PfmFile::read(), ImageFile::read(), read(), GeoMipTerrain::set_color_map(), GeoMipTerrain::set_heightfield(), and HeightfieldTesselator::set_heightfield().
| bool PNMImage::read |
( |
istream & |
data, |
|
|
const string & |
filename = string(), |
|
|
PNMFileType * |
type = NULL, |
|
|
bool |
report_unknown_type = true |
|
) |
| |
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.
Definition at line 263 of file pnmImage.cxx.
References clear(), PNMImageHeader::make_reader(), and read().
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 successful or not.
Definition at line 288 of file pnmImage.cxx.
References clear(), copy_header_from(), PNMImageHeader::get_maxval(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_type(), has_read_size(), PNMReader::is_floating_point(), PNMReader::is_valid(), PNMReader::prepare_read(), quick_filter_from(), PNMReader::read_data(), PNMReader::read_pfm(), PNMReader::set_read_size(), PfmFile::store(), and take_from().
Transforms every pixel using the operation (Ro,Go,Bo) = conv.xform_point(Ri,Gi,Bi); Input must be a color image.
Definition at line 1776 of file pnmImage.cxx.
References get_blue(), get_green(), PNMImageHeader::get_num_channels(), get_red(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), set_xel(), and LMatrix4f::xform_point().
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.
Definition at line 1604 of file pnmImage.cxx.
References set_xel_a().
Performs an in-place reversal of the row (y) data.
Definition at line 528 of file pnmImage.cxx.
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.
Definition at line 697 of file pnmImage.I.
References set_alpha_val(), and to_val().
Referenced by add_sub_image(), apply_exponent(), blend(), copy_sub_image(), darken_sub_image(), Texture::do_read_one(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), lighten_sub_image(), mult_sub_image(), PNMTextGlyph::place(), ImageFile::read(), PfmFile::store(), and threshold().
Replaces the underlying PNMImage alpha array with the indicated pointer.
Know what you are doing! The new array must be the correct size and must have been allocated via PANDA_MALLOC_ARRAY(). The PNMImage object becomes the owner of this pointer and will eventually free it with PANDA_FREE_ARRAY(). The previous array, if any, will be freed with PANDA_FREE_ARRAY() when this call is made.
Definition at line 865 of file pnmImage.cxx.
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.
Definition at line 470 of file pnmImage.I.
Referenced by alpha_fill_val(), copy_channel(), copy_sub_image(), darken_sub_image(), TexturePlacement::flag_error_image(), lighten_sub_image(), quick_filter_from(), set_alpha(), set_channel_val(), set_maxval(), set_pixel(), set_xel_a(), and threshold().
Replaces the underlying PNMImage array with the indicated pointer.
Know what you are doing! The new array must be the correct size and must have been allocated via PANDA_MALLOC_ARRAY(). The PNMImage object becomes the owner of this pointer and will eventually free it with PANDA_FREE_ARRAY(). The previous array, if any, will be freed with PANDA_FREE_ARRAY() when this call is made.
Definition at line 845 of file pnmImage.cxx.
Sets the blue component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Definition at line 667 of file pnmImage.I.
References set_blue_val(), and to_val().
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.
Definition at line 729 of file pnmImage.I.
References set_channel_val(), and to_val().
Referenced by copy_channel().
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.
Definition at line 457 of file pnmImage.cxx.
References get_bright(), PNMImageHeader::get_color_type(), get_gray_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), set_gray(), and set_xel_val().
Referenced by add_alpha(), make_rgb(), remove_alpha(), and set_num_channels().
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.
Definition at line 684 of file pnmImage.I.
References set_gray_val(), and to_val().
Referenced by apply_exponent(), make_grayscale(), rescale(), set_color_type(), PfmFile::store(), and PfmFile::store_mask().
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.
Definition at line 456 of file pnmImage.I.
Referenced by do_fill_distance(), set_gray(), set_maxval(), and ImageFile::write().
Sets the green component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Definition at line 655 of file pnmImage.I.
References set_green_val(), and to_val().
Rescales the image to the indicated maxval.
Definition at line 643 of file pnmImage.cxx.
References get_alpha_val(), get_blue_val(), get_gray_val(), get_green_val(), get_red_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), PNMImageHeader::is_grayscale(), set_alpha_val(), set_blue_val(), set_gray_val(), set_green_val(), and set_red_val().
Referenced by GeoMipTerrain::calc_ambient_occlusion().
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 accommodate; see set_color_type().
Definition at line 244 of file pnmImage.I.
References set_color_type().
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.
Definition at line 170 of file pnmImage.I.
Referenced by Texture::consider_rescale(), Texture::do_read_one(), and GeoMipTerrain::set_heightfield().
Sets the red component color only at the indicated pixel.
The value given should be a double in the range 0..1.
Definition at line 643 of file pnmImage.I.
References set_red_val(), and to_val().
Changes the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 495 of file pnmImage.I.
References set_xel_val(), and to_val().
Referenced by add_sub_image(), apply_exponent(), blend(), GeoMipTerrain::calc_ambient_occlusion(), copy_sub_image(), darken_sub_image(), TexturePlacement::fill_image(), TexturePlacement::fill_swapped_image(), lighten_sub_image(), GeoMipTerrain::make_slope_image(), mult_sub_image(), perlin_noise_fill(), PNMTextGlyph::place(), ImageTransformColors::process_image(), remix_channels(), rescale(), PfmFile::store(), and threshold().
Changes the RGB color at the indicated pixel.
Each component is a double in the range 0..1.
Definition at line 506 of file pnmImage.I.
References set_xel_val(), and to_val().
Changes all three color components at the indicated pixel to the same value.
The value is a double in the range 0..1.
Definition at line 518 of file pnmImage.I.
References set_xel_val(), and to_val().
Changes the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
Definition at line 312 of file pnmImage.I.
Referenced by copy_sub_image(), darken_sub_image(), fill_val(), TexturePlacement::flag_error_image(), lighten_sub_image(), PfmVizzer::make_displacement(), set_color_type(), set_pixel(), set_xel(), set_xel_a(), and threshold().
Changes the RGB color at the indicated pixel.
Each component is in the range 0..maxval.
Definition at line 324 of file pnmImage.I.
Changes all three color components at the indicated pixel to the same value.
The value is in the range 0..maxval.
Definition at line 337 of file pnmImage.I.
Returns the underlying PNMImage array and removes it from the PNMImage.
You become the owner of this array and must eventually free it with PANDA_FREE_ARRAY() (or pass it to another PNMImage with set_alpha_array()). Know what you are doing!
Definition at line 973 of file pnmImage.I.
Returns the underlying PNMImage array and removes it from the PNMImage.
You become the owner of this array and must eventually free it with PANDA_FREE_ARRAY() (or pass it to another PNMImage with set_array()). Know what you are doing!
Definition at line 957 of file pnmImage.I.
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. As a special case, lt and ge may both be 1x1 images instead of the source image size.
Definition at line 1213 of file pnmImage.cxx.
References get_alpha(), get_alpha_val(), get_channel_val(), PNMImageHeader::get_maxval(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_x_size(), get_xel(), get_xel_val(), PNMImageHeader::get_y_size(), PNMImageHeader::has_alpha(), set_alpha(), set_alpha_val(), set_xel(), and set_xel_val().
A handy function to scale values from [0..1] to [0..get_maxval()].
Definition at line 96 of file pnmImage.I.
References clamp_val(), and PNMImageHeader::get_maxval().
Referenced by alpha_fill(), fill(), operator*=(), set_alpha(), set_blue(), set_channel(), set_gray(), set_green(), set_red(), set_xel(), and set_xel_a().
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.
Definition at line 379 of file pnmImage.cxx.
References is_valid(), PNMImageHeader::make_writer(), and write().
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 successful or not.
Definition at line 404 of file pnmImage.cxx.
References PNMWriter::copy_header_from(), get_gray_val(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), PNMImageHeader::is_grayscale(), is_valid(), PfmFile::load(), PNMWriter::supports_grayscale(), PNMWriter::supports_integer(), PNMWriter::write_data(), and PNMWriter::write_pfm().
The documentation for this class was generated from the following files:
| | |