last update 20 Sep 2009 |
#include <cvrChannel.h>
Public Member Functions | |
channel () | |
channel (const int rows, const int cols) | |
channel (const ipoint &size) | |
channel (const int rows, const int cols, const float &iniValue) | |
channel (const ipoint &size, const float &iniValue) | |
channel (const int rows, const int cols, const float data[]) | |
channel (const channel &other, const int fromRow, const int fromCol=0, const int toRow=MaxIndex, const int toCol=MaxIndex) | |
channel (const channel &other) | |
channel (const channel &other, const ipoint &from, const ipoint &to) | |
virtual const std::string & | name () const |
virtual channel * | clone () const |
virtual channel * | newInstance () const |
channel & | castFrom (const channel8 &other) |
channel & | castFrom (const image &other) |
template<typename U > | |
channel & | castFrom (const matrix< U > &other) |
channel & | mapLinear (const float &minVal, const float &maxVal, const float &minDest=0.0f, const float &maxDest=1.0f) |
template<typename U > | |
channel & | mapLinear (const matrix< U > &other, const U &minVal, const U &maxVal, const float &minDest=0.0f, const float &maxDest=1.0f) |
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 cvr::image for more information).
cvr::channel::channel | ( | ) |
Default constructor creates an empty channel.
cvr::channel::channel | ( | const int | rows, | |
const int | cols | |||
) |
cvr::channel::channel | ( | const ipoint & | size | ) |
Create a connected size.y
x size.x
channel and initializes all elements with iniValue.
size | cvr::ipoint with the size of the channel (size.x is the number of columns and size.y the number of rows) |
cvr::channel::channel | ( | const int | rows, | |
const int | cols, | |||
const float & | iniValue | |||
) |
cvr::channel::channel | ( | const ipoint & | size, | |
const float & | iniValue | |||
) |
Create a connected size.y
x size.x
channel and initializes all elements with iniValue.
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::channel::channel | ( | const int | rows, | |
const int | cols, | |||
const float | 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.
cvr::channel::channel | ( | const channel & | other, | |
const int | fromRow, | |||
const int | fromCol = 0 , |
|||
const int | toRow = MaxIndex , |
|||
const int | toCol = MaxIndex | |||
) |
Copy constructor.
Create a window from another channel.
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 |
cvr::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 cvr::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
cvr::channel::channel | ( | const channel & | other | ) |
Copy constructor.
Copy the other matrix by casting each of its elements.
other | The matrix to be casted |
References castFrom().
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).
other | the image to be casted |
Copy the other channel8 by casting each of its elements.
The elements of the channel8 will be also multiplied by 1/255.
other | the channel8 to be casted |
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 channel* cvr::channel::clone | ( | ) | const [virtual] |
Create a clone of this channel.
Reimplemented from cvr::matrix< float >.
channel & cvr::channel::mapLinear | ( | const matrix< U > & | other, | |
const U & | minVal, | |||
const U & | maxVal, | |||
const float & | minDest = 0.0f , |
|||
const float & | 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.
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) |
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< float >::allocate(), cvr::genericVector< T >::begin(), cvr::genericMatrix< float >::begin(), cvr::genericVector< T >::end(), cvr::matrix< T >::getRow(), cvr::genericMatrix< T >::rows(), and cvr::genericMatrix< T >::size().
channel& cvr::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.
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) |
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
virtual const std::string& cvr::channel::name | ( | ) | const [virtual] |
virtual channel* cvr::channel::newInstance | ( | ) | const [virtual] |
Create a new empty channel.
Reimplemented from cvr::matrix< float >.