CVR-Lib last update 20 Sep 2009

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

A format for 8-bit channels. More...

#include <cvrChannel8.h>

Inheritance diagram for cvr::channel8:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

 channel8 ()
 channel8 (const int rows, const int cols)
 channel8 (const ipoint &size)
 channel8 (const int rows, const int cols, const ubyte &iniValue)
 channel8 (const ipoint &size, const ubyte &iniValue)
 channel8 (const int rows, const int cols, const ubyte data[])
 channel8 (const channel8 &other)
 channel8 (const channel8 &other, const ipoint &from, const ipoint &to)
 channel8 (const channel8 &other, const int fromRow, const int fromCol=0, const int toRow=MaxIndex, const int toCol=MaxIndex)
virtual const std::string & name () const
virtual channel8clone () const
virtual channel8newInstance () const
int computeSumOfElements () const
channel8castFrom (const channel &other, const bool minToBlack=false, const bool maxToWhite=false)
channel8castFrom (const image &other)
template<class U >
channel8castFrom (const matrix< U > &other)
channel8mapLinear (const ubyte &minVal, const ubyte &maxVal, const ubyte &minDest=0, const ubyte &maxDest=255)


Detailed Description

A format for 8-bit channels.

This class is identical to a matrix of bytes except for the method castFrom(channel)

The typical value range is between 0 and 255 (see cvr::image for more information).

See also:
cvr::image, cvr::channel

Constructor & Destructor Documentation

cvr::channel8::channel8 (  ) 

Default constructor creates an empty channel8.

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

Create a connected rows x cols channel8 and leave all elements uninitialized.

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

cvr::channel8::channel8 ( const ipoint size  ) 

Create a connected size.y x size.x channel8 and leave all elements uninitialized.

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

cvr::channel8::channel8 ( const int  rows,
const int  cols,
const ubyte iniValue 
)

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

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

cvr::channel8::channel8 ( const ipoint size,
const ubyte iniValue 
)

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

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

cvr::channel8::channel8 ( const int  rows,
const int  cols,
const ubyte  data[] 
)

Create a connected rows x cols Channel8 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 channel8
cols number of columns of the channel8
data pointer to the memory block with the data to be initialized with.

cvr::channel8::channel8 ( const channel8 other  ) 

Copy constructor.

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

Copy constructor.

Create this channel8 as a connected copy of a submatrix of another channel8.

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

Copy constructor.

Create this channel8 as a connected copy of another channel8 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 channel8 to be copied.
fromRow initial row of the other channel8 to be copied
fromCol initial column of the other channel8 to be copied
toRow last row to be copied of the other channel8
toCol last column to be copied of the other channel8
Example:
 cvr::channel8 m(4,6,0); // channel8 with 24 elements
 // ...
 // initialize channel8 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::channel8 sm(m,1,3,0,2)  // last line will leat to
 //                              following contents in sm:
 //        1  2  3
 //        1  5  4
 //        2  1  2


Member Function Documentation

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

Copy the other matrix by casting each of its elements.

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

References castFrom().

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

Cast the image to an channel8.

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 (black) and 255 (white).

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

channel8& cvr::channel8::castFrom ( const channel other,
const bool  minToBlack = false,
const bool  maxToWhite = false 
)

Copy the other channel by casting each of its elements.

The elements of the channel will be multiplied by 255 if no other parameter but the channel is given..

Parameters:
other the channel to be cast from
minToBlack if minToBlack is true, a linear gray-valued tranformation will be applied, which maps the minimal value in the channel to zero. 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. If false, the value 1.0f will be mapped to 255.
Returns:
a reference to this channel Example:
   cvr::channel matA(10,10,1); // a channel
   cvr::channel8  matB;          // a channel8

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

Referenced by castFrom().

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

Create a clone of this channel8.

Returns:
a pointer to a copy of this matrix

Reimplemented from cvr::matrix< ubyte >.

int cvr::channel8::computeSumOfElements (  )  const

Compute the sum of all elements in the channel.

Reimplemented from cvr::matrix< ubyte >.

channel8& cvr::channel8::mapLinear ( const ubyte minVal,
const ubyte maxVal,
const ubyte minDest = 0,
const ubyte maxDest = 255 
)

Apply a gray valued transformation which maps the given intervall to [0,255] (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)
maxDest the higher limit of the mapped interval (default 255)
Returns:
a reference to this object
For example, if you want to map the interval [20,200] to the "usual" interval [0,255] just use one of following methods:

 cvr::channel8 chnl;
 // ...
 chnl.mapLinear(20,200,0,255); // map [20,200] to  [0,255]
 // this is equivalent to (due to default "destination" interval)
 chnl.mapLinear(20,200);

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

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

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

Returns the name of this type.

Reimplemented from cvr::matrix< ubyte >.

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

Create a new empty channel8.

Returns:
a pointer to a copy of this matrix

Reimplemented from cvr::matrix< ubyte >.


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