LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::image Class Reference
[Aggregate Data TypesColor AnalysisAlgorithms and Classes for Image Processing]

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

#include <ltiImage.h>

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

List of all members.

Public Member Functions

 image ()
 image (const int &rows, const int &cols, const rgbPixel &iniValue=rgbPixel())
 image (const int &rows, const int &cols, const rgbPixel data[])
 image (const ipoint &size, const rgbPixel &iniValue=rgbPixel())
 image (const image &other, const int &fromRow=0, const int &toRow=MaxInt32, const int &fromCol=0, const int &toCol=MaxInt32)
 image (const bool &copyData, image &other, const int &fromRow=0, const int &toRow=MaxInt32, const int &fromCol=0, const int &toCol=MaxInt32)
 image (const bool &init, const int &rows, const int &cols)
 image (const bool &init, const ipoint &size)
virtual mathObjectclone () const
virtual const char * getTypeName () const
imagecastFrom (const channel8 &other)
imagecastFrom (const channel &other, const bool minToBlack=false, const bool maxToWhite=false)

Detailed Description

The one and only RGB-image format.

This class is an specialization of a matrix of lti::rgbPixel.

The concept for color images and gray valued images in the LTI-Lib is simple: they are specializations of the class lti::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. With 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 come here";
   exit 1;
 }

The gray valued channels lti::channel and lti::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 lti::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 lti::image as lti::matrix<lti::rgbPixel> 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:
lti::matrix for a reference to all inherited methods.

Constructor & Destructor Documentation

lti::image::image (  ) 

default constructor creates an empty image

lti::image::image ( const int &  rows,
const int &  cols,
const rgbPixel iniValue = rgbPixel() 
)

this constructor creates 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
lti::image::image ( const int &  rows,
const int &  cols,
const rgbPixel  data[] 
)

this constructor 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.
lti::image::image ( const ipoint size,
const rgbPixel iniValue = rgbPixel() 
)

this constructor creates a connected size.y x size.x image and initializes all elements with iniValue

Parameters:
size lti::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
lti::image::image ( const image other,
const int &  fromRow = 0,
const int &  toRow = MaxInt32,
const int &  fromCol = 0,
const int &  toCol = MaxInt32 
)

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:

 lti::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

 lti::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
lti::image::image ( const bool &  copyData,
image other,
const int &  fromRow = 0,
const int &  toRow = MaxInt32,
const int &  fromCol = 0,
const int &  toCol = MaxInt32 
)

copy constructor (reference to a subimage).

creates subimage of another image.

if copyData == true, the new object has its own data (equivalent to previous copy constructor).

if copyData == false, the new object has references to the other image, which means that the data is not necessarily consecutive. (This will not be a connected but a lined image)

Those algorithms which use direct access to the image memory block should check first if the memory lies in a consecutive block! (see getMode())

Parameters:
copyData should the data of the other image be copied or not
other the image with the original data
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
lti::image::image ( const bool &  init,
const int &  rows,
const int &  cols 
)

If init is true this constructor is equivalent to calling image(const int& rows, const int& cols), and thus initializing all elements with T().

However, in some cases the elements need not be initialized during construction, since complex initializion is required. Especially for large matrices, the unnecessary constructor initialization is very time consuming.

If init is false, memory is allocated but no initialization takes place. Thus the following is equivalent:

 image a(false,100,100);

 image a;
 a.resize(100,100,0,false,false);
Parameters:
init initialize image or not
rows number of rows of the image
cols number of columns of the image
lti::image::image ( const bool &  init,
const ipoint size 
)

If init is true this constructor is equivalent to calling image(const point& size), and thus initializing all elements with T().

However, in some cases the elements need not be initialized during construction, since complex initializion is required. Especially for large matrices, the unnecessary constructor initialization is very time consuming.

If init is false, memory is allocated but no initialization takes place. Thus the following is equivalent:

 image a(false,point(100,100));

 image a;
 a.resize(100,100,0,false,false);
Parameters:
init initialize image or not
size new size

Member Function Documentation

image& lti::image::castFrom ( const channel other,
const bool  minToBlack = false,
const bool  maxToWhite = false 
)

cast from the other 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 casted
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:
   lti::channel matA(10,10,1.0f); // a channel
   lti::image  matB;             // an image

   matB.castFrom(matA);         // this will copy matA in matB!!
                                // and all elements will have
                                // rgbPixel(255,255,255)
image& lti::image::castFrom ( const channel8 other  ) 

cast from the other 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 casted
Returns:
a reference to this image Example:
   lti::channel8 matA(10,10,255); // a channel8
   lti::image  matB;              // an image

   matB.castFrom(matA);         // this will copy matA in matB!!
                                // and all elements will have
                                // rgbPixel(255,255,255)
virtual mathObject* lti::image::clone (  )  const [virtual]

create a clone of this image

Returns:
a pointer to a copy of this image

Reimplemented from lti::matrix< rgbPixel >.

virtual const char* lti::image::getTypeName (  )  const [virtual]

return the name of this type

Reimplemented from lti::matrix< rgbPixel >.


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

Generated on Sat Apr 10 15:27:26 2010 for LTI-Lib by Doxygen 1.6.1