CVR-Lib last update 20 Sep 2009

cvr::channelC Class Reference
[Aggregate Data TypesImage Processing and Analysis]

Complex channel. More...

#include <cvrChannelC.h>

Inheritance diagram for cvr::channelC:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 channelC ()
 channelC (const int rows, const int cols)
 channelC (const ipoint &size)
 channelC (const int rows, const int cols, const fcomplex &iniValue)
 channelC (const ipoint &size, const fcomplex &iniValue)
 channelC (const int rows, const int cols, const fcomplex data[])
 channelC (const channelC &other, const int fromRow, const int fromCol=0, const int toRow=MaxIndex, const int toCol=MaxIndex)
 channelC (const channelC &other)
 channelC (const channelC &other, const ipoint &from, const ipoint &to)
virtual const std::string & name () const
virtual channelCclone () const
virtual channelCnewInstance () const
channelCcastFrom (const channel8 &other)
channelCcastFrom (const image &other)
template<typename U >
channelCcastFrom (const matrix< U > &other)
void getReal (channel &real) const
void getImag (channel &imag) const
void getNorm (channel &smag) const
void getAbs (channel &mag) const
void getArg (channel &arg) const
void getArgFast (channel &arg) const
bool set (const channel &real, const channel &imag)
void get (channel &real, channel &imag) const
channelCmapLinear (const fcomplex &minVal, const fcomplex &maxVal, const fcomplex &minDest=0.0f, const fcomplex &maxDest=1.0f)
template<typename U >
channelCmapLinear (const matrix< U > &other, const U &minVal, const U &maxVal, const fcomplex &minDest=0.0f, const fcomplex &maxDest=1.0f)


Detailed Description

Complex channel.

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

The typical value range is between 0.0f and 1.0f for both, real and imaginary components (see cvr::image for more information).

See also:
cvr::image, cvr::channel8

Constructor & Destructor Documentation

cvr::channelC::channelC (  ) 

Default constructor creates an empty channel.

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

Create a connected rows x cols channel and leave the data uninitialized.

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

cvr::channelC::channelC ( const ipoint size  ) 

Create a connected size.y x size.x channel and initializes all elements with iniValue.

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

cvr::channelC::channelC ( const int  rows,
const int  cols,
const fcomplex iniValue 
)

Create 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

cvr::channelC::channelC ( const ipoint size,
const fcomplex iniValue 
)

Create a connected size.y x size.x channel and initializes all elements with iniValue.

Parameters:
size cvr::ipoint 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

cvr::channelC::channelC ( const int  rows,
const int  cols,
const fcomplex  data[] 
)

Create a connected rows x cols channel and initializes all elements with the data ipointed 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.

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

Copy constructor.

Create a window from another channelC.

Parameters:
other the channel to be copied.
fromRow initial row of the other channel to be copied
fromCol initial column of the other channel to be copied
toRow last row to be copied of the other channel
toCol last column to be copied of the other channel
Example:
 cvr::channelC 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

 cvr::channelC 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

cvr::channelC::channelC ( const channelC other  ) 

Copy constructor.

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

Copy constructor.

Create a window from another channel.

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


Member Function Documentation

template<class U >
channelC & cvr::channelC::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

References castFrom().

channelC& cvr::channelC::castFrom ( const image other  ) 

Cast the image to an channelC.

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) for the real part and zero as imaginary part.

Parameters:
other the image to be casted
Returns:
a reference to this channel

channelC& cvr::channelC::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:
   cvr::channel8 matA(10,10,255); // a channel8
   cvr::channel  matB;            // a channel

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

Referenced by castFrom().

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

Create a clone of this channel.

Returns:
a pointer to a copy of this matrix

Reimplemented from cvr::matrix< fcomplex >.

void cvr::channelC::get ( channel real,
channel imag 
) const

Get the real and imaginary parts as two different channels.

void cvr::channelC::getAbs ( channel mag  )  const

Extract the magnitude of each pixel.

This method is slower than getSqrMagnitude() as it has to apply the square root to each pixel.

void cvr::channelC::getArg ( channel arg  )  const

Extract the argument of each pixel (its angle).

This method is slow as it needs to apply the arctan to each pixel.

For time critical applications, use the getArgumentFast, which makes use of the cvr::arctanLUT, but is not as precise as this one.

void cvr::channelC::getArgFast ( channel arg  )  const

Extract the argument of each pixel (its angle) in a fast way.

This method requires that both the real and imaginary parts lie within the interval [0,1].

This method makes use of the cvr::arctanLUT to accelerate the computation of the angle. If you need very precise angular values, use the getArg() method instead.

void cvr::channelC::getImag ( channel imag  )  const

Extract the imaginary part of each pixel as a channel.

void cvr::channelC::getNorm ( channel smag  )  const

Extract the squared magnitude of each pixel.

This method is faster than getAbs() as it avoids taking the square root of each pixel.

void cvr::channelC::getReal ( channel real  )  const

Extract the real part of each pixel as a channel.

template<class U >
channelC & cvr::channelC::mapLinear ( const matrix< U > &  other,
const U &  minVal,
const U &  maxVal,
const fcomplex minDest = 0.0f,
const fcomplex maxDest = 1.0f 
) [inline]

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:

 cvr::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);

References cvr::genericMatrix< fcomplex >::allocate(), cvr::genericVector< T >::begin(), cvr::genericMatrix< fcomplex >::begin(), cvr::genericVector< T >::end(), cvr::matrix< T >::getRow(), cvr::genericMatrix< T >::rows(), and cvr::genericMatrix< T >::size().

channelC& cvr::channelC::mapLinear ( const fcomplex minVal,
const fcomplex maxVal,
const fcomplex minDest = 0.0f,
const fcomplex maxDest = 1.0f 
)

Apply a gray valued transformation which maps the given interval 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
A linear mapping is applied, where now the slope and offset are complex values computed by and analytical extension of the real counterpart.

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:

 cvr::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);

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

Returns the name of this type.

Reimplemented from cvr::matrix< fcomplex >.

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

Create a new empty channel.

Returns:
a pointer to new channel

Reimplemented from cvr::matrix< fcomplex >.

bool cvr::channelC::set ( const channel real,
const channel imag 
)

Set the real and imaginary parts from two different channels.

Both channels must have the same size. If they are not, the method returns false.


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

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