last update 20 Sep 2009 |
#include <cvrUsePalette.h>
Classes | |
class | parameters |
the parameters for the class usePalette More... | |
Public Member Functions | |
usePalette () | |
usePalette (const usePalette &other) | |
virtual | ~usePalette () |
virtual const std::string & | name () const |
bool | apply (const matrix< ubyte > &chnl, image &other) const |
bool | apply (const matrix< int > &chnl, image &other) const |
bool | apply (const matrix< ubyte > &chnl, const palette &thePalette, image &other) const |
bool | apply (const matrix< int > &chnl, const palette &thePalette, image &other) const |
bool | apply (const matrix< ubyte > ®ions, const vector< float > &values, fmatrix &dest) const |
bool | apply (const matrix< int > ®ions, const vector< float > &values, fmatrix &dest) const |
bool | apply (const image &img, matrix< ubyte > &chnl) |
bool | apply (const image &img, matrix< int > &chnl) |
bool | apply (const image &img, const palette &thePalette, matrix< ubyte > &chnl) |
bool | apply (const image &img, const palette &thePalette, matrix< int > &chnl) |
bool | apply (const image &img, const kdTree< rgbaPixel, int > &tree, matrix< ubyte > &chnl) const |
bool | apply (const image &img, const kdTree< rgbaPixel, int > &tree, matrix< int > &chnl) const |
const kdTree< rgbaPixel, int > & | getKdTree () const |
usePalette & | copy (const usePalette &other) |
virtual usePalette * | clone () const |
virtual usePalette * | newInstance () const |
const parameters & | getParameters () const |
virtual bool | updateParameters () |
Protected Member Functions | |
bool | buildKdTree (const palette &pal) |
Protected Attributes | |
kdTree< rgbaPixel, int > | tree_ |
bool | treeBuilded_ |
This class has two uses:
For the second operation mode you can choose in the parameters to use a cvr::kdTree in order to avoid a "brute-force" search.
cvr::usePalette::usePalette | ( | ) |
default constructor
cvr::usePalette::usePalette | ( | const usePalette & | other | ) |
virtual cvr::usePalette::~usePalette | ( | ) | [virtual] |
destructor
bool cvr::usePalette::apply | ( | const image & | img, | |
const kdTree< rgbaPixel, int > & | tree, | |||
matrix< int > & | chnl | |||
) | const |
Find for each pixel in the given image the nearest entry in the given k-d Tree and leave the data component of that entry in the correspondig pixel of the matrix<ubyte>.
Note that with this method the parameters::colors attribute or previously computed k-d trees will be ignored.
img | the color image (true color) | |
tree | k-d Tree coding a color palette. The index in the integer data component of the tree elements will be assumed to be the index of a color palette. | |
chnl | the data of the nearest component for each pixel in img will be stored in the correponding pixel of this channel. |
bool cvr::usePalette::apply | ( | const image & | img, | |
const kdTree< rgbaPixel, int > & | tree, | |||
matrix< ubyte > & | chnl | |||
) | const |
Find for each pixel in the given image the nearest entry in the given k-d Tree and leave the data component of that entry in the correspondig pixel of the matrix<ubyte>.
Note that with this method the parameters::colors attribute or previously computed k-d trees will be ignored.
img | the color image (true color) | |
tree | k-d Tree coding a color palette. The index in the integer data component of the tree elements will be assumed to be the index of a color palette. | |
chnl | the data of the nearest component for each pixel in img will be stored in the correponding pixel of this channel. |
Find for each pixel in the given image the best entry of the given palette and leave the index of that entry in the correspondig pixel of the matrix<int>.
Note that with this method the parameters::colors attribute will be ignored.
img | the color image (true color) | |
thePalette | a color palette. The index of the most similar color entry within this palette to each pixel of the img will be left in the chnl | |
chnl | the indices for each pixel in img of the correponding palette entry in thePalette |
bool cvr::usePalette::apply | ( | const image & | img, | |
const palette & | thePalette, | |||
matrix< ubyte > & | chnl | |||
) |
Find for each pixel in the given image the best entry of the given palette and leave the index of that entry in the correspondig pixel of the matrix<ubyte>.
Note that with this method the parameters::colors attribute will be ignored. The internal k-d Tree will be computed using thePalette given here.
img | the color image (true color) | |
thePalette | a color palette. The index of the most similar color entry within this palette to each pixel of the img will be left in the chnl | |
chnl | the indices for each pixel in img of the correponding palette entry in thePalette |
Find for each pixel in the given image the best entry in the palette found in the parameters and leave the index of the entry in the correspondig pixel of the matrix<int>.
img | the color image (true color) | |
chnl | the indices for each pixel in img of the correponding palette entry in the parameters object |
For each pixel in the given image, find the "best" entry in the palette found in the parameters and leave the index of the entry in the correspondig pixel of the matrix<ubyte>.
img | the color image (true color) | |
chnl | the indices for each pixel in img of the correponding palette entry in the parameters object |
bool cvr::usePalette::apply | ( | const matrix< int > & | regions, | |
const vector< float > & | values, | |||
fmatrix & | dest | |||
) | const |
Use gray valued palette.
This method is provided for completeness. It is not for color images, but for gray valued ones, but since the principle used is the same than with colored palettes, the method seems to be in a proper place here. It complements the corresponding apply method of cvr::computePalette to compute gray-valued palettes from channels.
regions | regions map, containing for each region a palette index entry. | |
values | gray-valued palette entries. For each region with index i, the output channel will contain values.at(i). | |
dest | output channel, the result of using the gray-valued palette for the given regions map will be left here. |
bool cvr::usePalette::apply | ( | const matrix< ubyte > & | regions, | |
const vector< float > & | values, | |||
fmatrix & | dest | |||
) | const |
Use gray valued palette.
This method is provided for completeness. It is not for color images, but for gray valued ones, but since the principle used is the same than with colored palettes, the method seems to be in a proper place here. It complements the corresponding apply method of cvr::computePalette to compute gray-valued palettes from channels.
regions | regions map, containing for each region a palette index entry. | |
values | gray-valued palette entries. For each region with index i, the output channel will contain values.at(i). | |
dest | output channel, the result of using the gray-valued palette for the given regions map will be left here. |
bool cvr::usePalette::apply | ( | const matrix< ubyte > & | chnl, | |
const palette & | thePalette, | |||
image & | other | |||
) | const |
Takes the matrix<ubyte> and uses its elements as index for the given palette.
The result will be left in a new image.
chnl | the matrix<ubyte> with the indices for the palette | |
thePalette | palette to be used | |
other | the resulting image |
Takes the matrix<int> and uses its elements as index for the palette in the parameters.
The result will be left in a new image.
chnl | the matrix<int> with the indices for the palette | |
other | the resulting image |
Takes the matrix<ubyte> and uses its elements as index for the palette in the parameters.
The result will be left in a new image.
chnl | the matrix<ubyte> with the indices for the palette | |
other | the resulting image |
bool cvr::usePalette::buildKdTree | ( | const palette & | pal | ) | [protected] |
Build the k-d Tree from the given color palette.
virtual usePalette* cvr::usePalette::clone | ( | ) | const [virtual] |
usePalette& cvr::usePalette::copy | ( | const usePalette & | other | ) |
Get a constant reference to the internal k-d tree.
const parameters& cvr::usePalette::getParameters | ( | ) | const |
virtual const std::string& cvr::usePalette::name | ( | ) | const [virtual] |
virtual usePalette* cvr::usePalette::newInstance | ( | ) | const [virtual] |
virtual bool cvr::usePalette::updateParameters | ( | ) | [virtual] |
Set functor's parameters.
This member makes a copy of theParam: the functor will keep its own copy of the parameters!
Reimplemented from cvr::parametersManager.
kdTree<rgbaPixel,int> cvr::usePalette::tree_ [protected] |
The parameters palette is converted (if desired) into this k-d Tree.
The "data" type int states for the entry index.
bool cvr::usePalette::treeBuilded_ [protected] |
Flag to indicate if the k-d Tree has already been build or not.