last update 20 Sep 2009 |
#include <cvrImage.h>
Public Member Functions | |
image () | |
image (const int rows, const int cols) | |
image (const ipoint &size) | |
image (const int rows, const int cols, const rgbaPixel &iniValue) | |
image (const ipoint &size, const rgbaPixel &iniValue) | |
image (const int rows, const int cols, const rgbaPixel data[]) | |
image (const image &other) | |
image (const image &other, const ipoint &from, const ipoint &to) | |
image (const image &other, const int fromRow, const int fromCol=0, const int toRow=MaxIndex, const int toCol=MaxIndex) | |
virtual const std::string & | name () const |
virtual image * | clone () const |
virtual image * | newInstance () const |
image & | castFrom (const matrix< ubyte > &other) |
image & | castFrom (const fmatrix &other, const bool minToBlack=false, const bool maxToWhite=false) |
image & | castFrom (const matrix< int32 > &other, const bool minToBlack=false, const bool maxToWhite=false) |
image & | castFrom (const image &other) |
This class is an specialization of a matrix of cvr::rgbaPixel.
The concept for color images and gray valued images in the CVR-Lib is simple: they are specializations of the class cvr::matrix.
Several aspects must however be clarified. The rows of the matrix will represent horizontal lines in the image, and the columns vertical ones. The row with index zero will be the row at the top of the image. The column with row zero is the one at the left of the image. This means that the used coordinate system for the position of a pixel is "left-handed": the origin is situated at the top-left corner of the image, the x-coordinate gives the position in the horizontal axis and the y-coordinate the position in the vertical axis. In other words, the y coordinate give the row and x the column of the matrix. This fact is important to remember when accessing the image elements:
image img; // our image if (img.at(y,x) == img[y][x] == img.at(point(x,y))) { cout << "This is always true!"; } else { cout << "ERROR: it's imposible to get here"; exit 1; }
The gray valued channels cvr::channel and cvr::channel8 differ on the type and valid value ranges of their elements. The former accepts floating point values, with a default value range from 0.0 to 1.0. Many algorithms produce other values with specific meanings like angles or gradients, but using the default range you can assume 0.0 as a representation for black and 1.0 for white.
The cvr::channel8 is a much smaller representation but allows only integer values between 0 and 255, fact that can be advantageous in many algorithms. Here 0 usually means black and 255 white.
The cvr::image as cvr::matrix<cvr::rgbaPixel> allows the representation of true-color images, i.e. images with pixels that can be chosen from a palette of more than 16 million colors.
cvr::image::image | ( | ) |
Default constructor creates an empty image.
cvr::image::image | ( | const int | rows, | |
const int | cols | |||
) |
cvr::image::image | ( | const ipoint & | size | ) |
Create a connected size.y
x size.x
image but leave all elements uninitialized.
size | cvr::point with the size of the image (size.x is the number of columns and size.y the number of rows) |
cvr::image::image | ( | const int | rows, | |
const int | cols, | |||
const rgbaPixel & | iniValue | |||
) |
Creates a connected size.y
x size.x
image and initializes all elements with iniValue.
size | cvr::point with the size of the image (size.x is the number of columns and size.y the number of rows) | |
iniValue | all elements will be initialized with this value |
cvr::image::image | ( | const int | rows, | |
const int | cols, | |||
const rgbaPixel | data[] | |||
) |
Creates a connected rows
x cols
image 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::image::image | ( | const image & | other | ) |
cvr::image::image | ( | const image & | other, | |
const int | fromRow, | |||
const int | fromCol = 0 , |
|||
const int | toRow = MaxIndex , |
|||
const int | toCol = MaxIndex | |||
) |
Copy constructor.
Create this image as a connected copy of another image for this const version, the data will be always copied! It is also possible to create a copy of a subimage of another image.
other | the image to be copied. | |
fromRow | initial row of the other image to be copied | |
toRow | last row to be copied of the other image | |
fromCol | initial column of the other image to be copied | |
toCol | last column to be copied of the other image |
cvr::image m(4,6,0); // image with 24 elements // ... // initialize image 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::image 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
image& cvr::image::castFrom | ( | const matrix< int32 > & | other, | |
const bool | minToBlack = false , |
|||
const bool | maxToWhite = false | |||
) |
Cast from the other channel32.
For the transformation it assumes the channel as a gray valued channel where 0 means black and 1.0f means white. All other values will be clipped (less than zero to zero and more than 1.0 to 1.0)
other | the channel32 to be cast | |
minToBlack | if minToBlack is true, a linear gray-valued tranformation will be applied, which maps the minimal value in the channel to (0,0,0). 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,255,255). If false, the value 1.0f will be mapped to 255. |
cvr::channel matA(10,10,1.0f); // a channel cvr::image matB; // an image matB.castFrom(matA); // this will copy matA in matB!! // and all elements will have // rgbaPixel(255,255,255)
image& cvr::image::castFrom | ( | const fmatrix & | other, | |
const bool | minToBlack = false , |
|||
const bool | maxToWhite = false | |||
) |
Cast from the other fmatrix, intepreted as a single precision floating point channel.
For the transformation it assumes the channel as a gray valued channel where 0 means black and 1.0f means white. All other values will be clipped (less than zero to zero and more than 1.0 to 1.0)
other | the channel8 to be cast | |
minToBlack | if minToBlack is true, a linear gray-valued tranformation will be applied, which maps the minimal value in the channel to (0,0,0). 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,255,255). If false, the value 1.0f will be mapped to 255. |
cvr::channel matA(10,10,1.0f); // a channel cvr::image matB; // an image matB.castFrom(matA); // this will copy matA in matB!! // and all elements will have // rgbaPixel(255,255,255)
Cast from the other matrix<ubyte>, interpreted as a channel8.
For the transformation it assumes the channel8 as a gray valued channel where 0 means black and 255 means white.
other | the channel8 to be cast |
cvr::channel8 matA(10,10,255); // a channel8 cvr::image matB; // an image matB.castFrom(matA); // this will copy matA in matB!! // and all elements will have // rgbaPixel(255,255,255)
virtual image* cvr::image::clone | ( | ) | const [virtual] |
Create a clone of this image.
Reimplemented from cvr::matrix< rgbaPixel >.
virtual const std::string& cvr::image::name | ( | ) | const [virtual] |
virtual image* cvr::image::newInstance | ( | ) | const [virtual] |
Create a new empty image.
Reimplemented from cvr::matrix< rgbaPixel >.