last update 20 Sep 2009 |
#include <cvrViewer2DPainter.h>
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 () |
viewer2DPainter & | copy (const viewer2DPainter &other) |
viewer2DPainter & | operator= (const viewer2DPainter &other) |
virtual const std::string & | name () const |
virtual viewer2DPainter * | clone () const |
virtual viewer2DPainter * | newInstance () const |
void | setZoom (const float zoomFactor) |
const parameters & | getParameters () 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 | |
parameters & | getParameters () |
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 | |
histogramEqualization * | histEq_ |
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 () |
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.
anonymous enum |
Limit for the biggest allowable label in a channel32 for the label adjacency analysis.
enum cvr::viewer2DPainter::eChannelType [protected] |
Cache instance.
Enumeration used to indicate the type of gray-scale/brightness mapping used.
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 used to indicate which palette should be used when displaying channels, or on which channel should be applied the mapping if showing color images.
cvr::viewer2DPainter::viewer2DPainter | ( | ) |
Default constructor.
cvr::viewer2DPainter::viewer2DPainter | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
cvr::viewer2DPainter::viewer2DPainter | ( | const viewer2DPainter & | other | ) |
virtual cvr::viewer2DPainter::~viewer2DPainter | ( | ) | [virtual] |
Destructor.
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).
virtual bool cvr::viewer2DPainter::apply | ( | const matrix< int32 > & | src, | |
const irectangle & | viewport, | |||
image & | dest | |||
) | [virtual] |
virtual bool cvr::viewer2DPainter::apply | ( | const matrix< ubyte > & | src, | |
const irectangle & | viewport, | |||
image & | dest | |||
) | [virtual] |
virtual bool cvr::viewer2DPainter::apply | ( | const matrix< float > & | src, | |
const irectangle & | viewport, | |||
image & | dest | |||
) | [virtual] |
virtual bool cvr::viewer2DPainter::apply | ( | const matrix< rgbaPixel > & | src, | |
const irectangle & | viewport, | |||
image & | dest | |||
) | [virtual] |
Generate a new image to the given viewport.
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. |
virtual viewer2DPainter* cvr::viewer2DPainter::clone | ( | ) | const [virtual] |
bool cvr::viewer2DPainter::computeC8LUT | ( | ivector & | lut | ) | const [protected] |
Computes a LUT for a channel8 (or similar).
viewer2DPainter& cvr::viewer2DPainter::copy | ( | const viewer2DPainter & | other | ) |
parameters& cvr::viewer2DPainter::getParameters | ( | ) | [protected] |
const parameters& cvr::viewer2DPainter::getParameters | ( | ) | const |
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] |
virtual viewer2DPainter* cvr::viewer2DPainter::newInstance | ( | ) | const [virtual] |
viewer2DPainter& cvr::viewer2DPainter::operator= | ( | const viewer2DPainter & | other | ) |
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] |
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.
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! |
palette cvr::viewer2DPainter::blue_ [static, protected] |
palette
cacheManager cvr::viewer2DPainter::cache_ [protected] |
Cache instance.
palette cvr::viewer2DPainter::gray_ [static, protected] |
Gray palette.
palette cvr::viewer2DPainter::green_ [static, protected] |
palette
bool cvr::viewer2DPainter::haveNewParameters_ [protected] |
Flag to indicate that the parameters may have changed (the user called in the mean time setParameters(), useParameters(), etc.
histogramEqualization* cvr::viewer2DPainter::histEq_ [protected] |
Histogram equalization functor.
It is initialized only at construction time
palette cvr::viewer2DPainter::hue_ [static, protected] |
palette
palette cvr::viewer2DPainter::red_ [static, protected] |
palette
palette cvr::viewer2DPainter::user_ [protected] |
user palette that depends on the parameters