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

lti::channel Class Reference
[Aggregate Data TypesAlgorithms and Classes for Image Processing]

a format for float channels. More...

#include <ltiImage.h>

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

List of all members.

Public Member Functions

 channel ()
 channel (const int &rows, const int &cols, const float &iniValue=float())
 channel (const int &rows, const int &cols, const float data[])
 channel (const ipoint &size, const float &iniValue=float())
 channel (const channel &other, const int &fromRow=0, const int &toRow=MaxInt32, const int &fromCol=0, const int &toCol=MaxInt32)
 channel (const bool &copyData, channel &other, const int &fromRow=0, const int &toRow=MaxInt32, const int &fromCol=0, const int &toCol=MaxInt32)
 channel (const bool &init, const int &rows, const int &cols)
 channel (const bool &init, const ipoint &size)
virtual mathObjectclone () const
virtual const char * getTypeName () const
channelcastFrom (const channel8 &other)
channelcastFrom (const image &other)
channelmapLinear (const float &minVal, const float &maxVal, const float &minDest=0.0f, const float &maxDest=1.0f)
channelmapLinear (const channel &other, const float &minVal, const float &maxVal, const float &minDest=0.0f, const float &maxDest=1.0f)
template<class U >
channelcastFrom (const matrix< U > &other)

Detailed Description

a format for float channels.

This class is identical to a matrix of floats except for the method castFrom(channel8).

The typical value range is between 0.0f and 1.0f (see lti::image for more information).

See also:
lti::image, lti::channel8

Constructor & Destructor Documentation

lti::channel::channel (  ) 

default constructor creates an empty channel

lti::channel::channel ( const int &  rows,
const int &  cols,
const float &  iniValue = float() 
)

this constructor creates a connected rows x cols channel and initializes all elements with iniValue

Parameters:
rows number of rows of the channel
cols number of columns of the channel
iniValue all elements will be initialized with this value
lti::channel::channel ( const int &  rows,
const int &  cols,
const float  data[] 
)

this constructor creates a connected rows x cols channel 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 channel
cols number of columns of the channel
data pointer to the memory block with the data to be initialized with.
lti::channel::channel ( const ipoint size,
const float &  iniValue = float() 
)

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

Parameters:
size lti::point with the size of the channel (size.x is the number of columns and size.y the number of rows)
iniValue all elements will be initialized with this value
lti::channel::channel ( const channel other,
const int &  fromRow = 0,
const int &  toRow = MaxInt32,
const int &  fromCol = 0,
const int &  toCol = MaxInt32 
)

copy constructor.

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

Parameters:
other the channel to be copied.
fromRow initial row of the other channel to be copied
toRow last row to be copied of the other channel
fromCol initial column of the other channel to be copied
toCol last column to be copied of the other channel

Example:

 lti::channel m(4,6,0); // channel with 24 elements
 // ...
 // initialize channel 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::channel 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::channel::channel ( const bool &  copyData,
channel other,
const int &  fromRow = 0,
const int &  toRow = MaxInt32,
const int &  fromCol = 0,
const int &  toCol = MaxInt32 
)

copy constructor (reference to a subchannel).

creates subchannel of another channel.

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 channel, which means that the data is not necessarily consecutive. (This will not be a connected but a lined channel)

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

Parameters:
copyData should the data of the other channel be copied or not
other the channel with the original data
fromRow initial row of the other channel to be copied
toRow last row to be copied of the other channel
fromCol initial column of the other channel to be copied
toCol last column to be copied of the other channel
lti::channel::channel ( const bool &  init,
const int &  rows,
const int &  cols 
)

If init is true this constructor is equivalent to calling channel(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:

 channel a(false,100,100);

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

If init is true this constructor is equivalent to calling channel(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:

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

 channel a;
 a.resize(100,100,0,false,false);
Parameters:
init initialize channel or not
size new size for the matrix (size.x columns, size.y rows)

Member Function Documentation

template<class U >
channel& lti::channel::castFrom ( const matrix< U > &  other  )  [inline]

copy the other matrix by casting each of its elements

Parameters:
other The matrix to be casted
Returns:
a reference to this channel

Reimplemented from lti::matrix< float >.

References castFrom().

channel& lti::channel::castFrom ( const image other  ) 

cast the image to an channel.

It extracts the intensity channel of the image, defined as (R+G+B)/3, where R, G, and B are the red, green and blue components of the pixel.

The elements of the resulting channel will be between 0.0f (black) and 1.0f (white).

Parameters:
other the image to be casted
Returns:
a reference to this channel
channel& lti::channel::castFrom ( const channel8 other  ) 

copy the other channel8 by casting each of its elements.

The elements of the channel8 will be also multiplied by 1/255.

Parameters:
other the channel8 to be casted
Returns:
a reference to this channel Example:
   lti::channel8 matA(10,10,255); // a channel8
   lti::channel  matB;            // a channel

   matB.castFrom(matA);         // this will copy matA in matB!!
                                // and all elements will have 1.0f

Referenced by castFrom().

virtual mathObject* lti::channel::clone (  )  const [virtual]

create a clone of this channel

Returns:
a pointer to a copy of this matrix

Reimplemented from lti::matrix< float >.

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

return the name of this type

Reimplemented from lti::matrix< float >.

channel& lti::channel::mapLinear ( const channel other,
const float &  minVal,
const float &  maxVal,
const float &  minDest = 0.0f,
const float &  maxDest = 1.0f 
)

Apply a gray valued transformation which maps the given intervall of the other channel into [0.0,1.0] (default) or the explicitly given "destination" interval in this channel.

Parameters:
other the other channel which values are to be mapped into the new interval
minVal the lower limit of the original data interval
maxVal the higher limit of the original data interval
minDest the lower limit of the mapped interval (default 0.0f)
maxDest the higher limit of the mapped interval (default 1.0f)
Returns:
a reference to this object

For example, if you want to map the interval [-1.0f,2.0f] to the "usual" interval [0.0,1.0] just use one of following methods:

 lti::channel chnl;
 // ...
 chnl.mapLinear(-1.0f,2.0f,0.0,1.0); // map [-1,2] to  [0,1]
 // this is equivalent to (due to default "destination" interval)
 chnl.mapLinear(-1.0f,2.0f);

Not that you can use this method to "invert" your gray values with

 chnl.mapLinear(0.0f,1.0f,1,0f,0.0f); // map [0,1] to  [1,0]
 // this is equivalent to (due to default "destination" interval)
 chnl.mapLinear(1.0f,0.0f);
channel& lti::channel::mapLinear ( const float &  minVal,
const float &  maxVal,
const float &  minDest = 0.0f,
const float &  maxDest = 1.0f 
)

Apply a gray valued transformation which maps the given intervall to [0.0,1.0] (default) or the explicitly given "destination" interval.

Parameters:
minVal the lower limit of the original data interval
maxVal the higher limit of the original data interval
minDest the lower limit of the mapped interval (default 0.0f)
maxDest the higher limit of the mapped interval (default 1.0f)
Returns:
a reference to this object

For example, if you want to map the interval [-1.0f,2.0f] to the "usual" interval [0.0,1.0] just use one of following methods:

 lti::channel chnl;
 // ...
 chnl.mapLinear(-1.0f,2.0f,0.0,1.0); // map [-1,2] to  [0,1]
 // this is equivalent to (due to default "destination" interval)
 chnl.mapLinear(-1.0f,2.0f);

Not that you can use this method to "invert" your gray values with

 chnl.mapLinear(0.0f,1.0f,1,0f,0.0f); // map [0,1] to  [1,0]
 // this is equivalent to (due to default "destination" interval)
 chnl.mapLinear(1.0f,0.0f);

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

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