Definition in file pnm_io.h.
#include <string>
#include <fstream>
#include <utility>
Include dependency graph for pnm_io.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | IFSTREAM std::ifstream |
Functions | |
std::istream & | eatcomments (std::istream &is) |
Swallows comments from the given stream, where a comment is defined as a line whose first non-whitespace character is a pound sign (#). | |
template<class Array2D> bool | pgm_read (const string &filename, Array2D &image) |
Read the specified PBM or PGM file into the given matrix in column-major order. | |
std::pair< int, int > | pnm_size (const string &filename) |
Utility routine which returns the size of the given PNM file as a (width,height) if found and readable, or else (0,0). | |
bool | pgm_white_is_transparent (const string &filename) |
Utility routine which returns true if the file declares that white (i.e. |
|
Read the specified PBM or PGM file into the given matrix in column-major order. Any 2D array type which supports a (width,height) constructor should work, e.g. TNT's Matrix. Returns false if there was a problem reading the file. Definition at line 54 of file pnm_io.h. References eatcomments(). Referenced by KernelFactory::create(). |
|
Utility routine which returns true if the file declares that white (i.e. 255/255) pixels are to be considered transparent. The PNM specs do not provide for transparency, but as a convention I assume that if the file has a comment (all on one line) of the form: #Transparent: 255 then then I should consider it so. The comment must appear within the first two non-comment lines to be detected, there must be no space after the #, and there must be one space after the :. Only a value of 255 (pure white) is supported at present. The reason is that pgm_read returns floats, not discrete integers, so it's more complicated to check any pixel value other than pure white or black. (One would have to check a range half a pixel-value-step larger and smaller in each direction.) In any case, in a non-colormapped grayscale picture, only black and white are likely to be useful as transparent. (Otherwise there would be a big step in grayscale gradients somewhere.) |