Read and write images.
More...
#include <ImageIO.h>
|
static bool | writeBinaryImageAsPbm (const Image< unsigned char, 1 > &image, const std::string &pbmPath) |
| Write binary image to file as PBM (Portable Bit Map). More...
|
|
static bool | writeGrayscaleImageAsPgm (const Image< unsigned char, 1 > &image, const std::string &pgmPath) |
| Write 8-bit grayscale image to file as PGM (Portable Gray Map) More...
|
|
static bool | writeGrayscaleImageAsPgm (const Image< unsigned short, 1 > &image, const std::string &pgmPath) |
| Write 16-bit grayscale image to file as PGM (Portable Gray Map) More...
|
|
static bool | writeRgbImageAsPpm (const Image< unsigned char, 3 > &image, const std::string &ppmPath) |
| Write 24-bit RGB image to file as PPM (Portable Pixel Map) More...
|
|
static bool | writeRgbaImageAsPpm (const Image< unsigned char, 4 > &image, const std::string &ppmPath) |
| Write 32-bit RGBA image to file as PPM (Portable Pixel Map) More...
|
|
static bool | writeRgbImageAsPam (const Image< unsigned char, 3 > &image, const std::string &pamPath) |
| Write 24-bit RGB image to file as PAM (Portable Arbitrary Map) More...
|
|
static bool | writeRgbaImageAsPam (const Image< unsigned char, 4 > &image, const std::string &pamPath) |
| Write 32-bit RGBA image to file as PAM (Portable Arbitrary Map) More...
|
|
static bool | readBinaryImageFromPbm (const std::string &pbmPath, Image< unsigned char, 1 > &image) |
| Read 1-bit binary image from PBM file (Portable Bit Map). More...
|
|
static bool | readGrayscaleImageFromPgm (const std::string &pgmPath, Image< unsigned char, 1 > &image) |
| Read 8-bit grayscale image from PGM file (Portable Gray Map) More...
|
|
static bool | readRgbImageFromPpm (const std::string &ppmPath, Image< unsigned char, 3 > &image) |
| Read 24-bit RGB image from PPM file (Portable Pixel Map) More...
|
|
|
static bool | readPnmFileHeader (std::ifstream &ifile, std::string magicNumber, size_t &width, size_t &height, unsigned long &maxVal) |
| Read header of a PNM file (PBM, PGM or PPM) More...
|
|
Read and write images.
This class supports 4 file formats:
- Portable Bit Map (PBM) for binary images (values 0 and 1).
- Portable Gray Map (PGM) for 8-bit and 16-bit grayscale images.
- Portable Pixel Map (PPM) for 24-bit and 48-bit RGB images.
- Portable Arbitrary Map (PAM) for arbitrary images (binary, RGB, RGBA, etc).
- http://netpbm.sourceforge.net/doc/pam.html
- Although this file format supports many pixel formats, it is not widely supported. Consider using the other 3 file formats when possisble. Only use this format if you require transparancy (alpha channel).
Beware! These functions have not been tested on endianness; big-endian vs little-endian.
◆ readBinaryImageFromPbm()
static bool spatium::ImageIO::readBinaryImageFromPbm |
( |
const std::string & |
pbmPath, |
|
|
Image< unsigned char, 1 > & |
image |
|
) |
| |
|
inlinestatic |
Read 1-bit binary image from PBM file (Portable Bit Map).
- Parameters
-
[in] | pbmPath | Path to PBM file. Should have file extension *.pbm |
[out] | image | Image |
- Returns
- True on success, false otherwise
◆ readGrayscaleImageFromPgm()
static bool spatium::ImageIO::readGrayscaleImageFromPgm |
( |
const std::string & |
pgmPath, |
|
|
Image< unsigned char, 1 > & |
image |
|
) |
| |
|
inlinestatic |
Read 8-bit grayscale image from PGM file (Portable Gray Map)
Beware! This file format also supports 16-bit grayscale format (2 bytes per channel). This is not implemented and function will return false in that situation.
- Parameters
-
[in] | pgmPath | Path to PGM file. Should have file extension *.pgm |
[out] | image | Image |
- Returns
- True on success, false otherwise
◆ readPnmFileHeader()
static bool spatium::ImageIO::readPnmFileHeader |
( |
std::ifstream & |
ifile, |
|
|
std::string |
magicNumber, |
|
|
size_t & |
width, |
|
|
size_t & |
height, |
|
|
unsigned long & |
maxVal |
|
) |
| |
|
inlinestaticprotected |
Read header of a PNM file (PBM, PGM or PPM)
- Parameters
-
[in] | ifile | Input file stream |
[in] | magicNumber | Expected magic number |
[out] | width | Image width |
[out] | height | Image height |
[out] | maxVal | Maximum pixel value (ignored for PBM images) |
- Returns
- True on success, false otherwise
◆ readRgbImageFromPpm()
static bool spatium::ImageIO::readRgbImageFromPpm |
( |
const std::string & |
ppmPath, |
|
|
Image< unsigned char, 3 > & |
image |
|
) |
| |
|
inlinestatic |
Read 24-bit RGB image from PPM file (Portable Pixel Map)
Beware! This file format also supports 48-bit RGB format (2 bytes per channel). This is not implemented and function will return false in that situation.
- Parameters
-
[in] | ppmPath | Path to PPM file. Should have file extension *.ppm |
[out] | image | Image |
- Returns
- True on success, false otherwise
◆ writeBinaryImageAsPbm()
static bool spatium::ImageIO::writeBinaryImageAsPbm |
( |
const Image< unsigned char, 1 > & |
image, |
|
|
const std::string & |
pbmPath |
|
) |
| |
|
inlinestatic |
Write binary image to file as PBM (Portable Bit Map).
In this file each pixel is represented by 1 bit. In the Image object each pixel is represented by 1 byte.
- Parameters
-
[in] | image | Image |
[in] | pbmPath | Path to PBM file. Should have file extension *.pbm |
- Returns
- True on success, false otherwise
◆ writeGrayscaleImageAsPgm() [1/2]
static bool spatium::ImageIO::writeGrayscaleImageAsPgm |
( |
const Image< unsigned char, 1 > & |
image, |
|
|
const std::string & |
pgmPath |
|
) |
| |
|
inlinestatic |
Write 8-bit grayscale image to file as PGM (Portable Gray Map)
- Parameters
-
[in] | image | Image |
[in] | pgmPath | Path to PGM file. Should have file extension *.pgm |
- Returns
- True on success, false otherwise
◆ writeGrayscaleImageAsPgm() [2/2]
static bool spatium::ImageIO::writeGrayscaleImageAsPgm |
( |
const Image< unsigned short, 1 > & |
image, |
|
|
const std::string & |
pgmPath |
|
) |
| |
|
inlinestatic |
Write 16-bit grayscale image to file as PGM (Portable Gray Map)
- Parameters
-
[in] | image | Image |
[in] | pgmPath | Path to PGM file. Should have file extension *.pgm |
- Returns
- True on success, false otherwise
◆ writeRgbaImageAsPam()
static bool spatium::ImageIO::writeRgbaImageAsPam |
( |
const Image< unsigned char, 4 > & |
image, |
|
|
const std::string & |
pamPath |
|
) |
| |
|
inlinestatic |
Write 32-bit RGBA image to file as PAM (Portable Arbitrary Map)
- Parameters
-
[in] | image | Image |
[in] | pamPath | Path to PAM file. Should have file extension *.pam |
- Returns
- True on success, false otherwise
◆ writeRgbaImageAsPpm()
static bool spatium::ImageIO::writeRgbaImageAsPpm |
( |
const Image< unsigned char, 4 > & |
image, |
|
|
const std::string & |
ppmPath |
|
) |
| |
|
inlinestatic |
Write 32-bit RGBA image to file as PPM (Portable Pixel Map)
This file format does not support transparancy. The alpha channel is omitted. Use PAM instead.
- Parameters
-
[in] | image | Image |
[in] | ppmPath | Path to PPM file. Should have file extension *.ppm |
- Returns
- True on success, false otherwise
◆ writeRgbImageAsPam()
static bool spatium::ImageIO::writeRgbImageAsPam |
( |
const Image< unsigned char, 3 > & |
image, |
|
|
const std::string & |
pamPath |
|
) |
| |
|
inlinestatic |
Write 24-bit RGB image to file as PAM (Portable Arbitrary Map)
- Parameters
-
[in] | image | Image |
[in] | pamPath | Path to PAM file. Should have file extension *.pam |
- Returns
- True on success, false otherwise
◆ writeRgbImageAsPpm()
static bool spatium::ImageIO::writeRgbImageAsPpm |
( |
const Image< unsigned char, 3 > & |
image, |
|
|
const std::string & |
ppmPath |
|
) |
| |
|
inlinestatic |
Write 24-bit RGB image to file as PPM (Portable Pixel Map)
- Parameters
-
[in] | image | Image |
[in] | ppmPath | Path to PPM file. Should have file extension *.ppm |
- Returns
- True on success, false otherwise
The documentation for this class was generated from the following file:
- /home/martijn/Development/Projects/SpatiumLib/include/spatium/ImageIO.h