SigPack - the C++ signal processing library
sp::PNM Class Reference

#include <image.h>

Collaboration diagram for sp::PNM:
Collaboration graph

Public Types

enum  imtype {
  NOTUSED, PBM_A, PGM_A, PPM_A,
  PBM_B, PGM_B, PPM_B
}
 

Public Member Functions

 PNM ()
 
 ~PNM ()
 
void clear (void)
 
void read_header ()
 
void write_header (const imtype _type, const arma::uword _rows, const arma::uword _cols, const int _maxval, const std::string comments)
 
bool write (std::string fname, const imtype _type, const arma::cube &img, const std::string info="")
 
bool write (std::string fname, const imtype _type, arma::mat &img, const std::string info="")
 
void get_info ()
 
arma::uword get_rows ()
 
arma::uword get_cols ()
 
int get_maxval ()
 
bool read (std::string fname, arma::cube &img)
 
bool read (std::string fname, arma::mat &img)
 

Public Attributes

enum sp::PNM::imtype type
 

Private Attributes

std::ifstream ifs
 
std::ofstream ofs
 
arma::uword cols
 
arma::uword rows
 
int maxval
 

Detailed Description

Implements portable anymap image functions Supports .pbm, .pgm and .ppm plain and raw

Examples:
image.cpp.

Definition at line 22 of file image.h.

Member Enumeration Documentation

◆ imtype

Enumerator
NOTUSED 
PBM_A 
PGM_A 
PPM_A 
PBM_B 
PGM_B 
PPM_B 

Definition at line 31 of file image.h.

Constructor & Destructor Documentation

◆ PNM()

sp::PNM::PNM ( )
inline

Constructor.

Definition at line 45 of file image.h.

References NOTUSED.

◆ ~PNM()

sp::PNM::~PNM ( )
inline

Destructor.

Definition at line 56 of file image.h.

Member Function Documentation

◆ clear()

void sp::PNM::clear ( void  )
inline

Clears the internal variables.

Definition at line 61 of file image.h.

References NOTUSED.

◆ get_cols()

arma::uword sp::PNM::get_cols ( )
inline

Get nr of cols.

Returns
number of columns

Definition at line 305 of file image.h.

References cols.

◆ get_info()

void sp::PNM::get_info ( )
inline

Prints header info.

Definition at line 284 of file image.h.

References PGM_A, and PGM_B.

Referenced by read().

◆ get_maxval()

int sp::PNM::get_maxval ( )
inline

Get maxval.

Returns
Maximum value in image

Definition at line 312 of file image.h.

References maxval.

◆ get_rows()

arma::uword sp::PNM::get_rows ( )
inline

Get nr of rows.

Returns
number of rows

Definition at line 298 of file image.h.

References rows.

◆ read() [1/2]

bool sp::PNM::read ( std::string  fname,
arma::cube &  img 
)
inline

Read image.

Returns
true if success
Parameters
fnameFile name
imgImage data

Definition at line 321 of file image.h.

References cols, PPM_A, PPM_B, read_header(), and rows.

Here is the call graph for this function:

◆ read() [2/2]

bool sp::PNM::read ( std::string  fname,
arma::mat &  img 
)
inline

Read image.

Returns
true if success
Parameters
fnameFile name
imgImage data

Definition at line 392 of file image.h.

References cols, get_info(), PBM_A, PBM_B, PGM_A, PGM_B, read_header(), and rows.

Here is the call graph for this function:

◆ read_header()

void sp::PNM::read_header ( )
inline

Reads the .pnm header.

Definition at line 73 of file image.h.

References err_handler, NOTUSED, PBM_A, PBM_B, and PPM_B.

Referenced by read().

◆ write() [1/2]

bool sp::PNM::write ( std::string  fname,
const imtype  _type,
const arma::cube &  img,
const std::string  info = "" 
)
inline

Write the .pnm file.

Returns
true if success
Parameters
fnameFile name
_typeFile name
imgImage data
infoFile comments
Examples:
image.cpp.

Definition at line 150 of file image.h.

References cols, PPM_A, PPM_B, rows, and write_header().

Referenced by main().

Here is the call graph for this function:

◆ write() [2/2]

bool sp::PNM::write ( std::string  fname,
const imtype  _type,
arma::mat &  img,
const std::string  info = "" 
)
inline

Write the .pnm file.

Returns
true if success
Parameters
fnameFile name
_typeImage type
imgImage data
infoFile comments

Definition at line 208 of file image.h.

References cols, PBM_A, PBM_B, PGM_A, PGM_B, rows, and write_header().

Here is the call graph for this function:

◆ write_header()

void sp::PNM::write_header ( const imtype  _type,
const arma::uword  _rows,
const arma::uword  _cols,
const int  _maxval,
const std::string  comments 
)
inline

Write the .pnm header.

Parameters
_typeImage type
_rowsNr of rows
_colsNr of cols
_maxvalMaxval
commentsComments

Definition at line 126 of file image.h.

References PBM_A, and PBM_B.

Referenced by write().

Member Data Documentation

◆ cols

arma::uword sp::PNM::cols
private

Nr of columns in image.

Definition at line 27 of file image.h.

Referenced by get_cols(), read(), and write().

◆ ifs

std::ifstream sp::PNM::ifs
private

Input stream handle.

Definition at line 25 of file image.h.

◆ maxval

int sp::PNM::maxval
private

Maximum pixel value in image.

Definition at line 29 of file image.h.

Referenced by get_maxval().

◆ ofs

std::ofstream sp::PNM::ofs
private

Output stream handle.

Definition at line 26 of file image.h.

◆ rows

arma::uword sp::PNM::rows
private

Nr of rows in image.

Definition at line 28 of file image.h.

Referenced by get_rows(), read(), and write().

◆ type

enum sp::PNM::imtype sp::PNM::type

Image format.


The documentation for this class was generated from the following file: