MeVisLab Toolbox Reference
ml::LUTFunction Class Referenceabstract

Common base class for lookup tables. More...

#include <mlLUTFunction.h>

Inheritance diagram for ml::LUTFunction:
ml::Base ml::LUTFBlend ml::LUTFChannelMap ml::LUTFColor ml::LUTFCombine ml::LUTFCompose ml::LUTFConcat ml::LUTFLinear ml::LUTFPrimitive ml::LUTFRampPair ml::LUTFRescale ml::LUTFSelect

Public Member Functions

 LUTFunction (LUTVisualType vt, bool relative)
 Constructor. More...
 
void changed (void)
 Assign a new LUT ID. More...
 
void overwriteUniqueId (unsigned int newId)
 Overwrites the unique id. NOTE: use this only if you really know what you are doing! More...
 
LUT properties
virtual bool isValid (void) const
 Return true if the LUT function is valid. An invalid LUT function can not be rendered. More...
 
virtual LUTVisualType getVisualType (void) const
 Get LUT visual type. More...
 
virtual bool isRelative (void) const
 Is LUT relative? More...
 
virtual void setRelative (bool relative)
 Set/reset relative flag. More...
 
virtual LUTDimensionality getDimensionality (void) const
 Get dimensionality (1, 2, or 3), usually depending on height and depth. More...
 
virtual double getNativeMinIndex (void) const
 Get native minimum index. More...
 
virtual double getNativeMaxIndex (void) const
 Get native maximum index. More...
 
virtual int getHeight (void) const
 Get native LUT height (= number of rows, numbering starts at 0) More...
 
virtual int getDepth (void) const
 Get native LUT depth (= number of layers, numbering starts at 0) More...
 
virtual double getNativeMinValue (void) const
 Get native minimum LUT value. More...
 
virtual double getNativeMaxValue (void) const
 Get native maximum LUT value. More...
 
unsigned int getId (void) const
 Get current LUT ID. More...
 
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. More...
 
virtual bool renderRescaled (LUTDataBase *lutData, double minIndex, double maxIndex) const
 Render rescaled LUT in (previously initialized) LUTData object. More...
 
- Public Member Functions inherited from ml::Base
 Base ()
 Constructor. More...
 
virtual ~Base ()
 Destructor. More...
 
virtual BasedeepCopy () const
 Set addStateToTree version number that can be accessed via getAddStateVersion() More...
 
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. More...
 
virtual bool isRefCountedBase () const
 Returns if the instance is derived from RefCountedBase. More...
 
virtual std::string detailString () const
 Return a string describing this object. More...
 
virtual bool implementsPersistence (PersistenceInterface) const
 Override this method to declare which persistence interfaces are implemented by your derived class. More...
 
virtual std::string persistentState () const
 Returns a string describing the object's internal state. More...
 
virtual void setPersistentState (const std::string &state)
 Restores the object's internal state from a string that had been previously generated using persistentState(). More...
 
virtual void addStateToTree (TreeNode *) const
 Attaches the object state as children of the given parent node. More...
 
virtual void readStateFromTree (TreeNode *)
 Reads the object state from the children of the given parent node. More...
 
virtual void writeTo (AbstractPersistenceOutputStream *) const
 Write the objects state to the data stream object. More...
 
virtual void readFrom (AbstractPersistenceInputStream *, int)
 Read the objects state from the data stream object. More...
 

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

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 ... More...
 
template<typename T >
bool interpolateLUT (LUTData< T > *lutData, LUTIterator< T > *lutIterator, double minIndex, double maxIndex) const
 Perform type-specific rescaled LUT rendering by. More...
 
 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. More...
 
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. More...
 
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. More...
 
- Protected Member Functions inherited from ml::Base
virtual char * getPersistentState () const
 Returns a C string describing the object's internal state. More...
 
virtual void setPersistentState (const char *)
 Restores the object's internal state from a string that had been previously generated using getPersistentState(). More...
 
virtual void clearPersistentState (char *) const
 Disposes a string previously allocated by getPersistentState(). More...
 

Protected Attributes

LUTVisualType _visualType
 LUT visual type. More...
 
bool _relative
 Flag for relative LUT. More...
 
unsigned int _id
 Unique LUT ID, changed by the changed() method whenever a property of the LUT function object is modified. More...
 

Static Protected Attributes

static unsigned int _gNextId
 Global storage for next unused LUT ID to ensure uniqueness. More...
 

Additional Inherited Members

- Public Types inherited from ml::Base
enum  PersistenceInterface { PersistenceByString , PersistenceByTreeNode , PersistenceByStream }
 This enum describes the different persistence interfaces available. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ LUTFunction()

ml::LUTFunction::LUTFunction ( LUTVisualType  vt,
bool  relative 
)
inline

Constructor.

Definition at line 59 of file mlLUTFunction.h.

Member Function Documentation

◆ changed()

◆ generateUniqueId()

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.

◆ getDepth()

virtual int ml::LUTFunction::getDepth ( void  ) const
inlinevirtual

Get native LUT depth (= number of layers, numbering starts at 0)

Reimplemented in ml::LUTFRescale, ml::LUTFConcat, ml::LUTFCompose, ml::LUTFCombine, ml::LUTFColor, ml::LUTFChannelMap, and ml::LUTFBlend.

Definition at line 92 of file mlLUTFunction.h.

◆ getDimensionality()

virtual LUTDimensionality ml::LUTFunction::getDimensionality ( void  ) const
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.

◆ getHeight()

virtual int ml::LUTFunction::getHeight ( void  ) const
inlinevirtual

Get native LUT height (= number of rows, numbering starts at 0)

Reimplemented in ml::LUTFRescale, ml::LUTFConcat, ml::LUTFCompose, ml::LUTFCombine, ml::LUTFColor, ml::LUTFChannelMap, and ml::LUTFBlend.

Definition at line 89 of file mlLUTFunction.h.

◆ getId()

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 105 of file mlLUTFunction.h.

◆ getNativeMaxIndex()

virtual double ml::LUTFunction::getNativeMaxIndex ( void  ) const
inlinevirtual

◆ getNativeMaxValue()

virtual double ml::LUTFunction::getNativeMaxValue ( void  ) const
inlinevirtual

Get native maximum LUT value.

Reimplemented in ml::LUTFSelect, ml::LUTFRescale, ml::LUTFConcat, ml::LUTFCompose, ml::LUTFCombine, ml::LUTFColor, ml::LUTFChannelMap, and ml::LUTFBlend.

Definition at line 98 of file mlLUTFunction.h.

◆ getNativeMinIndex()

virtual double ml::LUTFunction::getNativeMinIndex ( void  ) const
inlinevirtual

◆ getNativeMinValue()

virtual double ml::LUTFunction::getNativeMinValue ( void  ) const
inlinevirtual

Get native minimum LUT value.

Reimplemented in ml::LUTFSelect, ml::LUTFRescale, ml::LUTFConcat, ml::LUTFCompose, ml::LUTFCombine, ml::LUTFColor, ml::LUTFChannelMap, and ml::LUTFBlend.

Definition at line 95 of file mlLUTFunction.h.

◆ getRenderType()

virtual LUTVisualType ml::LUTFunction::getRenderType ( LUTDataBase ) const
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::LUTFCompose, and ml::LUTFBlend.

Definition at line 156 of file mlLUTFunction.h.

◆ getVisualType()

virtual LUTVisualType ml::LUTFunction::getVisualType ( void  ) const
inlinevirtual

Get LUT visual type.

Reimplemented in ml::LUTFRescale.

Definition at line 70 of file mlLUTFunction.h.

◆ interpolateLUT()

template<typename T >
bool ml::LUTFunction::interpolateLUT ( LUTData< T > *  lutData,
LUTIterator< T > *  lutIterator,
double  minIndex,
double  maxIndex 
) const
protected

Perform type-specific rescaled LUT rendering by.

  • creating a second LUTData for the range minIndex .. maxIndex
  • calling renderT() to render the LUT
  • interpolating the second LUT for the range specified in lutData.

◆ isRelative()

virtual bool ml::LUTFunction::isRelative ( void  ) const
inlinevirtual

Is LUT relative?

Definition at line 73 of file mlLUTFunction.h.

◆ isValid()

virtual bool ml::LUTFunction::isValid ( void  ) const
inlinevirtual

Return true if the LUT function is valid. An invalid LUT function can not be rendered.

Reimplemented in ml::LUTFSelect, ml::LUTFRescale, ml::LUTFLinear, ml::LUTFConcat, ml::LUTFCompose, ml::LUTFCombine, ml::LUTFChannelMap, and ml::LUTFBlend.

Definition at line 67 of file mlLUTFunction.h.

◆ ML_ABSTRACT_CLASS_HEADER()

ml::LUTFunction::ML_ABSTRACT_CLASS_HEADER ( LUTFunction  )
protected

◆ overwriteUniqueId()

void ml::LUTFunction::overwriteUniqueId ( unsigned int  newId)

Overwrites the unique id. NOTE: use this only if you really know what you are doing!

◆ render()

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::LUTFConcat, ml::LUTFCompose, and ml::LUTFBlend.

◆ renderLUTNative()

virtual bool ml::LUTFunction::renderLUTNative ( LUTDataBase lutData,
LUTIteratorBase lutIterator 
) const
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::LUTFSelect, ml::LUTFRescale, ml::LUTFRampPair, ml::LUTFPrimitive, ml::LUTFLinear, ml::LUTFCompose, ml::LUTFCombine, ml::LUTFColor, ml::LUTFChannelMap, ml::LUTFBlend, and ml::LUTFConcat.

◆ renderLUTRescaled()

virtual bool ml::LUTFunction::renderLUTRescaled ( LUTDataBase lutData,
LUTIteratorBase lutIterator,
double  minIndex,
double  maxIndex 
) const
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::LUTFSelect, ml::LUTFRescale, ml::LUTFRampPair, ml::LUTFPrimitive, ml::LUTFLinear, ml::LUTFCompose, ml::LUTFCombine, ml::LUTFColor, ml::LUTFChannelMap, and ml::LUTFBlend.

◆ renderRescaled()

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::LUTFConcat, ml::LUTFCompose, and ml::LUTFBlend.

◆ renderT()

template<typename T >
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

◆ setRelative()

virtual void ml::LUTFunction::setRelative ( bool  relative)
inlinevirtual

Set/reset relative flag.

Reimplemented in ml::LUTFRescale, and ml::LUTFRampPair.

Definition at line 76 of file mlLUTFunction.h.

Member Data Documentation

◆ _gNextId

unsigned int ml::LUTFunction::_gNextId
staticprotected

Global storage for next unused LUT ID to ensure uniqueness.

Definition at line 215 of file mlLUTFunction.h.

◆ _id

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 211 of file mlLUTFunction.h.

◆ _relative

bool ml::LUTFunction::_relative
protected

Flag for relative LUT.

Definition at line 207 of file mlLUTFunction.h.

◆ _visualType

LUTVisualType ml::LUTFunction::_visualType
protected

LUT visual type.

Definition at line 204 of file mlLUTFunction.h.


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