SigPack - the C++ signal processing library
 
Loading...
Searching...
No Matches
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 cols, maxval, NOTUSED, rows, and type.

◆ ~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 63 of file image.h.

References cols, maxval, NOTUSED, rows, and type.

◆ get_cols()

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

Get nr of cols.

Returns
number of columns

Definition at line 304 of file image.h.

References cols.

◆ get_info()

void sp::PNM::get_info ( )
inline

Prints header info.

Definition at line 280 of file image.h.

References cols, maxval, PGM_A, PGM_B, rows, and type.

Referenced by read().

◆ get_maxval()

int sp::PNM::get_maxval ( )
inline

Get maxval.

Returns
Maximum value in image

Definition at line 314 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 294 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 326 of file image.h.

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

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 397 of file image.h.

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

Here is the call graph for this function:

◆ read_header()

void sp::PNM::read_header ( )
inline

Reads the .pnm header.

Definition at line 75 of file image.h.

References cols, err_handler, ifs, maxval, NOTUSED, PBM_A, PBM_B, PPM_B, rows, and type.

Referenced by read(), and read().

◆ write() [1/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 206 of file image.h.

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

Here is the call graph for this function:

◆ write() [2/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, ofs, PPM_A, PPM_B, rows, type, and write_header().

Referenced by main().

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 128 of file image.h.

References cols, maxval, ofs, PBM_A, PBM_B, rows, and type.

Referenced by write(), and 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 clear(), get_cols(), get_info(), PNM(), read(), read(), read_header(), write(), write(), and write_header().

◆ ifs

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

Input stream handle.

Definition at line 25 of file image.h.

Referenced by read(), read(), and read_header().

◆ maxval

int sp::PNM::maxval
private

Maximum pixel value in image.

Definition at line 29 of file image.h.

Referenced by clear(), get_info(), get_maxval(), PNM(), read(), read_header(), write(), and write_header().

◆ ofs

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

Output stream handle.

Definition at line 26 of file image.h.

Referenced by write(), write(), and write_header().

◆ rows

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

Nr of rows in image.

Definition at line 28 of file image.h.

Referenced by clear(), get_info(), get_rows(), PNM(), read(), read(), read_header(), write(), write(), and write_header().

◆ type

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

Image format.

Referenced by clear(), get_info(), PNM(), read(), read(), read_header(), write(), write(), and write_header().


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