latest version v1.9 - last update 10 Apr 2010 |
a format for 8-bit-channels. More...
#include <ltiImage.h>
Public Member Functions | |
channel8 () | |
channel8 (const int &rows, const int &cols, const ubyte &iniValue=ubyte()) | |
channel8 (const int &rows, const int &cols, const ubyte data[]) | |
channel8 (const ipoint &size, const ubyte &iniValue=ubyte()) | |
channel8 (const channel8 &other, const int &fromRow=0, const int &toRow=MaxInt32, const int &fromCol=0, const int &toCol=MaxInt32) | |
channel8 (const bool ©Data, channel8 &other, const int &fromRow=0, const int &toRow=MaxInt32, const int &fromCol=0, const int &toCol=MaxInt32) | |
channel8 (const bool &init, const int &rows, const int &cols) | |
channel8 (const bool &init, const ipoint &size) | |
virtual mathObject * | clone () const |
virtual const char * | getTypeName () const |
int | sumOfElements () 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) |
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 lti::image for more information).
lti::channel8::channel8 | ( | ) |
default constructor creates an empty channel8
lti::channel8::channel8 | ( | const int & | rows, | |
const int & | cols, | |||
const ubyte | data[] | |||
) |
this constructor creates 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.
this constructor creates a connected size.y x size.x
Channel8 and initializes all elements with iniValue
size | lti::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 |
lti::channel8::channel8 | ( | const channel8 & | other, | |
const int & | fromRow = 0 , |
|||
const int & | toRow = MaxInt32 , |
|||
const int & | fromCol = 0 , |
|||
const int & | toCol = MaxInt32 | |||
) |
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 | |
toRow | last row to be copied of the other channel8 | |
fromCol | initial column of the other channel8 to be copied | |
toCol | last column to be copied of the other channel8 |
Example:
lti::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 lti::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
lti::channel8::channel8 | ( | const bool & | copyData, | |
channel8 & | other, | |||
const int & | fromRow = 0 , |
|||
const int & | toRow = MaxInt32 , |
|||
const int & | fromCol = 0 , |
|||
const int & | toCol = MaxInt32 | |||
) |
copy constructor (reference to a subchannel8).
creates subchannel8 of another channel8.
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 channel8, which means that the data is not necessarily consecutive. (This will not be a connected but a lined channel8)
Those algorithms which use direct access to the channel8 memory block should check first if the memory lies in a consecutive block! (see getMode())
copyData | should the data of the other channel8 be copied or not | |
other | the channel with the original data | |
fromRow | initial row of the other channel8 to be copied | |
toRow | last row to be copied of the other channel8 | |
fromCol | initial column of the other channel8 to be copied | |
toCol | last column to be copied of the other channel8 |
lti::channel8::channel8 | ( | const bool & | init, | |
const int & | rows, | |||
const int & | cols | |||
) |
If init is true this constructor is equivalent to calling channel8(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:
lti::channel8::channel8 | ( | 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);
copy the other
matrix by casting each of its elements
other | The matrix to be casted |
Reimplemented from lti::matrix< ubyte >.
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 casted |
channel8& lti::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 casted 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. |
lti::channel matA(10,10,1); // a channel lti::channel8 matB; // a channel8 matB.castFrom(matA); // this will copy matA in matB!! // and all elements will have 255
Referenced by castFrom(), and lti::epsDraw< T >::drawImage().
virtual mathObject* lti::channel8::clone | ( | ) | const [virtual] |
create a clone of this channel
Reimplemented from lti::matrix< ubyte >.
virtual const char* lti::channel8::getTypeName | ( | ) | const [virtual] |
return the name of this type
Reimplemented from lti::matrix< ubyte >.
int lti::channel8::sumOfElements | ( | ) | const |
calculate the sum of all elements of the matrix.
This member can be used with classes which define the operator '+='
Reimplemented from lti::matrix< ubyte >.