Panda3D
|
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component. More...
#include "pfmFile.h"
Public Member Functions | |
PfmFile (const PfmFile ©) | |
void | add_sub_image (const PfmFile ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float 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. More... | |
void | apply_crop (int x_begin, int x_end, int y_begin, int y_end) |
Reduces the PFM file to the cells in the rectangle bounded by (x_begin, x_end, y_begin, y_end), where the _end cells are not included. More... | |
void | box_filter_from (float radius, const PfmFile ©) |
Makes a resized copy of the indicated image into this one using the indicated filter. More... | |
bool | calc_autocrop (int &x_begin, int &x_end, int &y_begin, int &y_end) const |
Computes the minimum range of x and y across the PFM file that include all points. More... | |
bool | calc_autocrop (LVecBase4f &range) const |
Computes the minimum range of x and y across the PFM file that include all points. More... | |
bool | calc_autocrop (LVecBase4d &range) const |
Computes the minimum range of x and y across the PFM file that include all points. More... | |
bool | calc_average_point (LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 radius) const |
Computes the unweighted average point of all points within the box centered at (x, y) with the indicated Manhattan-distance radius. More... | |
bool | calc_bilinear_point (LPoint3f &result, PN_float32 x, PN_float32 y) const |
Computes the weighted average of the four nearest points to the floating-point index (x, y). More... | |
bool | calc_min_max (LVecBase3f &min_points, LVecBase3f &max_points) const |
Calculates the minimum and maximum x, y, and z depth component values, representing the bounding box of depth values, and places them in the indicated vectors. More... | |
bool | calc_tight_bounds (LPoint3f &min_point, LPoint3f &max_point) const |
Calculates the minimum and maximum vertices of all points within the table. More... | |
void | clear () |
Eliminates all data in the file. More... | |
void | clear (int x_size, int y_size, int num_channels) |
Resets to an empty table with a specific size. More... | |
void | clear_no_data_value () |
Removes the special value that means "no data" when it appears in the pfm file. More... | |
void | clear_to_texcoords (int x_size, int y_size) |
Replaces this PfmFile with a new PfmFile of size x_size x y_size x 3, containing the x y 0 values in the range 0 . More... | |
void | compute_sample_point (LPoint3f &result, PN_float32 x, PN_float32 y, PN_float32 sample_radius) const |
void | copy_channel (int to_channel, const PfmFile &other, int from_channel) |
Copies just the specified channel values from the indicated PfmFile (which could be same as this PfmFile) into the specified channel of this one. More... | |
void | copy_channel_masked (int to_channel, const PfmFile &other, int from_channel) |
Copies just the specified channel values from the indicated PfmFile, but only where the other file has a data point. More... | |
void | copy_sub_image (const PfmFile ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1) |
void | divide_sub_image (const PfmFile ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float pixel_scale=1.0) |
Behaves like copy_sub_image(), except the copy pixels are divided into the pixels of the destination, after scaling by the specified pixel_scale. More... | |
void | fill (PN_float32 value) |
Fills the table with all of the same value. More... | |
void | fill (const LPoint2f &value) |
Fills the table with all of the same value. More... | |
void | fill (const LPoint3f &value) |
Fills the table with all of the same value. More... | |
void | fill (const LPoint4f &value) |
Fills the table with all of the same value. More... | |
void | fill_channel (int channel, PN_float32 value) |
Fills the indicated channel with all of the same value, leaving the other channels unchanged. More... | |
void | fill_channel_masked (int channel, PN_float32 value) |
Fills the indicated channel with all of the same value, but only where the table already has a data point. More... | |
void | fill_channel_masked_nan (int channel) |
Fills the indicated channel with NaN, but only where the table already has a data point. More... | |
void | fill_channel_nan (int channel) |
Fills the indicated channel with NaN, leaving the other channels unchanged. More... | |
void | fill_nan () |
Fills the table with all NaN. More... | |
void | fill_no_data_value () |
Fills the table with the current no_data value, so that the table is empty. More... | |
void | flip (bool flip_x, bool flip_y, bool transpose) |
Reverses, transposes, and/or rotates the table in-place according to the specified parameters. More... | |
void | forward_distort (const PfmFile &dist, PN_float32 scale_factor=1.0) |
Applies the distortion indicated in the supplied dist map to the current map. More... | |
void | gaussian_filter_from (float radius, const PfmFile ©) |
Makes a resized copy of the indicated image into this one using the indicated filter. More... | |
PN_float32 | get_channel (int x, int y, int c) const |
Returns the cth channel of the point value at the indicated point. More... | |
const LPoint4f & | get_no_data_value () const |
If has_no_data_value() returns true, this returns the particular "no data" value. More... | |
const LPoint3f & | get_point (int x, int y) const |
Returns the 3-component point value at the indicated point. More... | |
PN_float32 | get_point1 (int x, int y) const |
Returns the 1-component point value at the indicated point. More... | |
const LPoint2f & | get_point2 (int x, int y) const |
Returns the 2-component point value at the indicated point. More... | |
const LPoint3f & | get_point3 (int x, int y) const |
Returns the 3-component point value at the indicated point. More... | |
const LPoint4f & | get_point4 (int x, int y) const |
Returns the 4-component point value at the indicated point. More... | |
PN_float32 | get_scale () const |
The "scale" is reported in the pfm header and is probably meaningless. More... | |
const vector_float & | get_table () const |
bool | has_no_data_threshold () const |
Returns whether a "no data" threshold value has been established by set_no_data_threshold(). More... | |
bool | has_no_data_value () const |
Returns whether a "no data" value has been established by set_no_data_value(). More... | |
bool | has_point (int x, int y) const |
Returns true if there is a valid point at x, y. More... | |
bool | is_column_empty (int x, int y_begin, int y_end) const |
Returns true if all of the points on column x, from [y_begin, y_end), are the no_data value, or false if any one of these points has a value. More... | |
bool | is_row_empty (int y, int x_begin, int x_end) const |
Returns true if all of the points on row y, in the range [x_begin, x_end), are the no_data value, or false if any one of these points has a value. More... | |
bool | is_valid () const |
bool | load (const PNMImage &pnmimage) |
Fills the PfmFile with the data from the indicated PNMImage, converted to floating-point values. More... | |
void | merge (const PfmFile &other) |
Wherever there is missing data in this PfmFile (that is, wherever has_point() returns false), copy data from the other PfmFile, which must be exactly the same dimensions as this one. More... | |
LPoint3f & | modify_point (int x, int y) |
Returns a modifiable 3-component point value at the indicated point. More... | |
LPoint2f & | modify_point2 (int x, int y) |
Returns a modifiable 2-component point value at the indicated point. More... | |
LPoint3f & | modify_point3 (int x, int y) |
Returns a modifiable 3-component point value at the indicated point. More... | |
LPoint4f & | modify_point4 (int x, int y) |
Returns a modifiable 4-component point value at the indicated point. More... | |
void | mult_sub_image (const PfmFile ©, int xto, int yto, int xfrom=0, int yfrom=0, int x_size=-1, int y_size=-1, float 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. More... | |
void | operator*= (float multiplier) |
Multiplies every point value in the image by a constant floating-point multiplier value. More... | |
void | operator= (const PfmFile ©) |
void | output (ostream &out) const |
PT (BoundingHexahedron) compute_planar_bounds(const LPoint2f ¢er | |
PT (BoundingHexahedron) compute_planar_bounds(const LPoint2d ¢er | |
int | pull_spot (const LPoint4f &delta, float xc, float yc, float xr, float yr, float exponent) |
Applies delta * t to the point values within radius (xr, yr) distance of (xc, yc). More... | |
void | quick_filter_from (const PfmFile ©) |
Resizes from the given image, with a fixed radius of 0.5. More... | |
bool | read (const Filename &fullpath) |
Reads the PFM data from the indicated file, returning true on success, false on failure. More... | |
bool | read (istream &in, const Filename &fullpath=Filename()) |
Reads the PFM data from the indicated stream, returning true on success, false on failure. More... | |
bool | read (PNMReader *reader) |
Reads the PFM data using the indicated PNMReader. More... | |
void | resize (int new_x_size, int new_y_size) |
Applies a simple filter to resample the pfm file in-place to the indicated size. More... | |
void | reverse_distort (const PfmFile &dist, PN_float32 scale_factor=1.0) |
Applies the distortion indicated in the supplied dist map to the current map. More... | |
void | reverse_rows () |
Performs an in-place reversal of the row (y) data. More... | |
void | set_channel (int x, int y, int c, PN_float32 value) |
Replaces the cth channel of the point value at the indicated point. More... | |
void | set_no_data_chan4 (bool chan4) |
Sets the no_data_chan4 flag. More... | |
void | set_no_data_nan (int num_channels) |
Sets the no_data_nan flag. More... | |
void | set_no_data_threshold (const LPoint4f &no_data_value) |
Sets the special threshold value. More... | |
void | set_no_data_threshold (const LPoint4d &no_data_value) |
Sets the special threshold value. More... | |
void | set_no_data_value (const LPoint4f &no_data_value) |
Sets the special value that means "no data" when it appears in the pfm file. More... | |
void | set_no_data_value (const LPoint4d &no_data_value) |
Sets the special value that means "no data" when it appears in the pfm file. More... | |
void | set_point (int x, int y, const LVecBase3f &point) |
Replaces the 3-component point value at the indicated point. More... | |
void | set_point (int x, int y, const LVecBase3d &point) |
Replaces the 3-component point value at the indicated point. More... | |
void | set_point1 (int x, int y, PN_float32 point) |
Replaces the 1-component point value at the indicated point. More... | |
void | set_point2 (int x, int y, const LVecBase2f &point) |
Replaces the 2-component point value at the indicated point. More... | |
void | set_point2 (int x, int y, const LVecBase2d &point) |
Replaces the 2-component point value at the indicated point. More... | |
void | set_point3 (int x, int y, const LVecBase3f &point) |
Replaces the 3-component point value at the indicated point. More... | |
void | set_point3 (int x, int y, const LVecBase3d &point) |
Replaces the 3-component point value at the indicated point. More... | |
void | set_point4 (int x, int y, const LVecBase4f &point) |
Replaces the 4-component point value at the indicated point. More... | |
void | set_point4 (int x, int y, const LVecBase4d &point) |
Replaces the 4-component point value at the indicated point. More... | |
void | set_scale (PN_float32 scale) |
The "scale" is reported in the pfm header and is probably meaningless. More... | |
void | set_zero_special (bool zero_special) |
Sets the zero_special flag. More... | |
bool | store (PNMImage &pnmimage) const |
Copies the data to the indicated PNMImage, converting to RGB values. More... | |
bool | store_mask (PNMImage &pnmimage) const |
Stores 1 or 0 values into the indicated PNMImage, according to has_point() for each pixel. More... | |
void | swap_table (vector_float &table) |
bool | write (const Filename &fullpath) |
Writes the PFM data to the indicated file, returning true on success, false on failure. More... | |
bool | write (ostream &out, const Filename &fullpath=Filename()) |
Writes the PFM data to the indicated stream, returning true on success, false on failure. More... | |
bool | write (PNMWriter *writer) |
Writes the PFM data using the indicated PNMWriter. More... | |
void | xform (const LMatrix4f &transform) |
Applies the indicated transform matrix to all points in-place. More... | |
void | xform (const LMatrix4d &transform) |
Applies the indicated transform matrix to all points in-place. More... | |
![]() | |
PNMImageHeader (const PNMImageHeader ©) | |
ColorSpace | get_color_space () const |
Returns the color space that the image is encoded in, or CS_unspecified if unknown. More... | |
ColorType | get_color_type () const |
Returns the image type of the image, as an enumerated value. More... | |
string | get_comment () const |
Gets the user comment from the file. More... | |
xelval | get_maxval () const |
Returns the maximum channel value allowable for any pixel in this image; for instance, 255 for a typical 8-bit-per-channel image. More... | |
int | get_num_channels () const |
Returns the number of channels in the image. More... | |
PNMFileType * | get_type () const |
If the file type is known (e.g. More... | |
int | get_x_size () const |
Returns the number of pixels in the X direction. More... | |
int | get_y_size () const |
Returns the number of pixels in the Y direction. More... | |
bool | has_alpha () const |
Returns true if the image includes an alpha channel, false otherwise. More... | |
bool | has_type () const |
Returns true if the PNMImageHeader knows what type it is, false otherwise. More... | |
bool | is_grayscale () const |
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. More... | |
PNMReader * | make_reader (const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true) const |
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. More... | |
PNMReader * | make_reader (istream *file, bool owns_file=true, const Filename &filename=Filename(), string magic_number=string(), PNMFileType *type=NULL, bool report_unknown_type=true) const |
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. More... | |
PNMWriter * | make_writer (const Filename &filename, PNMFileType *type=NULL) const |
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. More... | |
PNMWriter * | make_writer (ostream *file, bool owns_file=true, const Filename &filename=Filename(), PNMFileType *type=NULL) const |
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. More... | |
void | operator= (const PNMImageHeader ©) |
void | output (ostream &out) const |
bool | read_header (const Filename &filename, PNMFileType *type=NULL, bool report_unknown_type=true) |
Opens up the image file and tries to read its header information to determine its size, number of channels, etc. More... | |
bool | read_header (istream &data, const string &filename=string(), PNMFileType *type=NULL, bool report_unknown_type=true) |
Reads the image header information only from the indicated stream. More... | |
void | set_comment (const string &comment) |
Writes a user comment string to the image (header). More... | |
void | set_type (PNMFileType *type) |
Sets the file type of this PNMImage. More... | |
Public Attributes | |
PN_float32 PN_float32 bool points_only | const |
PN_float32 | point_dist |
PN_float32 PN_float32 | sample_radius |
Friends | |
class | PfmVizzer |
Additional Inherited Members | |
![]() | |
enum | ColorType { CT_invalid = 0, CT_grayscale = 1, CT_two_channel = 2, CT_color = 3, CT_four_channel = 4 } |
typedef pmap< PixelSpec, int > | HistMap |
typedef pvector< PixelSpec > | Palette |
typedef pvector< PixelSpecCount > | PixelCount |
![]() | |
static bool | has_alpha (ColorType color_type) |
This static variant of has_alpha() returns true if the indicated image type includes an alpha channel, false otherwise. More... | |
static bool | is_grayscale (ColorType color_type) |
This static variant of is_grayscale() returns true if the indicated image type represents a grayscale image, false otherwise. More... | |
static bool | read_magic_number (istream *file, string &magic_number, int num_bytes) |
Ensures that the first n bytes of the file are read into magic_number. More... | |
Defines a pfm file, a 2-d table of floating-point numbers, either 3-component or 1-component, or with a special extension, 2- or 4-component.
void PfmFile::add_sub_image | ( | const PfmFile & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 , |
||
float | 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.
Definition at line 1955 of file pfmFile.cxx.
References get_point1(), get_point2(), get_point3(), get_point4(), has_point(), and mult_sub_image().
Referenced by calc_tight_bounds().
void PfmFile::apply_crop | ( | int | x_begin, |
int | x_end, | ||
int | y_begin, | ||
int | y_end | ||
) |
Reduces the PFM file to the cells in the rectangle bounded by (x_begin, x_end, y_begin, y_end), where the _end cells are not included.
Definition at line 1521 of file pfmFile.cxx.
References clear_to_texcoords().
Referenced by copy_channel_masked(), and PfmTrans::process_pfm().
void PfmFile::box_filter_from | ( | float | width, |
const PfmFile & | 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.
Definition at line 663 of file pnm-image-filter.cxx.
References gaussian_filter_from().
Referenced by PNMImage::gaussian_filter_from(), and resize().
bool PfmFile::calc_autocrop | ( | int & | x_begin, |
int & | x_end, | ||
int & | y_begin, | ||
int & | y_end | ||
) | const |
Computes the minimum range of x and y across the PFM file that include all points.
If there are no points with no_data_value in the grid–that is, all points are included–then this will return (0, get_x_size(), 0, get_y_size()).
Definition at line 800 of file pfmFile.cxx.
References is_row_empty().
Referenced by calc_autocrop(), calc_min_max(), fill(), and PfmTrans::process_pfm().
|
inline |
Computes the minimum range of x and y across the PFM file that include all points.
If there are no points with no_data_value in the grid–that is, all points are included–then this will return (0, get_x_size(), 0, get_y_size()).
Definition at line 425 of file pfmFile.I.
References calc_autocrop().
|
inline |
Computes the minimum range of x and y across the PFM file that include all points.
If there are no points with no_data_value in the grid–that is, all points are included–then this will return (0, get_x_size(), 0, get_y_size()).
Definition at line 442 of file pfmFile.I.
References calc_autocrop(), and set_zero_special().
bool PfmFile::calc_average_point | ( | LPoint3f & | result, |
PN_float32 | x, | ||
PN_float32 | y, | ||
PN_float32 | radius | ||
) | const |
Computes the unweighted average point of all points within the box centered at (x, y) with the indicated Manhattan-distance radius.
Missing points are assigned the value of their nearest neighbor. Returns true if successful, or false if the point value cannot be determined.
Definition at line 620 of file pfmFile.cxx.
References calc_bilinear_point(), and LPoint3f::zero().
Referenced by fill_channel_masked_nan().
bool PfmFile::calc_bilinear_point | ( | LPoint3f & | result, |
PN_float32 | x, | ||
PN_float32 | y | ||
) | const |
Computes the weighted average of the four nearest points to the floating-point index (x, y).
Returns true if the point has any contributors, false if the point is unknown.
Definition at line 708 of file pfmFile.cxx.
References calc_min_max(), and LPoint3f::zero().
Referenced by calc_average_point(), PfmVizzer::project(), and reverse_distort().
bool PfmFile::calc_min_max | ( | LVecBase3f & | min_depth, |
LVecBase3f & | max_depth | ||
) | const |
Calculates the minimum and maximum x, y, and z depth component values, representing the bounding box of depth values, and places them in the indicated vectors.
Returns true if successful, false if the mesh contains no points.
Definition at line 759 of file pfmFile.cxx.
References calc_autocrop(), and LVecBase3f::zero().
Referenced by calc_bilinear_point().
Calculates the minimum and maximum vertices of all points within the table.
Assumes the table contains 3-D points.
The return value is true if any points in the table, or false if none are.
Definition at line 1626 of file pfmFile.cxx.
References add_sub_image(), get_point(), get_point1(), get_point2(), get_point4(), has_point(), LMatrix4f::invert_from(), LVecBase3f::normalize(), and LMatrix4f::set_row().
Referenced by pull_spot().
void PfmFile::clear | ( | ) |
Eliminates all data in the file.
Definition at line 81 of file pfmFile.cxx.
Referenced by Texture::ensure_loader_type(), PfmVizzer::extrude(), forward_distort(), Texture::get_ram_image_as(), PfmVizzer::make_displacement(), PNMFileTypePfm::Reader::read_pfm(), resize(), and reverse_distort().
void PfmFile::clear | ( | int | x_size, |
int | y_size, | ||
int | num_channels | ||
) |
Resets to an empty table with a specific size.
The case of num_channels == 0 is allowed only in the case that x_size and y_size are also == 0; and this makes an empty (and invalid) PfmFile.
Definition at line 99 of file pfmFile.cxx.
References read().
|
inline |
Removes the special value that means "no data" when it appears in the pfm file.
All points will thus be considered valid.
Definition at line 520 of file pfmFile.I.
References has_no_data_value(), and LPoint4f::zero().
Referenced by set_no_data_chan4(), set_no_data_threshold(), and set_zero_special().
void PfmFile::clear_to_texcoords | ( | int | x_size, |
int | y_size | ||
) |
Replaces this PfmFile with a new PfmFile of size x_size x y_size x 3, containing the x y 0 values in the range 0 .
. 1 according to the x y index.
Definition at line 1555 of file pfmFile.cxx.
References pull_spot().
Referenced by apply_crop(), and PfmVizzer::generate_vis_mesh().
void PfmFile::copy_channel | ( | int | to_channel, |
const PfmFile & | other, | ||
int | from_channel | ||
) |
Copies just the specified channel values from the indicated PfmFile (which could be same as this PfmFile) into the specified channel of this one.
Definition at line 1477 of file pfmFile.cxx.
References copy_channel_masked(), get_channel(), and PNMImageHeader::get_num_channels().
Referenced by PfmVizzer::generate_vis_mesh(), and merge().
void PfmFile::copy_channel_masked | ( | int | to_channel, |
const PfmFile & | other, | ||
int | from_channel | ||
) |
Copies just the specified channel values from the indicated PfmFile, but only where the other file has a data point.
Definition at line 1498 of file pfmFile.cxx.
References apply_crop(), get_channel(), PNMImageHeader::get_num_channels(), and has_point().
Referenced by copy_channel().
void PfmFile::divide_sub_image | ( | const PfmFile & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 , |
||
float | pixel_scale = 1.0 |
||
) |
Behaves like copy_sub_image(), except the copy pixels are divided into the pixels of the destination, after scaling by the specified pixel_scale.
dest(x, y) = dest(x, y) / (copy(x, y) * pixel_scale).
Definition at line 2090 of file pfmFile.cxx.
References get_point1(), get_point2(), get_point3(), get_point4(), has_point(), and operator*=().
Referenced by mult_sub_image().
|
inline |
Fills the table with all of the same value.
Definition at line 391 of file pfmFile.I.
Referenced by fill(), forward_distort(), modify_point4(), resize(), reverse_distort(), and store_mask().
|
inline |
|
inline |
Fills the table with all of the same value.
Definition at line 411 of file pfmFile.I.
References calc_autocrop(), and fill().
void PfmFile::fill | ( | const LPoint4f & | value | ) |
Fills the table with all of the same value.
Definition at line 476 of file pfmFile.cxx.
References fill_nan().
void PfmFile::fill_channel | ( | int | channel, |
PN_float32 | value | ||
) |
Fills the indicated channel with all of the same value, leaving the other channels unchanged.
Definition at line 550 of file pfmFile.cxx.
References fill_channel_nan().
Referenced by fill_no_data_value().
void PfmFile::fill_channel_masked | ( | int | channel, |
PN_float32 | value | ||
) |
Fills the indicated channel with all of the same value, but only where the table already has a data point.
Leaves empty points unchanged.
Definition at line 580 of file pfmFile.cxx.
References fill_channel_masked_nan().
Referenced by fill_channel_nan().
void PfmFile::fill_channel_masked_nan | ( | int | channel | ) |
Fills the indicated channel with NaN, but only where the table already has a data point.
Leaves empty points unchanged.
Definition at line 604 of file pfmFile.cxx.
References calc_average_point().
Referenced by fill_channel_masked().
void PfmFile::fill_channel_nan | ( | int | channel | ) |
Fills the indicated channel with NaN, leaving the other channels unchanged.
Definition at line 567 of file pfmFile.cxx.
References fill_channel_masked().
Referenced by fill_channel().
void PfmFile::fill_nan | ( | ) |
Fills the table with all NaN.
Definition at line 526 of file pfmFile.cxx.
References fill_no_data_value().
Referenced by fill().
void PfmFile::fill_no_data_value | ( | ) |
Fills the table with the current no_data value, so that the table is empty.
Definition at line 539 of file pfmFile.cxx.
References fill_channel().
Referenced by fill_nan().
void PfmFile::flip | ( | bool | flip_x, |
bool | flip_y, | ||
bool | transpose | ||
) |
Reverses, transposes, and/or rotates the table 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 1222 of file pfmFile.cxx.
References xform().
Referenced by PfmTrans::process_pfm(), and reverse_rows().
void PfmFile::forward_distort | ( | const PfmFile & | dist, |
PN_float32 | scale_factor = 1.0 |
||
) |
Applies the distortion indicated in the supplied dist map to the current map.
The dist map is understood to be a mapping of points in the range 0..1 in the first two dimensions.
The operation can be expressed symbolically as:
this(u, v) = this(dist(u, v))
If scale_factor is not 1, it should be a value > 1, and it specifies the factor to upscale the working table while processing, to reduce artifacts from integer truncation.
By convention, the y axis is inverted in the distortion map relative to the coordinates here. A y value of 0 in the distortion map corresponds with a v value of 1 in this file.
Definition at line 1310 of file pfmFile.cxx.
References clear(), fill(), get_point2(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), has_point(), LVecBase3f::is_nan(), resize(), reverse_distort(), set_no_data_value(), and set_point().
Referenced by xform().
void PfmFile::gaussian_filter_from | ( | float | width, |
const PfmFile & | 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.
Definition at line 677 of file pnm-image-filter.cxx.
References PNMImageHeader::get_x_size(), PNMImage::get_xel_a(), PNMImageHeader::get_y_size(), PNMImage::quick_filter_from(), and LVecBase4f::zero().
Referenced by box_filter_from(), and resize().
|
inline |
Returns the cth channel of the point value at the indicated point.
Definition at line 68 of file pfmFile.I.
References set_channel().
Referenced by copy_channel(), copy_channel_masked(), Texture::get_ram_image_as(), has_point(), PfmVizzer::make_displacement(), and PfmTrans::process_pfm().
|
inline |
If has_no_data_value() returns true, this returns the particular "no data" value.
Definition at line 556 of file pfmFile.I.
References xform(), and LPoint4f::zero().
Referenced by has_no_data_threshold(), and PfmVizzer::project().
|
inline |
Returns the 3-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 198 of file pfmFile.I.
References get_point3(), and set_point().
Referenced by PfmVizzer::calc_max_u_displacement(), PfmVizzer::calc_max_v_displacement(), calc_tight_bounds(), PfmVizzer::extrude(), PfmVizzer::generate_vis_points(), PfmVizzer::make_displacement(), merge(), and modify_point2().
|
inline |
Returns the 1-component point value at the indicated point.
Definition at line 96 of file pfmFile.I.
References set_point1().
Referenced by add_sub_image(), calc_tight_bounds(), divide_sub_image(), PfmVizzer::extrude(), PfmVizzer::make_displacement(), mult_sub_image(), and set_channel().
|
inline |
Returns the 2-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 124 of file pfmFile.I.
References set_point2(), and LPoint2f::zero().
Referenced by add_sub_image(), calc_tight_bounds(), divide_sub_image(), forward_distort(), PfmVizzer::make_displacement(), mult_sub_image(), and set_point1().
|
inline |
Returns the 3-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 245 of file pfmFile.I.
References set_point3(), and LPoint3f::zero().
Referenced by add_sub_image(), divide_sub_image(), get_point(), modify_point(), and mult_sub_image().
|
inline |
Returns the 4-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 319 of file pfmFile.I.
References set_point4(), and LPoint4f::zero().
Referenced by add_sub_image(), calc_tight_bounds(), divide_sub_image(), modify_point3(), and mult_sub_image().
|
inline |
The "scale" is reported in the pfm header and is probably meaningless.
Definition at line 33 of file pfmFile.I.
References set_scale().
Referenced by PNMFileTypePfm::Writer::write_pfm().
|
inline |
Returns whether a "no data" threshold value has been established by set_no_data_threshold().
Definition at line 545 of file pfmFile.I.
References get_no_data_value().
Referenced by has_no_data_value().
|
inline |
Returns whether a "no data" value has been established by set_no_data_value().
Definition at line 534 of file pfmFile.I.
References has_no_data_threshold().
Referenced by clear_no_data_value(), PfmVizzer::extrude(), PNMImage::gaussian_filter_from(), and PfmVizzer::project().
|
inline |
Returns true if there is a valid point at x, y.
This always returns true unless a "no data" value has been set, in which case it returns false if the point at x, y is the "no data" value.
Definition at line 57 of file pfmFile.I.
References get_channel().
Referenced by add_sub_image(), PfmVizzer::calc_max_u_displacement(), PfmVizzer::calc_max_v_displacement(), calc_tight_bounds(), copy_channel_masked(), divide_sub_image(), PfmVizzer::extrude(), forward_distort(), PfmVizzer::generate_vis_points(), PfmVizzer::make_displacement(), merge(), mult_sub_image(), PfmTrans::process_pfm(), PfmVizzer::project(), and set_scale().
bool PfmFile::is_column_empty | ( | int | x, |
int | y_begin, | ||
int | y_end | ||
) | const |
Returns true if all of the points on column x, from [y_begin, y_end), are the no_data value, or false if any one of these points has a value.
Definition at line 865 of file pfmFile.cxx.
References set_no_data_nan().
Referenced by is_row_empty().
bool PfmFile::is_row_empty | ( | int | y, |
int | x_begin, | ||
int | x_end | ||
) | const |
Returns true if all of the points on row y, in the range [x_begin, x_end), are the no_data value, or false if any one of these points has a value.
Definition at line 841 of file pfmFile.cxx.
References is_column_empty().
Referenced by calc_autocrop().
bool PfmFile::load | ( | const PNMImage & | pnmimage | ) |
Fills the PfmFile with the data from the indicated PNMImage, converted to floating-point values.
Definition at line 312 of file pfmFile.cxx.
References PNMImage::get_alpha(), PNMImage::get_gray(), PNMImageHeader::get_num_channels(), PNMImageHeader::get_x_size(), PNMImage::get_xel(), PNMImage::get_xel_a(), PNMImageHeader::get_y_size(), PNMImage::is_valid(), and store().
Referenced by Texture::ensure_loader_type(), write(), and PNMImage::write().
void PfmFile::merge | ( | const PfmFile & | other | ) |
Wherever there is missing data in this PfmFile (that is, wherever has_point() returns false), copy data from the other PfmFile, which must be exactly the same dimensions as this one.
Definition at line 1451 of file pfmFile.cxx.
References copy_channel(), get_point(), and has_point().
Referenced by reverse_distort().
|
inline |
Returns a modifiable 3-component point value at the indicated point.
Definition at line 233 of file pfmFile.I.
References get_point3(), and modify_point3().
Referenced by PfmVizzer::project(), and set_point().
|
inline |
Returns a modifiable 2-component point value at the indicated point.
Definition at line 180 of file pfmFile.I.
References get_point(), and LPoint2f::zero().
Referenced by set_point2().
|
inline |
Returns a modifiable 3-component point value at the indicated point.
Definition at line 301 of file pfmFile.I.
References get_point4(), and LPoint3f::zero().
Referenced by modify_point(), and set_point3().
|
inline |
Returns a modifiable 4-component point value at the indicated point.
Definition at line 375 of file pfmFile.I.
References fill(), and LPoint4f::zero().
Referenced by set_point4().
void PfmFile::mult_sub_image | ( | const PfmFile & | copy, |
int | xto, | ||
int | yto, | ||
int | xfrom = 0 , |
||
int | yfrom = 0 , |
||
int | x_size = -1 , |
||
int | y_size = -1 , |
||
float | 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.
Definition at line 2022 of file pfmFile.cxx.
References divide_sub_image(), get_point1(), get_point2(), get_point3(), get_point4(), and has_point().
Referenced by add_sub_image().
void PfmFile::operator*= | ( | float | multiplier | ) |
Multiplies every point value in the image by a constant floating-point multiplier value.
Definition at line 2168 of file pfmFile.cxx.
References LPoint2f::zero(), LPoint4f::zero(), and LPoint3f::zero().
Referenced by divide_sub_image().
int PfmFile::pull_spot | ( | const LPoint4f & | delta, |
float | xc, | ||
float | yc, | ||
float | xr, | ||
float | yr, | ||
float | exponent | ||
) |
Applies delta * t to the point values within radius (xr, yr) distance of (xc, yc).
The t value is scaled from 1.0 at the center to 0.0 at radius (xr, yr), and this scale follows the specified exponent. Returns the number of points affected.
Definition at line 1586 of file pfmFile.cxx.
References calc_tight_bounds().
Referenced by clear_to_texcoords().
void PfmFile::quick_filter_from | ( | const PfmFile & | from | ) |
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.
Definition at line 1041 of file pfmFile.cxx.
References PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and reverse_rows().
Referenced by resize().
bool PfmFile::read | ( | const Filename & | fullpath | ) |
Reads the PFM data from the indicated file, returning true on success, false on failure.
This can also handle reading a standard image file supported by PNMImage; it will be quietly converted to a floating-point type.
Definition at line 130 of file pfmFile.cxx.
References VirtualFileSystem::close_read_file(), VirtualFileSystem::get_file(), and VirtualFileSystem::get_global_ptr().
Referenced by clear(), Texture::ensure_loader_type(), and read().
Reads the PFM data from the indicated stream, returning true on success, false on failure.
This can also handle reading a standard image file supported by PNMImage; it will be quietly converted to a floating-point type.
Definition at line 165 of file pfmFile.cxx.
References read().
bool PfmFile::read | ( | PNMReader * | reader | ) |
Reads the PFM data using the indicated PNMReader.
The PNMReader is always deleted upon completion, whether successful or not.
Definition at line 183 of file pfmFile.cxx.
References PNMReader::is_floating_point(), PNMReader::is_valid(), PNMImage::read(), PNMReader::read_pfm(), and write().
void PfmFile::resize | ( | int | new_x_size, |
int | new_y_size | ||
) |
Applies a simple filter to resample the pfm file in-place to the indicated size.
Don't confuse this with applying a scale to all of the points via xform().
Definition at line 996 of file pfmFile.cxx.
References box_filter_from(), clear(), fill(), gaussian_filter_from(), and quick_filter_from().
Referenced by Texture::ensure_loader_type(), forward_distort(), PfmTrans::process_pfm(), reverse_distort(), and set_no_data_threshold().
void PfmFile::reverse_distort | ( | const PfmFile & | dist, |
PN_float32 | scale_factor = 1.0 |
||
) |
Applies the distortion indicated in the supplied dist map to the current map.
The dist map is understood to be a mapping of points in the range 0..1 in the first two dimensions.
The operation can be expressed symbolically as:
this(u, v) = dist(this(u, v))
If scale_factor is not 1, it should be a value > 1, and it specifies the factor to upscale the working table while processing, to reduce artifacts from integer truncation.
By convention, the y axis in inverted in the distortion map relative to the coordinates here. A y value of 0 in the distortion map corresponds with a v value of 1 in this file.
Definition at line 1388 of file pfmFile.cxx.
References calc_bilinear_point(), clear(), fill(), PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), merge(), resize(), set_no_data_value(), and set_point().
Referenced by forward_distort().
void PfmFile::reverse_rows | ( | ) |
Performs an in-place reversal of the row (y) data.
Definition at line 1190 of file pfmFile.cxx.
References flip(), and Thread::start().
Referenced by quick_filter_from().
|
inline |
Replaces the cth channel of the point value at the indicated point.
Definition at line 82 of file pfmFile.I.
References get_point1().
Referenced by get_channel(), Texture::get_ram_image_as(), and PfmVizzer::make_displacement().
|
inline |
Sets the no_data_chan4 flag.
When this flag is true, and the pfm file has 4 channels, then a negative value in the fourth channel indicates no data. When it is false, all points are valid.
This is a special case of set_no_data_value().
Definition at line 478 of file pfmFile.I.
References clear_no_data_value(), and set_no_data_value().
Referenced by set_zero_special().
void PfmFile::set_no_data_nan | ( | int | num_channels | ) |
Sets the no_data_nan flag.
When num_channels is nonzero, then a NaN value in any of the first num_channels channels indicates no data for that point. If num_channels is zero, then all points are valid.
This is a special case of set_no_data_value().
Definition at line 893 of file pfmFile.cxx.
References set_no_data_value(), and LPoint4f::zero().
Referenced by is_column_empty(), and PfmTrans::process_pfm().
void PfmFile::set_no_data_threshold | ( | const LPoint4f & | no_data_value | ) |
Sets the special threshold value.
Points that are below this value in all components are considered "no value".
Definition at line 963 of file pfmFile.cxx.
References resize().
Referenced by set_no_data_threshold(), and set_no_data_value().
|
inline |
Sets the special threshold value.
Points that are below this value in all components are considered "no value".
Definition at line 508 of file pfmFile.I.
References clear_no_data_value(), and set_no_data_threshold().
void PfmFile::set_no_data_value | ( | const LPoint4f & | no_data_value | ) |
Sets the special value that means "no data" when it appears in the pfm file.
Definition at line 931 of file pfmFile.cxx.
References set_no_data_threshold().
Referenced by forward_distort(), reverse_distort(), set_no_data_chan4(), set_no_data_nan(), set_no_data_value(), and set_zero_special().
|
inline |
Sets the special value that means "no data" when it appears in the pfm file.
Definition at line 496 of file pfmFile.I.
References set_no_data_threshold(), and set_no_data_value().
|
inline |
Replaces the 3-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 210 of file pfmFile.I.
References set_point3().
Referenced by PfmVizzer::extrude(), forward_distort(), get_point(), and reverse_distort().
|
inline |
Replaces the 3-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 222 of file pfmFile.I.
References modify_point(), and set_point3().
|
inline |
Replaces the 1-component point value at the indicated point.
Definition at line 109 of file pfmFile.I.
References get_point2().
Referenced by get_point1().
|
inline |
Replaces the 2-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 138 of file pfmFile.I.
References LVecBase2f::is_nan().
Referenced by get_point2(), and set_point2().
|
inline |
Replaces the 2-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 169 of file pfmFile.I.
References modify_point2(), and set_point2().
|
inline |
Replaces the 3-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 259 of file pfmFile.I.
References LVecBase3f::is_nan().
Referenced by get_point3(), PfmVizzer::make_displacement(), set_point(), and set_point3().
|
inline |
Replaces the 3-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 290 of file pfmFile.I.
References modify_point3(), and set_point3().
|
inline |
Replaces the 4-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 333 of file pfmFile.I.
References LVecBase4f::is_nan().
Referenced by get_point4(), PfmVizzer::project(), and set_point4().
|
inline |
Replaces the 4-component point value at the indicated point.
In a 1-channel image, the channel value is in the x component.
Definition at line 364 of file pfmFile.I.
References modify_point4(), and set_point4().
|
inline |
The "scale" is reported in the pfm header and is probably meaningless.
Definition at line 44 of file pfmFile.I.
References has_point().
Referenced by get_scale(), and PNMFileTypePfm::Reader::read_pfm().
|
inline |
Sets the zero_special flag.
When this flag is true, values of (0, 0, 0) in the pfm file are treated as a special case, and are not processed.
This is a special case of set_no_data_value().
Definition at line 459 of file pfmFile.I.
References clear_no_data_value(), set_no_data_chan4(), set_no_data_value(), and LPoint4f::zero().
Referenced by calc_autocrop(), PfmVizzer::extrude(), PfmBba::process_pfm(), and PfmTrans::process_pfm().
bool PfmFile::store | ( | PNMImage & | pnmimage | ) | const |
Copies the data to the indicated PNMImage, converting to RGB values.
Definition at line 387 of file pfmFile.cxx.
References PNMImage::clear(), PNMImage::set_alpha(), PNMImage::set_gray(), PNMImage::set_xel(), PNMImage::set_xel_a(), and store_mask().
Referenced by Texture::ensure_loader_type(), load(), and PNMImage::read().
bool PfmFile::store_mask | ( | PNMImage & | pnmimage | ) | const |
Stores 1 or 0 values into the indicated PNMImage, according to has_point() for each pixel.
Each valid point gets a 1 value; each nonexistent point gets a 0 value.
Definition at line 455 of file pfmFile.cxx.
References PNMImage::clear(), fill(), and PNMImage::set_gray().
Referenced by store().
bool PfmFile::write | ( | const Filename & | fullpath | ) |
Writes the PFM data to the indicated file, returning true on success, false on failure.
If the type implied by the filename extension supports floating-point, the data will be written directly; otherwise, the floating-point data will be quietly converted to the appropriate integer type.
Definition at line 222 of file pfmFile.cxx.
References Filename::open_write().
Referenced by Texture::ensure_loader_type(), PfmTrans::process_pfm(), read(), and write().
Writes the PFM data to the indicated stream, returning true on success, false on failure.
Definition at line 252 of file pfmFile.cxx.
References write().
bool PfmFile::write | ( | PNMWriter * | writer | ) |
Writes the PFM data using the indicated PNMWriter.
The PNMWriter is always deleted upon completion, whether successful or not.
Definition at line 274 of file pfmFile.cxx.
References PNMWriter::copy_header_from(), PNMImage::get_alpha_array(), PNMImage::get_array(), load(), PNMWriter::supports_floating_point(), PNMWriter::write_data(), and PNMWriter::write_pfm().
void PfmFile::xform | ( | const LMatrix4f & | transform | ) |
Applies the indicated transform matrix to all points in-place.
Definition at line 1273 of file pfmFile.cxx.
References forward_distort(), and LMatrix4f::xform_point_general_in_place().
Referenced by flip(), get_no_data_value(), PfmTrans::process_pfm(), and xform().
|
inline |
Applies the indicated transform matrix to all points in-place.
Definition at line 568 of file pfmFile.I.
References PNMImageHeader::get_x_size(), PNMImageHeader::get_y_size(), and xform().