MeVisLabToolboxReference
|
Common base class for lookup tables. More...
#include <mlLUTFunction.h>
Public Member Functions | |
LUTFunction (LUTVisualType vt, bool relative) | |
Constructor. | |
void | changed (void) |
Assign a new LUT ID. | |
void | overwriteUniqueId (unsigned int newId) |
Overwrites the unique id. NOTE: use this only if you really know what you are doing! | |
LUT properties | |
virtual bool | isValid (void) const |
Return true if the LUT function is valid. An invalid LUT function can not be rendered. | |
virtual LUTVisualType | getVisualType (void) const |
Get LUT visual type. | |
virtual bool | isRelative (void) const |
Is LUT relative? | |
virtual void | setRelative (bool relative) |
Set/reset relative flag. | |
virtual LUTDimensionality | getDimensionality (void) const |
Get dimensionality (1, 2, or 3), usually depending on height and depth. | |
virtual int | getNativeMinIndex (void) const |
Get native minimum index. | |
virtual int | getNativeMaxIndex (void) const |
Get native maximum index. | |
virtual int | getHeight (void) const |
Get native LUT height (= number of rows, numbering starts at 0) | |
virtual int | getDepth (void) const |
Get native LUT depth (= number of layers, numbering starts at 0) | |
virtual double | getNativeMinValue (void) const |
Get native minimum LUT value. | |
virtual double | getNativeMaxValue (void) const |
Get native maximum LUT value. | |
unsigned int | getId (void) const |
Get current LUT ID. | |
LUT rendering | |
These methods are called by LUT users to obtain a rendering of the LUT function. | |
virtual bool | render (LUTDataBase *lutData) const |
Render LUT in (previously initialized) LUTData object. | |
virtual bool | renderRescaled (LUTDataBase *lutData, double minIndex, double maxIndex) const |
Render rescaled LUT in (previously initialized) LUTData object. | |
Static Public Member Functions | |
static unsigned int | generateUniqueId (void) |
Generate a unique id (unique for all mlLUTFunctions), this can also be called to get a unique id for a LUTData object manually. | |
Protected Member Functions | |
template<typename T > | |
bool | renderT (LUTData< T > *lutData, bool rescaled, double minIndex, double maxIndex) const |
Perform type-specific, native or rescaled (rescaled = true, rescale to range minIndex ... | |
template<typename T > | |
bool | interpolateLUT (LUTData< T > *lutData, LUTIterator< T > *lutIterator, double minIndex, double maxIndex) const |
Perform type-specific rescaled LUT rendering by. | |
ML_ABSTRACT_CLASS_HEADER (LUTFunction) | |
LUT implementation | |
These methods are overloaded to define the LUT function | |
virtual LUTVisualType | getRenderType (LUTDataBase *) const |
Get visual type used for rendering. | |
virtual bool | renderLUTNative (LUTDataBase *lutData, LUTIteratorBase *lutIterator) const =0 |
Render a single row of the lookup table into lutData using lutIterator to access and increment the LUT pointers and to identify the current row and layer. | |
virtual bool | renderLUTRescaled (LUTDataBase *lutData, LUTIteratorBase *lutIterator, double minIndex, double maxIndex) const |
Render a single row of a rescaled LUT into lutData using lutIterator to access and increment the LUT pointers and to identify the current row and layer. | |
Protected Attributes | |
LUTVisualType | _visualType |
LUT visual type. | |
bool | _relative |
Flag for relative LUT. | |
unsigned int | _id |
Unique LUT ID, changed by the changed() method whenever a property of the LUT function object is modified. | |
Static Protected Attributes | |
static unsigned int | _gNextId |
Global storage for next unused LUT ID to ensure uniqueness. |
Common base class for lookup tables.
A class derived from LUTFunction represents an abstract lookup table (LUT) defining the mapping of index values to LUT entry values. Despite its name, a LUTFunction is not a table, i.e. the LUT entries are not specified for a fixed set of index values. Instead, a LUTFunction defines the methods render() and renderRescaled() that generate LUT entry values for an arbitrary index range. The table data generated when a LUT is rendered is stored in a LUTData object.
In addition to the usual one-dimensional lookup tables, there are also two- and three-dimensional LUTs, consisting of several 1D-LUTs arranged in rows and layers. The index range for rows and layers always starts at 0 and is absolute. Rescaling with respect to the row or layer range is not supported.
To implement a lookup table, derive a class from LUTFunction and overload the methods renderLUTNative() and renderLUTRescaled() and use the LUTIterator object to access the LUTData. If necessary, also overload the methods defining the LUT properties and the getRenderType() methods. Make sure to call the changed() method whenever a property of the LUT changes. This will allow a user of the LUT to decide whether it is necessary to re-render the LUT.
Definition at line 62 of file mlLUTFunction.h.
ml::LUTFunction::LUTFunction | ( | LUTVisualType | vt, |
bool | relative | ||
) | [inline] |
Constructor.
Definition at line 67 of file mlLUTFunction.h.
void ml::LUTFunction::changed | ( | void | ) |
Assign a new LUT ID.
This method has to be called whenever a property of the LUT object is modified.
Referenced by ml::LUTFRampPair::setAlphaCenter(), ml::LUTFRampPair::setAlphaEnd(), ml::LUTFLinear::setAlphaFactor(), ml::LUTFRampPair::setAlphaStart(), ml::LUTFRampPair::setAlphaWidth(), ml::LUTFRescale::setAutoSourceRange(), ml::LUTFPrimitive::setBaseValue(), ml::LUTFPrimitive::setCenter(), ml::LUTFLinear::setColorInterpolation(), ml::LUTFPrimitive::setEdgeWidth(), ml::LUTFSelect::setLayer(), ml::LUTFPrimitive::setPeakValue(), ml::LUTFCompose::setResolution(), ml::LUTFRampPair::setRGBCenter(), ml::LUTFRampPair::setRGBWidth(), ml::LUTFSelect::setRow(), ml::LUTFPrimitive::setShape(), ml::LUTFLinear::setVisualType(), ml::LUTFColor::setVisualType(), and ml::LUTFPrimitive::setWidth().
static unsigned int ml::LUTFunction::generateUniqueId | ( | void | ) | [static] |
Generate a unique id (unique for all mlLUTFunctions), this can also be called to get a unique id for a LUTData object manually.
The id 0 is never returned and can safely be used as an invalid/unknown id.
virtual int ml::LUTFunction::getDepth | ( | void | ) | const [inline, virtual] |
Get native LUT depth (= number of layers, numbering starts at 0)
Reimplemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFConcat, and ml::LUTFRescale.
Definition at line 100 of file mlLUTFunction.h.
virtual LUTDimensionality ml::LUTFunction::getDimensionality | ( | void | ) | const [inline, virtual] |
Get dimensionality (1, 2, or 3), usually depending on height and depth.
Reimplemented in ml::LUTFBlend.
Definition at line 87 of file mlLUTFunction.h.
References ml::LUT_1D, ml::LUT_2D, and ml::LUT_3D.
virtual int ml::LUTFunction::getHeight | ( | void | ) | const [inline, virtual] |
Get native LUT height (= number of rows, numbering starts at 0)
Reimplemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFConcat, and ml::LUTFRescale.
Definition at line 97 of file mlLUTFunction.h.
unsigned int ml::LUTFunction::getId | ( | void | ) | const [inline] |
Get current LUT ID.
The ID is a unique number identifying the state of a LUT object. It is modified whenever a property of the LUT object changes. When the LUT is rendered, the current value of the LUT ID is stored in the LUTData object. This allows to check whether a rendered LUT needs to be updated.
Definition at line 113 of file mlLUTFunction.h.
virtual int ml::LUTFunction::getNativeMaxIndex | ( | void | ) | const [inline, virtual] |
Get native maximum index.
Reimplemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFConcat, ml::LUTFLinear, ml::LUTFPrimitive, ml::LUTFRampPair, ml::LUTFRescale, and ml::LUTFSelect.
Definition at line 94 of file mlLUTFunction.h.
virtual double ml::LUTFunction::getNativeMaxValue | ( | void | ) | const [inline, virtual] |
Get native maximum LUT value.
Reimplemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFConcat, ml::LUTFRescale, and ml::LUTFSelect.
Definition at line 106 of file mlLUTFunction.h.
virtual int ml::LUTFunction::getNativeMinIndex | ( | void | ) | const [inline, virtual] |
Get native minimum index.
Reimplemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFConcat, ml::LUTFLinear, ml::LUTFPrimitive, ml::LUTFRampPair, ml::LUTFRescale, and ml::LUTFSelect.
Definition at line 91 of file mlLUTFunction.h.
virtual double ml::LUTFunction::getNativeMinValue | ( | void | ) | const [inline, virtual] |
Get native minimum LUT value.
Reimplemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFConcat, ml::LUTFRescale, and ml::LUTFSelect.
Definition at line 103 of file mlLUTFunction.h.
virtual LUTVisualType ml::LUTFunction::getRenderType | ( | LUTDataBase * | ) | const [inline, protected, virtual] |
Get visual type used for rendering.
This method is called by render() and renderRescaled() to initialize the LUT iterator object appropriate for a pair of source/target visual types. By default, LUT's visual type is returned, independent of the target visual type of the LUTData object. A derived class may overload this method in case it supports rendering into several visual types by itself.
Reimplemented in ml::LUTFBlend, and ml::LUTFCompose.
Definition at line 164 of file mlLUTFunction.h.
virtual LUTVisualType ml::LUTFunction::getVisualType | ( | void | ) | const [inline, virtual] |
Get LUT visual type.
Reimplemented in ml::LUTFRescale.
Definition at line 78 of file mlLUTFunction.h.
bool ml::LUTFunction::interpolateLUT | ( | LUTData< T > * | lutData, |
LUTIterator< T > * | lutIterator, | ||
double | minIndex, | ||
double | maxIndex | ||
) | const [protected] |
virtual bool ml::LUTFunction::isRelative | ( | void | ) | const [inline, virtual] |
Is LUT relative?
Definition at line 81 of file mlLUTFunction.h.
virtual bool ml::LUTFunction::isValid | ( | void | ) | const [inline, virtual] |
Return true if the LUT function is valid. An invalid LUT function can not be rendered.
Reimplemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFConcat, ml::LUTFLinear, ml::LUTFRescale, and ml::LUTFSelect.
Definition at line 75 of file mlLUTFunction.h.
ml::LUTFunction::ML_ABSTRACT_CLASS_HEADER | ( | LUTFunction | ) | [protected] |
void ml::LUTFunction::overwriteUniqueId | ( | unsigned int | newId | ) |
Overwrites the unique id. NOTE: use this only if you really know what you are doing!
virtual bool ml::LUTFunction::render | ( | LUTDataBase * | lutData | ) | const [virtual] |
Render LUT in (previously initialized) LUTData object.
Return true if successful.
To define a LUT in a derived class, overload the renderLUTNative() method.
Reimplemented in ml::LUTFBlend, ml::LUTFCompose, and ml::LUTFConcat.
virtual bool ml::LUTFunction::renderLUTNative | ( | LUTDataBase * | lutData, |
LUTIteratorBase * | lutIterator | ||
) | const [protected, pure virtual] |
Render a single row of the lookup table into lutData using lutIterator to access and increment the LUT pointers and to identify the current row and layer.
When rendering a 2/3D-LUT, lutData represents only the row currently rendered. Both lutData and lutIterator should be type-cast to a derived, type specific class pointer, according to lutData->getDataType(). Return true if successful. This method is overloaded by a derived class to actually define the LUT.
Implemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFConcat, ml::LUTFLinear, ml::LUTFPrimitive, ml::LUTFRampPair, ml::LUTFRescale, and ml::LUTFSelect.
virtual bool ml::LUTFunction::renderLUTRescaled | ( | LUTDataBase * | lutData, |
LUTIteratorBase * | lutIterator, | ||
double | minIndex, | ||
double | maxIndex | ||
) | const [protected, virtual] |
Render a single row of a rescaled LUT into lutData using lutIterator to access and increment the LUT pointers and to identify the current row and layer.
When rendering a 2/3D-LUT, lutData represents only the row currently rendered. Both lutData and lutIterator should be type-cast to a derived, type specific class pointer, according to lutData->getDataType(). The LUT is rendered for range minIndex .. maxIndex, but resampled to the index range specified in lutData. Return true if successful.
The default implementation renders the original LUT for the given range and rescales by interpolation. A derived LUT function may overload this method for higher efficiency/precision.
Reimplemented in ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFLinear, ml::LUTFPrimitive, ml::LUTFRampPair, ml::LUTFRescale, and ml::LUTFSelect.
virtual bool ml::LUTFunction::renderRescaled | ( | LUTDataBase * | lutData, |
double | minIndex, | ||
double | maxIndex | ||
) | const [virtual] |
Render rescaled LUT in (previously initialized) LUTData object.
LUT is rendered for range minIndex .. maxIndex, but resampled to the index range specified in lutData. Return true if successful
The default implementation renders the original LUT for the given range and rescales by interpolation. A derived LUT function may overload this method for higher efficiency/precision.
Reimplemented in ml::LUTFBlend, ml::LUTFCompose, and ml::LUTFConcat.
bool ml::LUTFunction::renderT | ( | LUTData< T > * | lutData, |
bool | rescaled, | ||
double | minIndex, | ||
double | maxIndex | ||
) | const [protected] |
Perform type-specific, native or rescaled (rescaled = true, rescale to range minIndex ...
maxIndex) LUT rendering by
virtual void ml::LUTFunction::setRelative | ( | bool | relative | ) | [inline, virtual] |
Set/reset relative flag.
Reimplemented in ml::LUTFRampPair, and ml::LUTFRescale.
Definition at line 84 of file mlLUTFunction.h.
unsigned int ml::LUTFunction::_gNextId [static, protected] |
Global storage for next unused LUT ID to ensure uniqueness.
Definition at line 223 of file mlLUTFunction.h.
unsigned int ml::LUTFunction::_id [protected] |
Unique LUT ID, changed by the changed() method whenever a property of the LUT function object is modified.
Definition at line 219 of file mlLUTFunction.h.
bool ml::LUTFunction::_relative [protected] |
Flag for relative LUT.
Definition at line 215 of file mlLUTFunction.h.
LUTVisualType ml::LUTFunction::_visualType [protected] |
LUT visual type.
Definition at line 212 of file mlLUTFunction.h.