CVR-Lib last update 20 Sep 2009

cvr::viewer2DPainter Class Reference
[Visualization Tools]

Class viewer2DPainter. More...

#include <cvrViewer2DPainter.h>

Inheritance diagram for cvr::viewer2DPainter:

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

Collaboration graph
[legend]

List of all members.

Classes

class  cacheBlock
 Data computed for a channel and flags indicating if stats were already computed. More...
class  cacheManager
 A manager for all statistic blocks, computed (only if necessary) for the red, green, blue, hue and intensity channels of the data. More...
class  parameters
 Parameters of the cvr::viewer2DPainter class. More...

Public Types

enum  eMappingType {
  Original, OffsetSlope, MinToBlack, MaxToWhite,
  Optimal, HistogramEq, Log, OptimalLog,
  UserDefMap
}
enum  ePaletteType {
  GrayPalette, RedPalette, GreenPalette, BluePalette,
  HuePalette, UserDefPalette
}
enum  eNeighborhoodType { FourNeighborhood, EightNeighborhood }
enum  { BiggestLable = 307200 }

Public Member Functions

 viewer2DPainter ()
 viewer2DPainter (const parameters &par)
 viewer2DPainter (const viewer2DPainter &other)
virtual ~viewer2DPainter ()
virtual void invalidateCache ()
viewer2DPaintercopy (const viewer2DPainter &other)
viewer2DPainteroperator= (const viewer2DPainter &other)
virtual const std::string & name () const
virtual viewer2DPainterclone () const
virtual viewer2DPainternewInstance () const
void setZoom (const float zoomFactor)
const parametersgetParameters () const
virtual bool updateParameters ()
Apply methods to paint the whole image
bool apply (const matrix< rgbaPixel > &src, image &dest)
bool apply (const matrix< float > &src, image &dest)
bool apply (const matrix< ubyte > &src, image &dest)
bool apply (const matrix< int32 > &src, image &dest)
Apply methods to partially paint an image.
The view port is considered to denote the dimensions of an area in a canvas where the src data is to be painted on.

Please note that, due to the chosen zoom factor, such canvas may have a different size than the input data itself. The apply methods have to take care of all conversions of coordinate systems, as the viewport denote the canvas coordinates and not the src image coordinates.

If you are overloading these methods, you may find the method analyzeViewport() useful.

virtual bool apply (const matrix< rgbaPixel > &src, const irectangle &viewport, image &dest)
virtual bool apply (const matrix< float > &src, const irectangle &viewport, image &dest)
virtual bool apply (const matrix< ubyte > &src, const irectangle &viewport, image &dest)
virtual bool apply (const matrix< int32 > &src, const irectangle &viewport, image &dest)

Protected Member Functions

parametersgetParameters ()
void analyzeViewport (const irectangle &viewport, const ipoint &dataSize, const float &zoom, ipoint &startPx, ipoint &endPx) const
bool render (const matrix< rgbaPixel > &src, const ipoint from, const ipoint to, image &dest)
bool render (const matrix< float > &src, const ipoint from, const ipoint to, image &dest)
bool render (const matrix< ubyte > &src, const ipoint from, const ipoint to, image &dest)
bool renderLabels (const matrix< ubyte > &src, const ipoint from, const ipoint to, image &dest)
bool renderLabels (const matrix< int32 > &src, const ipoint from, const ipoint to, image &dest)
bool render (const matrix< int32 > &src, const ipoint from, const ipoint to, image &dest)
bool mapping (matrix< float > &srcDest, const eChannelType type) const
bool mapping (matrix< int32 > &srcDest, const eChannelType type) const
bool computeC8LUT (ivector &lut) const
virtual bool zoom (image &src, const irectangle &viewport, const float zoom, image &dest) const

Protected Attributes

histogramEqualizationhistEq_
Splitters and mergers
const splitImageToHSI splitHSI_
const mergeHSIToImage mergeHSI_
const splitImageToRGB splitRGB_
const mergeRGBToImage mergeRGB_

Cached data statistics

enum  eChannelType
cacheManager cache_
bool haveNewParameters_

Palettes

The channel representations can be colored using one of the following palettes

palette user_
static palette gray_
static palette red_
static palette green_
static palette blue_
static palette hue_
void initPalettes ()


Detailed Description

Class viewer2DPainter.

Class used to paint the 2D data as required by the cvr::viewer2D.

The apply() methods "render" an image corresponding to a window of the data to be visualized. They are not "const" since the viewer2DPainter administrates a cache for the statistics of the given images and some precomputations, in order to allow the required speed in the viewer classes.

Therefore, the apply methods are faster if they are always invoqued with the same source image, as the statistics are computed only the first time they are required.

The "cache miss" is computed based on very simple heuristics: the probability that two different images have exactly the same size and located on the same memory block is relatively low, so that the signature of the data is computed based on these "identifiers". If you have an application where you just fill always the same cvr::matrix (or derived) instance, then you have to call invalidateCache() first, to ensure that the statistics will be properly computed.


Member Enumeration Documentation

anonymous enum

Limit for the biggest allowable label in a channel32 for the label adjacency analysis.

Enumerator:
BiggestLable  assume that a mask of 640x480 has 1 label per pixel, which would produce in the worst case LUT of 1.2MB.

Cache instance.

Enumeration used to indicate the type of gray-scale/brightness mapping used.

Enumerator:
Original  Original image, without modifications.
OffsetSlope  Use a linear mapping with the given Offset and Slope.
MinToBlack  Map always the minimum value to black.
MaxToWhite  Map always the maximum value to white.
Optimal  Map the minimum to black and maximum to white.
HistogramEq  Equalize the brightness histogram.
Log  Logarithmic curve log(x+1)/log(256) where x is assumed to be between 0 a 255.

For channels it is used x*255.

OptimalLog  Like log, but an Optimal map is applied first.
UserDefMap  Use a user given LUT.

Enumeration type used to indicate the type of neighborhood used in the adjacency analysis.

Enumerator:
FourNeighborhood  4-Neighborhood
EightNeighborhood  8-Neighborhood

Enumeration used to indicate which palette should be used when displaying channels, or on which channel should be applied the mapping if showing color images.

Enumerator:
GrayPalette  Gray palette or intensity channel.
RedPalette  Red palette or red channel.
GreenPalette  Green palette or green channel.
BluePalette  Blue palette or blue channel.
HuePalette  Hue palette or hue channel.
UserDefPalette  A palette defined by the user or all RGB channels.


Constructor & Destructor Documentation

cvr::viewer2DPainter::viewer2DPainter (  ) 

Default constructor.

cvr::viewer2DPainter::viewer2DPainter ( const parameters par  ) 

Construct a functor using the given parameters.

cvr::viewer2DPainter::viewer2DPainter ( const viewer2DPainter other  ) 

Copy constructor.

Parameters:
other the object to be copied

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

Destructor.


Member Function Documentation

void cvr::viewer2DPainter::analyzeViewport ( const irectangle viewport,
const ipoint dataSize,
const float &  zoom,
ipoint startPx,
ipoint endPx 
) const [protected]

Get the start and end coordinates of the viewport but in the coordinate system of the original image.

If the viewport area corresponds to a region that exceeds the boundaries in the original image, then the returned startPx and endPx coordinates will be truncated to not exceed the area between (0,0) and dataSize-(1,1).

Parameters:
viewport section of the canvas that has to be rendered
dataSize size of the original data
zoom zoom factor
startPx coordinates of the upper-left point in the original data equivalent to the requested viewport.
endPx coordinates of the bottom-write point in the original data (inclusive)

virtual bool cvr::viewer2DPainter::apply ( const matrix< int32 > &  src,
const irectangle viewport,
image dest 
) [virtual]

Generate a new image.

Parameters:
src Original image
viewport section of the destination image to be rendered. The meaning of this rectangle depends on the zoom factor configured by the user.
dest Canvas where the region will be painted.
Returns:
true if the rendering was possible, false if not.

virtual bool cvr::viewer2DPainter::apply ( const matrix< ubyte > &  src,
const irectangle viewport,
image dest 
) [virtual]

Generate a new image.

Parameters:
src Original image
viewport section of the destination image to be rendered. The meaning of this rectangle depends on the zoom factor configured by the user.
dest Canvas where the region will be painted.
Returns:
true if the rendering was possible, false if not.

virtual bool cvr::viewer2DPainter::apply ( const matrix< float > &  src,
const irectangle viewport,
image dest 
) [virtual]

Generate a new image.

Parameters:
src Original image
viewport section of the destination image to be rendered. The meaning of this rectangle depends on the zoom factor configured by the user.
dest Canvas where the region will be painted.
Returns:
true if the rendering was possible, false if not.

virtual bool cvr::viewer2DPainter::apply ( const matrix< rgbaPixel > &  src,
const irectangle viewport,
image dest 
) [virtual]

Generate a new image to the given viewport.

Parameters:
src Original image
viewport section of the destination image to be rendered. The meaning of this rectangle depends on the zoom factor configured by the user.
dest Canvas where the region will be painted.
Returns:
true if the rendering was possible, false if not.

bool cvr::viewer2DPainter::apply ( const matrix< int32 > &  src,
image dest 
)

Generate a new image considering all viewer parameterization and store it in dest.

Parameters:
src channel with the source data.
dest image where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::viewer2DPainter::apply ( const matrix< ubyte > &  src,
image dest 
)

Generate a new image considering all viewer parameterization and store it in dest.

Parameters:
src channel with the source data.
dest image where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::viewer2DPainter::apply ( const matrix< float > &  src,
image dest 
)

Generate a new image considering all viewer parameterization and store it in dest.

Parameters:
src channel with the source data.
dest image where the result will be left.
Returns:
true if apply successful or false otherwise.

bool cvr::viewer2DPainter::apply ( const matrix< rgbaPixel > &  src,
image dest 
)

Generate a new image considering all viewer parameterization and store it in dest.

Parameters:
src image with the source data.
dest image where the result will be left.
Returns:
true if apply successful or false otherwise.

virtual viewer2DPainter* cvr::viewer2DPainter::clone (  )  const [virtual]

Returns a pointer to a clone of this functor.

Implements cvr::functor.

bool cvr::viewer2DPainter::computeC8LUT ( ivector lut  )  const [protected]

Computes a LUT for a channel8 (or similar).

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

Copy data of "other" functor.

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

parameters& cvr::viewer2DPainter::getParameters (  )  [protected]

Returns a read-write reference to the used parameters.

Reimplemented from cvr::parametersManager.

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

Returns used parameters.

Reimplemented from cvr::parametersManager.

void cvr::viewer2DPainter::initPalettes (  )  [protected]

Initialize all palettes.

virtual void cvr::viewer2DPainter::invalidateCache (  )  [virtual]

Ensure that the next apply called will force the computation of the required statistics.

bool cvr::viewer2DPainter::mapping ( matrix< int32 > &  srcDest,
const eChannelType  type 
) const [protected]

Computes on-place the intensity mapping.

It is assumed that the normal range is always from 0 to 255 The normal output will be in that range too.

bool cvr::viewer2DPainter::mapping ( matrix< float > &  srcDest,
const eChannelType  type 
) const [protected]

Computes on-place the intensity mapping.

It is assumed that the normal range is always from 0.0 to 1.0

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

Returns the complete name of the functor class.

Implements cvr::functor.

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

Returns a pointer to a new instance of this functor.

Implements cvr::functor.

viewer2DPainter& cvr::viewer2DPainter::operator= ( const viewer2DPainter other  ) 

Alias for copy member.

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

bool cvr::viewer2DPainter::render ( const matrix< int32 > &  src,
const ipoint  from,
const ipoint  to,
image dest 
) [protected]

Changes pixelwise the appearance of src but only the pixels from the point "from" to "to", and leaves the result in dest.

The dest image is always connected and owns its data.

bool cvr::viewer2DPainter::render ( const matrix< ubyte > &  src,
const ipoint  from,
const ipoint  to,
image dest 
) [protected]

Changes pixelwise the appearance of src but only the pixels from the point "from" to "to", and leaves the result in dest.

The dest image is always connected and owns its data.

bool cvr::viewer2DPainter::render ( const matrix< float > &  src,
const ipoint  from,
const ipoint  to,
image dest 
) [protected]

Changes pixelwise the appearance of src but only the pixels from the point "from" to "to", and leaves the result in dest.

The dest image is always connected and owns its data.

bool cvr::viewer2DPainter::render ( const matrix< rgbaPixel > &  src,
const ipoint  from,
const ipoint  to,
image dest 
) [protected]

Changes pixelwise the appearance of src but only the pixels from the point "from" to "to", and leaves the result in dest.

The dest image is always connected and owns its data.

bool cvr::viewer2DPainter::renderLabels ( const matrix< int32 > &  src,
const ipoint  from,
const ipoint  to,
image dest 
) [protected]

Changes pixelwise the appearance of src but only the pixels from the point "from" to "to", and leaves the result in dest, assuming that src is a labeled mask.

The dest image is always connected and owns its data.

bool cvr::viewer2DPainter::renderLabels ( const matrix< ubyte > &  src,
const ipoint  from,
const ipoint  to,
image dest 
) [protected]

Changes pixelwise the appearance of src but only the pixels from the point "from" to "to", and leaves the result in dest, assuming that src is a labeled mask.

The dest image is always connected and owns its data.

void cvr::viewer2DPainter::setZoom ( const float  zoomFactor  ) 

Set the zoom parameter to the value indicated.

The painter can be used with GUI tools that take care of the zoom, so it is handy to have a method that allows a direct change of the parameters object to set only the zoom value.

virtual bool cvr::viewer2DPainter::updateParameters (  )  [virtual]

Compute a correct user palette from the parameters.

Reimplemented from cvr::parametersManager.

virtual bool cvr::viewer2DPainter::zoom ( image src,
const irectangle viewport,
const float  zoom,
image dest 
) const [protected, virtual]

Zoom in or out the given image by the given factor leaving the result in dest and considering the "from" point that may indicate a partial part of the pixels.

Parameters:
src a reference to the source image, which is not const since it can be detached to the dest if it is possible. It has to be connected!
viewport coordinates of the viewport
zoom zoom factor
dest destination image, which must have the desired size already!
Returns:
true if successful or false otherwise.


Member Data Documentation

palette cvr::viewer2DPainter::blue_ [static, protected]

palette

Cache instance.

palette cvr::viewer2DPainter::gray_ [static, protected]

Gray palette.

palette

Flag to indicate that the parameters may have changed (the user called in the mean time setParameters(), useParameters(), etc.

Histogram equalization functor.

It is initialized only at construction time

palette cvr::viewer2DPainter::hue_ [static, protected]

palette

palette cvr::viewer2DPainter::red_ [static, protected]

palette

user palette that depends on the parameters


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

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