CVR-Lib last update 20 Sep 2009

cvr::image Class Reference
[Aggregate Data TypesColor AnalysisImage Processing and Analysis]

The one and only RGBA-image format. More...

#include <cvrImage.h>

Inheritance diagram for cvr::image:

Inheritance graph
[legend]
Collaboration diagram for cvr::image:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 image ()
 image (const int rows, const int cols)
 image (const ipoint &size)
 image (const int rows, const int cols, const rgbaPixel &iniValue)
 image (const ipoint &size, const rgbaPixel &iniValue)
 image (const int rows, const int cols, const rgbaPixel data[])
 image (const image &other)
 image (const image &other, const ipoint &from, const ipoint &to)
 image (const image &other, const int fromRow, const int fromCol=0, const int toRow=MaxIndex, const int toCol=MaxIndex)
virtual const std::string & name () const
virtual imageclone () const
virtual imagenewInstance () const
imagecastFrom (const matrix< ubyte > &other)
imagecastFrom (const fmatrix &other, const bool minToBlack=false, const bool maxToWhite=false)
imagecastFrom (const matrix< int32 > &other, const bool minToBlack=false, const bool maxToWhite=false)
imagecastFrom (const image &other)


Detailed Description

The one and only RGBA-image format.

This class is an specialization of a matrix of cvr::rgbaPixel.

The concept for color images and gray valued images in the CVR-Lib is simple: they are specializations of the class cvr::matrix.

Several aspects must however be clarified. The rows of the matrix will represent horizontal lines in the image, and the columns vertical ones. The row with index zero will be the row at the top of the image. The column with row zero is the one at the left of the image. This means that the used coordinate system for the position of a pixel is "left-handed": the origin is situated at the top-left corner of the image, the x-coordinate gives the position in the horizontal axis and the y-coordinate the position in the vertical axis. In other words, the y coordinate give the row and x the column of the matrix. This fact is important to remember when accessing the image elements:

 image img; // our image
 if (img.at(y,x) == img[y][x] == img.at(point(x,y))) {
   cout << "This is always true!";
 } else {
   cout << "ERROR: it's imposible to get here";
   exit 1;
 }

The gray valued channels cvr::channel and cvr::channel8 differ on the type and valid value ranges of their elements. The former accepts floating point values, with a default value range from 0.0 to 1.0. Many algorithms produce other values with specific meanings like angles or gradients, but using the default range you can assume 0.0 as a representation for black and 1.0 for white.

The cvr::channel8 is a much smaller representation but allows only integer values between 0 and 255, fact that can be advantageous in many algorithms. Here 0 usually means black and 255 white.

The cvr::image as cvr::matrix<cvr::rgbaPixel> allows the representation of true-color images, i.e. images with pixels that can be chosen from a palette of more than 16 million colors.

See also:
cvr::matrix for a reference to all inherited methods.

Constructor & Destructor Documentation

cvr::image::image (  ) 

Default constructor creates an empty image.

cvr::image::image ( const int  rows,
const int  cols 
)

Create a connected rows x cols image but leave all elements uninitialized.

Parameters:
rows number of rows of the image
cols number of columns of the image

cvr::image::image ( const ipoint size  ) 

Create a connected size.y x size.x image but leave all elements uninitialized.

Parameters:
size cvr::point with the size of the image (size.x is the number of columns and size.y the number of rows)

cvr::image::image ( const int  rows,
const int  cols,
const rgbaPixel iniValue 
)

Create a connected rows x cols image and initializes all elements with iniValue.

Parameters:
rows number of rows of the image
cols number of columns of the image
iniValue all elements will be initialized with this value

cvr::image::image ( const ipoint size,
const rgbaPixel iniValue 
)

Creates a connected size.y x size.x image and initializes all elements with iniValue.

Parameters:
size cvr::point with the size of the image (size.x is the number of columns and size.y the number of rows)
iniValue all elements will be initialized with this value

cvr::image::image ( const int  rows,
const int  cols,
const rgbaPixel  data[] 
)

Creates a connected rows x cols image and initializes all elements with the data pointed by data.

The first cols-elements of the data will be copied on the first row, the next ones on the second row and so on.

Parameters:
rows number of rows of the image
cols number of columns of the image
data pointer to the memory block with the data to be initialized with.

cvr::image::image ( const image other  ) 

Copy constructor.

Parameters:
other the image to be copied.

cvr::image::image ( const image other,
const ipoint from,
const ipoint to 
)

Copy constructor.

Create a subimage of the other image

Parameters:
other the image to be copied.
from initial coordinates of the window.
to final coordinates of the window.

cvr::image::image ( const image other,
const int  fromRow,
const int  fromCol = 0,
const int  toRow = MaxIndex,
const int  toCol = MaxIndex 
)

Copy constructor.

Create this image as a connected copy of another image for this const version, the data will be always copied! It is also possible to create a copy of a subimage of another image.

Parameters:
other the image to be copied.
fromRow initial row of the other image to be copied
toRow last row to be copied of the other image
fromCol initial column of the other image to be copied
toCol last column to be copied of the other image
Example:
 cvr::image m(4,6,0); // image with 24 elements
 // ...
 // initialize image with:
 //        0  1  2  3  4  5
 //        2  1  5  4  0  3
 //        1  2  1  2  3  2
 //        3  3  2  1  2  3

 cvr::image sm(m,1,3,0,2)  // this line will lead to the
 //                             following contents for sm:
 //        1  2  3
 //        1  5  4
 //        2  1  2


Member Function Documentation

image& cvr::image::castFrom ( const image other  )  [inline]

Alias for copy.

References cvr::matrix< rgbaPixel >::copy().

image& cvr::image::castFrom ( const matrix< int32 > &  other,
const bool  minToBlack = false,
const bool  maxToWhite = false 
)

Cast from the other channel32.

For the transformation it assumes the channel as a gray valued channel where 0 means black and 1.0f means white. All other values will be clipped (less than zero to zero and more than 1.0 to 1.0)

Parameters:
other the channel32 to be cast
minToBlack if minToBlack is true, a linear gray-valued tranformation will be applied, which maps the minimal value in the channel to (0,0,0). If false, the value zero will be mapped to zero.
maxToWhite if maxToWhite is true, a linear gray-valued transformation will be applied, which maps the maximal value in the channel to (255,255,255). If false, the value 1.0f will be mapped to 255.
Returns:
a reference to this image Example:
   cvr::channel matA(10,10,1.0f); // a channel
   cvr::image  matB;             // an image

   matB.castFrom(matA);         // this will copy matA in matB!!
                                // and all elements will have
                                // rgbaPixel(255,255,255)

image& cvr::image::castFrom ( const fmatrix other,
const bool  minToBlack = false,
const bool  maxToWhite = false 
)

Cast from the other fmatrix, intepreted as a single precision floating point channel.

For the transformation it assumes the channel as a gray valued channel where 0 means black and 1.0f means white. All other values will be clipped (less than zero to zero and more than 1.0 to 1.0)

Parameters:
other the channel8 to be cast
minToBlack if minToBlack is true, a linear gray-valued tranformation will be applied, which maps the minimal value in the channel to (0,0,0). If false, the value zero will be mapped to zero.
maxToWhite if maxToWhite is true, a linear gray-valued transformation will be applied, which maps the maximal value in the channel to (255,255,255). If false, the value 1.0f will be mapped to 255.
Returns:
a reference to this image Example:
   cvr::channel matA(10,10,1.0f); // a channel
   cvr::image  matB;             // an image

   matB.castFrom(matA);         // this will copy matA in matB!!
                                // and all elements will have
                                // rgbaPixel(255,255,255)

image& cvr::image::castFrom ( const matrix< ubyte > &  other  ) 

Cast from the other matrix<ubyte>, interpreted as a channel8.

For the transformation it assumes the channel8 as a gray valued channel where 0 means black and 255 means white.

Parameters:
other the channel8 to be cast
Returns:
a reference to this image
Example:
   cvr::channel8 matA(10,10,255); // a channel8
   cvr::image  matB;              // an image

   matB.castFrom(matA);         // this will copy matA in matB!!
                                // and all elements will have
                                // rgbaPixel(255,255,255)

virtual image* cvr::image::clone (  )  const [virtual]

Create a clone of this image.

Returns:
a pointer to a copy of this image

Reimplemented from cvr::matrix< rgbaPixel >.

virtual const std::string& cvr::image::name (  )  const [virtual]

Returns the name of this type.

Reimplemented from cvr::matrix< rgbaPixel >.

virtual image* cvr::image::newInstance (  )  const [virtual]

Create a new empty image.

Returns:
a pointer to the new image

Reimplemented from cvr::matrix< rgbaPixel >.


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

Generated on Sun Sep 20 22:08:46 2009 for CVR-Lib by Doxygen 1.5.8