MeVisLab Toolbox Reference
mlLUTFunction.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_LUTFUNCTION_H
14 #define ML_LUTFUNCTION_H
15 
16 
18 
19 #include "mlLUTSystem.h"
20 #include "mlLUTBasic.h"
21 #include "mlLUTData.h"
22 #include "mlLUTIterator.h"
23 
24 // ML includes
25 #include "mlBase.h"
26 
27 
28 ML_START_NAMESPACE
29 
32 #define ML_LUT_NATIVE_MINMAX_DOUBLE 1
33 
55 {
56 public:
57 
59  LUTFunction (LUTVisualType vt, bool relative)
60  : _visualType(vt), _relative(relative) {}
61 
62 
65 
67  virtual bool isValid (void) const { return true; }
68 
70  virtual LUTVisualType getVisualType (void) const { return _visualType; }
71 
73  virtual bool isRelative (void) const { return _relative; }
74 
76  virtual void setRelative (bool relative) { _relative = relative; changed(); }
77 
79  virtual LUTDimensionality getDimensionality (void) const
80  { return (getDepth() > 1) ? LUT_3D : (getHeight() > 1) ? LUT_2D : LUT_1D; }
81 
83  virtual double getNativeMinIndex (void) const { return 0; }
84 
86  virtual double getNativeMaxIndex (void) const { return 1; }
87 
89  virtual int getHeight (void) const { return 1; }
90 
92  virtual int getDepth (void) const { return 1; }
93 
95  virtual double getNativeMinValue (void) const { return 0; }
96 
98  virtual double getNativeMaxValue (void) const { return 1; }
99 
105  unsigned int getId (void) const { return _id; }
106 
108 
109 
113 
118  virtual bool render (LUTDataBase *lutData) const;
119 
128  virtual bool renderRescaled (LUTDataBase *lutData, double minIndex, double maxIndex) const;
129 
131 
134  void changed (void);
135 
139  static unsigned int generateUniqueId (void);
140 
142  void overwriteUniqueId(unsigned int newId);
143 
144 protected:
145 
149 
156  virtual LUTVisualType getRenderType (LUTDataBase * /*lutData*/) const { return _visualType; }
157 
165  virtual bool renderLUTNative (LUTDataBase *lutData, LUTIteratorBase *lutIterator) const = 0;
166 
179  virtual bool renderLUTRescaled (LUTDataBase *lutData, LUTIteratorBase *lutIterator,
180  double minIndex, double maxIndex) const;
181 
183 
184 
190  template <typename T>
191  bool renderT (LUTData<T> *lutData, bool rescaled, double minIndex, double maxIndex) const;
192 
197  template <typename T>
198  bool interpolateLUT (LUTData<T> *lutData, LUTIterator<T> *lutIterator,
199  double minIndex, double maxIndex) const;
200 
201 
202 
205 
207  bool _relative;
208 
211  unsigned int _id;
212 
213 
215  static unsigned int _gNextId;
216 
217 
219 
220 };
221 
222 
223 ML_END_NAMESPACE
224 
225 
226 #endif
227 // __mlLUTFunction_H
Class representing general ML objects that support import/export via strings (setPersistentState() an...
Definition: mlBase.h:62
Untyped base class for LUTData template classes.
Definition: mlLUTData.h:64
A LUTData object stores an instance of a LUT, rendered for a specified visual type,...
Definition: mlLUTData.h:243
Common base class for lookup tables.
Definition: mlLUTFunction.h:55
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 ...
virtual LUTVisualType getVisualType(void) const
Get LUT visual type.
Definition: mlLUTFunction.h:70
virtual bool render(LUTDataBase *lutData) const
Render LUT in (previously initialized) LUTData object.
virtual int getDepth(void) const
Get native LUT depth (= number of layers, numbering starts at 0)
Definition: mlLUTFunction.h:92
unsigned int getId(void) const
Get current LUT ID.
virtual LUTVisualType getRenderType(LUTDataBase *) const
Get visual type used for rendering.
static unsigned int generateUniqueId(void)
Generate a unique id (unique for all mlLUTFunctions), this can also be called to get a unique id for ...
void changed(void)
Assign a new LUT ID.
virtual double getNativeMaxIndex(void) const
Get native maximum index.
Definition: mlLUTFunction.h:86
unsigned int _id
Unique LUT ID, changed by the changed() method whenever a property of the LUT function object is modi...
virtual bool isRelative(void) const
Is LUT relative?
Definition: mlLUTFunction.h:73
static unsigned int _gNextId
Global storage for next unused LUT ID to ensure uniqueness.
virtual bool renderRescaled(LUTDataBase *lutData, double minIndex, double maxIndex) const
Render rescaled LUT in (previously initialized) LUTData object.
virtual double getNativeMinIndex(void) const
Get native minimum index.
Definition: mlLUTFunction.h:83
virtual LUTDimensionality getDimensionality(void) const
Get dimensionality (1, 2, or 3), usually depending on height and depth.
Definition: mlLUTFunction.h:79
virtual bool isValid(void) const
Return true if the LUT function is valid. An invalid LUT function can not be rendered.
Definition: mlLUTFunction.h:67
virtual double getNativeMinValue(void) const
Get native minimum LUT value.
Definition: mlLUTFunction.h:95
virtual int getHeight(void) const
Get native LUT height (= number of rows, numbering starts at 0)
Definition: mlLUTFunction.h:89
void overwriteUniqueId(unsigned int newId)
Overwrites the unique id. NOTE: use this only if you really know what you are doing!
virtual void setRelative(bool relative)
Set/reset relative flag.
Definition: mlLUTFunction.h:76
bool interpolateLUT(LUTData< T > *lutData, LUTIterator< T > *lutIterator, double minIndex, double maxIndex) const
Perform type-specific rescaled LUT rendering by.
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 LU...
LUTVisualType _visualType
LUT visual type.
LUTFunction(LUTVisualType vt, bool relative)
Constructor.
Definition: mlLUTFunction.h:59
bool renderT(LUTData< T > *lutData, bool rescaled, double minIndex, double maxIndex) const
Perform type-specific, native or rescaled (rescaled = true, rescale to range minIndex ....
ML_ABSTRACT_CLASS_HEADER(LUTFunction)
virtual double getNativeMaxValue(void) const
Get native maximum LUT value.
Definition: mlLUTFunction.h:98
bool _relative
Flag for relative LUT.
LUT iterator base class with type independent functionality and declarations.
Definition: mlLUTIterator.h:30
The LUTIterator class template is used by a LUTFunction object for rendering into a LUTData object.
#define MLLUT_EXPORT
System specific macro definitions.
Definition: mlLUTSystem.h:25
LUTDimensionality
LUT dimensionality.
Definition: mlLUTBasic.h:78
@ LUT_1D
1D-LUT, consists of a single row
Definition: mlLUTBasic.h:79
@ LUT_3D
3D-LUT, consists of multiple layers
Definition: mlLUTBasic.h:81
@ LUT_2D
2D-LUT, consists of multiple rows in a single layer
Definition: mlLUTBasic.h:80
LUTVisualType
LUT visual type constants to identify the visual interpretation of the individual LUT channels.
Definition: mlLUTBasic.h:30