last update 20 Sep 2009 |
#include <cvrChannel8.h>
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 channel8 * | clone () const |
virtual channel8 * | newInstance () const |
int | computeSumOfElements () const |
channel8 & | castFrom (const channel &other, const bool minToBlack=false, const bool maxToWhite=false) |
channel8 & | castFrom (const image &other) |
template<class U > | |
channel8 & | castFrom (const matrix< U > &other) |
channel8 & | mapLinear (const ubyte &minVal, const ubyte &maxVal, const ubyte &minDest=0, const ubyte &maxDest=255) |
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).
cvr::channel8::channel8 | ( | ) |
Default constructor creates an empty channel8.
cvr::channel8::channel8 | ( | const int | rows, | |
const int | cols | |||
) |
cvr::channel8::channel8 | ( | const ipoint & | size | ) |
Create a connected size.y
x size.x
channel8 and leave all elements uninitialized.
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 size.y
x size.x
Channel8 and initializes all elements with iniValue.
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.
cvr::channel8::channel8 | ( | const channel8 & | other | ) |
Copy constructor.
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.
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 |
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
Copy the other matrix by casting each of its elements.
other | The matrix to be cast |
References castFrom().
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).
other | the image to be cast |
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..
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. |
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.
Reimplemented from cvr::matrix< ubyte >.
int cvr::channel8::computeSumOfElements | ( | ) | const |
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.
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) |
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
virtual const std::string& cvr::channel8::name | ( | ) | const [virtual] |
virtual channel8* cvr::channel8::newInstance | ( | ) | const [virtual] |
Create a new empty channel8.
Reimplemented from cvr::matrix< ubyte >.