CVR-Lib last update 20 Sep 2009

cvr::usePalette Class Reference
[Region analysis]

Use color or gray-valued palette. More...

#include <cvrUsePalette.h>

Inheritance diagram for cvr::usePalette:

Inheritance graph
[legend]
Collaboration diagram for cvr::usePalette:

Collaboration graph
[legend]

List of all members.

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 > &regions, const vector< float > &values, fmatrix &dest) const
bool apply (const matrix< int > &regions, 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
usePalettecopy (const usePalette &other)
virtual usePaletteclone () const
virtual usePalettenewInstance () const
const parametersgetParameters () const
virtual bool updateParameters ()

Protected Member Functions

bool buildKdTree (const palette &pal)

Protected Attributes

kdTree< rgbaPixel, int > tree_
bool treeBuilded_


Detailed Description

Use color or gray-valued palette.

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.

See also:
cvr::computePalette

Constructor & Destructor Documentation

cvr::usePalette::usePalette (  ) 

default constructor

cvr::usePalette::usePalette ( const usePalette other  ) 

copy constructor

Parameters:
other the object to be copied

virtual cvr::usePalette::~usePalette (  )  [virtual]

destructor


Member Function Documentation

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.

Parameters:
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.

Parameters:
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 palette thePalette,
matrix< int > &  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<int>.

Note that with this method the parameters::colors attribute will be ignored.

Parameters:
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.

Parameters:
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,
matrix< int > &  chnl 
)

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>.

Parameters:
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 image img,
matrix< ubyte > &  chnl 
)

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>.

Parameters:
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.

Parameters:
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.
Returns:
true if successful, false otherwise.

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.

Parameters:
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.
Returns:
true if successful, false otherwise.

bool cvr::usePalette::apply ( const matrix< int > &  chnl,
const palette thePalette,
image other 
) const

Takes the matrix<int> and uses its elements as index for the given palette.

The result will be left in a new image.

Parameters:
chnl the matrix<int> with the indices for the palette
thePalette palette to be used
other the resulting image
Returns:
true if successful, false otherwise

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.

Parameters:
chnl the matrix<ubyte> with the indices for the palette
thePalette palette to be used
other the resulting image
Returns:
true if successful, false otherwise

bool cvr::usePalette::apply ( const matrix< int > &  chnl,
image other 
) const

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.

Parameters:
chnl the matrix<int> with the indices for the palette
other the resulting image
Returns:
true if successful, false otherwise

bool cvr::usePalette::apply ( const matrix< ubyte > &  chnl,
image other 
) const

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.

Parameters:
chnl the matrix<ubyte> with the indices for the palette
other the resulting image
Returns:
true if successful, false otherwise

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]

Returns a pointer to a clone of this functor.

Implements cvr::functor.

usePalette& cvr::usePalette::copy ( const usePalette other  ) 

Copy data of "other" functor.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

const kdTree<rgbaPixel,int>& cvr::usePalette::getKdTree (  )  const

Get a constant reference to the internal k-d tree.

const parameters& cvr::usePalette::getParameters (  )  const

Returns used parameters.

Reimplemented from cvr::parametersManager.

virtual const std::string& cvr::usePalette::name (  )  const [virtual]

returns the name of this type

Implements cvr::functor.

virtual usePalette* cvr::usePalette::newInstance (  )  const [virtual]

Returns a pointer to a new instance of this functor.

Implements cvr::functor.

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!

Returns:
true if successful, false otherwise

Reimplemented from cvr::parametersManager.


Member Data Documentation

The parameters palette is converted (if desired) into this k-d Tree.

The "data" type int states for the entry index.

Flag to indicate if the k-d Tree has already been build or not.


The documentation for this class was generated from the following file:

Generated on Sun Sep 20 22:08:53 2009 for CVR-Lib by Doxygen 1.5.8