MeVisLab Toolbox Reference
|
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 double | getNativeMinIndex (void) const |
Get native minimum index. | |
virtual double | 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. | |
Public Member Functions inherited from ml::Base | |
Base () | |
Constructor. | |
virtual | ~Base () |
Destructor. | |
virtual Base * | deepCopy () const |
Set addStateToTree version number that can be accessed via getAddStateVersion() | |
bool | isOfAllowedType (const std::vector< const RuntimeType * > &types) const |
Check if this object's type is equal to or derived from one of the types given in the argument. | |
virtual bool | isRefCountedBase () const |
Returns if the instance is derived from RefCountedBase. | |
virtual std::string | detailString () const |
Return a string describing this object. | |
virtual bool | implementsPersistence (PersistenceInterface) const |
Override this method to declare which persistence interfaces are implemented by your derived class. | |
virtual std::string | persistentState () const |
Returns a string describing the object's internal state. | |
virtual void | setPersistentState (const std::string &state) |
Restores the object's internal state from a string that had been previously generated using persistentState() . | |
virtual void | addStateToTree (TreeNode *) const |
Attaches the object state as children of the given parent node. | |
virtual void | readStateFromTree (TreeNode *) |
Reads the object state from the children of the given parent node. | |
virtual void | writeTo (AbstractPersistenceOutputStream *) const |
Write the objects state to the data stream object. | |
virtual void | readFrom (AbstractPersistenceInputStream *, int) |
Read the objects state from the data stream 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 ... maxIndex) LUT rendering by. | |
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. | |
Additional Inherited Members | |
Public Types inherited from ml::Base | |
enum | PersistenceInterface { PersistenceByString , PersistenceByTreeNode , PersistenceByStream } |
This enum describes the different persistence interfaces available. More... | |
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 54 of file mlLUTFunction.h.
|
inline |
Constructor.
Definition at line 59 of file mlLUTFunction.h.
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::LUTFRampPair::setAlphaStart(), ml::LUTFRampPair::setAlphaWidth(), ml::LUTFRescale::setAutoSourceRange(), ml::LUTFPrimitive::setBaseValue(), ml::LUTFPrimitive::setCenter(), 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::LUTFColor::setVisualType(), and ml::LUTFPrimitive::setWidth().
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.
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 92 of file mlLUTFunction.h.
|
inlinevirtual |
Get dimensionality (1, 2, or 3), usually depending on height and depth.
Reimplemented in ml::LUTFBlend.
Definition at line 79 of file mlLUTFunction.h.
References ml::LUT_1D, ml::LUT_2D, and ml::LUT_3D.
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 89 of file mlLUTFunction.h.
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 105 of file mlLUTFunction.h.
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 86 of file mlLUTFunction.h.
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 98 of file mlLUTFunction.h.
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 83 of file mlLUTFunction.h.
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 95 of file mlLUTFunction.h.
|
inlineprotectedvirtual |
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 156 of file mlLUTFunction.h.
|
inlinevirtual |
Get LUT visual type.
Reimplemented in ml::LUTFRescale.
Definition at line 70 of file mlLUTFunction.h.
Is LUT relative?
Definition at line 73 of file mlLUTFunction.h.
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 67 of file mlLUTFunction.h.
|
protected |
Overwrites the unique id. NOTE: use this only if you really know what you are doing!
|
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.
|
protectedpure 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::LUTFConcat, ml::LUTFBlend, ml::LUTFChannelMap, ml::LUTFColor, ml::LUTFCombine, ml::LUTFCompose, ml::LUTFLinear, ml::LUTFPrimitive, ml::LUTFRampPair, ml::LUTFRescale, and ml::LUTFSelect.
|
protectedvirtual |
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 |
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.
|
protected |
Perform type-specific, native or rescaled (rescaled = true, rescale to range minIndex ... maxIndex) LUT rendering by.
Set/reset relative flag.
Reimplemented in ml::LUTFRampPair, and ml::LUTFRescale.
Definition at line 76 of file mlLUTFunction.h.
References mlrange_cast().
Global storage for next unused LUT ID to ensure uniqueness.
Definition at line 215 of file mlLUTFunction.h.
Unique LUT ID, changed by the changed() method whenever a property of the LUT function object is modified.
Definition at line 211 of file mlLUTFunction.h.
|
protected |
Flag for relative LUT.
Definition at line 207 of file mlLUTFunction.h.
|
protected |
LUT visual type.
Definition at line 204 of file mlLUTFunction.h.