IT++ Logo
Functions

Image Functions and Classes

Source Coding Module

Functions

char itpp::pnm_type (const std::string &filename)
 Determines the type of a PNM file, based on magic numbers. The returned value is a character between '1' and '6'. If an error occured, the returned value is the character '0'.
bool itpp::pnm_info (const std::string &filename, char &pnm_type, int &width, int &height, int &max_val, std::string &comments)
 Retrieve some information about an pnm file.
bool itpp::pgm_read (const std::string &filename, imat &m, std::string &comments)
 Read the entire graymap into the matrix m or return false if the function failed.
bool itpp::pgm_read (const std::string &filename, imat &m, int r1, int r2, int c1, int c2)
 Read a part of the graymap into the matrix m.
imat itpp::pgm_read (const std::string &filename)
 Read a pgm file of name filename and return the corresponding matrix of integers. Return a void matrix if an error ocurred.
bool itpp::pgm_write (const std::string &filename, const imat &m, const std::string &comments="Generated by IT++ (http://itpp.sourceforge.net)")
 Create an image file from the matrix of integer.
bool itpp::ppm_read (const std::string &filename, imat &r, imat &g, imat &b, std::string &comments)
 Read the color image file in the format ppm. The image is retrieved as a set of three matrices, each of whom is a plan of RGB component.
bool itpp::ppm_read (const std::string &filename, imat &r, imat &g, imat &b)
 Read the color image file in the PPM format.
bool itpp::ppm_read (const std::string &filename, imat &r, imat &g, imat &b, int r1, int r2, int c1, int c2)
 Read a part of the pixmap into the matrix m. The parameters r1, r2, c1 and c2 are the rows and columns (inclusive) of the subimage.
bool itpp::ppm_write (const std::string &filename, const imat &r, const imat &g, const imat &b, const std::string &comments="Generated by IT++ (http://itpp.sourceforge.net)", int max_val=255)
 Write the matrix m as a pixmap.
imat itpp::img_double2int (const mat &m, int max_val=255, double double_min=0, double double_max=1)
 Prepare a matrix of double to be writted as an image.
mat itpp::img_int2double (const imat &m, int max_val=255, double double_min=0, double double_max=1)
 Return a matrix of double which is a scaled version of the input matrix m of integers.

Detailed Description

The PNM graphics format is actually a family of formats consisting of PBM (black and white, not implemented yet), PGM (gray) and PPM (RGB color). This interface proposes input/output functions for images in the raw formats (type 'P4', 'P5' and 'P6').

There are several utilities available for manipulating PNM images. Search the net for the netpbm package.


Function Documentation

char itpp::pnm_type ( const std::string &  filename)

Determines the type of a PNM file, based on magic numbers. The returned value is a character between '1' and '6'. If an error occured, the returned value is the character '0'.

Parameters:
filenameThe name of the file from which the image is retrieved

Definition at line 70 of file pnm.cpp.

Referenced by itpp::pgm_read(), and itpp::ppm_read().

bool itpp::pnm_info ( const std::string &  filename,
char &  pnm_type,
int &  width,
int &  height,
int &  max_val,
std::string &  comments 
)

Retrieve some information about an pnm file.

Parameters:
filenameThe name of the file from which the image is retrieved
pnm_typeThe type of the pnm file (5: pgm file, 6: ppm file)
widthThe image width
heightThe image height
max_valThe greatest possible value
commentsThe comments in the file

Definition at line 86 of file pnm.cpp.

bool itpp::pgm_read ( const std::string &  filename,
imat m,
std::string &  comments 
)

Read the entire graymap into the matrix m or return false if the function failed.

Parameters:
filenameThe name of the file from which the image is retrieved
mThe matrix in which the image will be stored
commentsThis std::string variable is used to retrieve the comments of the file

Definition at line 104 of file pnm.cpp.

References itpp::pnm_type().

Referenced by itpp::pgm_read().

bool itpp::pgm_read ( const std::string &  filename,
imat m,
int  r1,
int  r2,
int  c1,
int  c2 
)

Read a part of the graymap into the matrix m.

Parameters:
filenameThe name of the file from which the image is retrieved
mThe matrix in which the image will be stored
r1first row to be included in the matrix
r2last row to be included in the matrix
c1first column to be included in the matrix
c2last column to be included in the matrix

Definition at line 144 of file pnm.cpp.

References it_error_if, and itpp::pnm_type().

imat itpp::pgm_read ( const std::string &  filename)

Read a pgm file of name filename and return the corresponding matrix of integers. Return a void matrix if an error ocurred.

Parameters:
filenameThe name of the file from which the image is retrieved

Definition at line 132 of file pnm.cpp.

References it_warning, and itpp::pgm_read().

bool itpp::pgm_write ( const std::string &  filename,
const imat m,
const std::string &  comments = "Generated by IT++ (http://itpp.sourceforge.net)" 
)

Create an image file from the matrix of integer.

Parameters:
filenameThe name of the image file to create
mThe matrix of integer representing the image
commentsComments included in the file

Coefficients greater than 255 and smaller than 0 are clipped.

Definition at line 192 of file pnm.cpp.

bool itpp::ppm_read ( const std::string &  filename,
imat r,
imat g,
imat b,
std::string &  comments 
)

Read the color image file in the format ppm. The image is retrieved as a set of three matrices, each of whom is a plan of RGB component.

Parameters:
filenameThe name of the file to be read
rthe red component of the image
gthe green component of the image
bthe blue component of the image
commentsa string variable to retrieve the comments contained in the file header.

Definition at line 219 of file pnm.cpp.

References itpp::pnm_type().

Referenced by itpp::ppm_read().

bool itpp::ppm_read ( const std::string &  filename,
imat r,
imat g,
imat b 
)

Read the color image file in the PPM format.

Parameters:
filenameThe name of the file to be read
rthe red component of the image
gthe green component of the image
bthe blue component of the image

Definition at line 248 of file pnm.cpp.

References itpp::ppm_read().

bool itpp::ppm_write ( const std::string &  filename,
const imat r,
const imat g,
const imat b,
const std::string &  comments = "Generated by IT++ (http://itpp.sourceforge.net)",
int  max_val = 255 
)

Write the matrix m as a pixmap.

Parameters:
filenameThe name of the file to create
rthe red component of the image
gthe green component of the image
bthe blue component of the image
commentsa comment that will be inserted in the image file
max_valThe maximum value of a component. This quantity should be lower than 255 (raw type).

Definition at line 312 of file pnm.cpp.

References it_assert_debug, and it_warning.

imat itpp::img_double2int ( const mat m,
int  max_val = 255,
double  double_min = 0,
double  double_max = 1 
)

Prepare a matrix of double to be writted as an image.

Parameters:
mThe matrix of real. The components are assumed to be between double_min and double_max, and will be scaled by factor max_val / (double_max - double_min ) in the output matrix.
max_valThe maximum value for the output matrix. This value is usually set to 255.
double_minThe value corresponding to the integer value 0. Note that all the values smaller that this quantity will be double_min.
double_maxThe value corresponding to the integer value max_val. Similarly to double_min, values greater than double_max will be set to double_max

Definition at line 349 of file pnm.cpp.

mat itpp::img_int2double ( const imat m,
int  max_val = 255,
double  double_min = 0,
double  double_max = 1 
)

Return a matrix of double which is a scaled version of the input matrix m of integers.

Parameters:
mThe matrix of real. The components are assumed to be between 0 and 1, and will be scaled by factor max_val in the output matrix.
max_valThe maximum value for the output matrix. This value is usually set to 255.
double_minThe value on which the integer value 0 will be mapped
double_maxThe value on which the integer value max_val will be mapped

Definition at line 373 of file pnm.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Wed Feb 9 2011 13:47:18 for IT++ by Doxygen 1.7.3