MeVisLab Toolbox Reference
mlLUTFLinear.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_LUTFLINEAR_H
14 #define ML_LUTFLINEAR_H
15 
16 
18 
19 #include "mlLUTSystem.h"
20 #include "mlLUTFunction.h"
21 
22 #include <mlFields.h>
23 
24 #include <vector>
25 
26 ML_START_NAMESPACE
27 
30 {
31 public:
35  LUTRGBAPoint(double posArg, double rArg, double gArg, double bArg, double aArg);
36 
38  double pos() const { return _v[0]; }
40  void setPos(double posArg) { _v[0] = posArg; }
41 
43  double r() const { return _v[1]; }
44  void setR(double rArg) { _v[1] = rArg; }
45  double g() const { return _v[2]; }
46  void setG(double gArg) { _v[2] = gArg; }
47  double b() const { return _v[3]; }
48  void setB(double bArg) { _v[3] = bArg; }
49  double a() const { return _v[4]; }
50  void setA(double aArg) { _v[4] = aArg; }
51 
53  void setL(double lArg) {
54  _v[1] = lArg; _v[2] = lArg; _v[3] = lArg;
55  }
56 
58  double l() const {
59  return _v[1];
60  }
61 
62  void setRGBA(double rArg, double gArg, double bArg, double aArg) {
63  _v[1] = rArg;
64  _v[2] = gArg;
65  _v[3] = bArg;
66  _v[4] = aArg;
67  }
68 
69  void setRGB(double rArg, double gArg, double bArg) {
70  _v[1] = rArg;
71  _v[2] = gArg;
72  _v[3] = bArg;
73  }
74 
76 
79  double &operator [](int idx) {
80  return _v[idx];
81  }
82 
86  const double &operator [](int idx) const {
87  return _v[idx];
88  }
89 
91  bool operator <(const LUTRGBAPoint& p) const {
92  return this->pos()<p.pos();
93  }
94 
96  bool operator >(const LUTRGBAPoint& p) const {
97  return this->pos()>p.pos();
98  }
99 
100 private:
102  double _v[5];
103 };
104 
105 
106 
108 typedef std::vector<LUTRGBAPoint> LUTRGBAPointList;
109 
110 
111 
115 {
116 public:
117 
118  // Set current version number
120 
129  };
130 
133 
134 
136  LUTFLinear (void);
137 
138 
141 
144  virtual bool setPoints(const LUTRGBAPointList& points);
145 
147  const LUTRGBAPointList& getPoints() const { return _points; }
148 
151  LUTRGBAPointList& getModifiablePoints() { return _points; }
152 
154  void setVisualType(LUTVisualType visualType) { _visualType = visualType; changed(); }
155 
157  int insertPoint(const LUTRGBAPoint& point);
158 
160  void removePoint(int idx);
161 
163  const LUTRGBAPoint& getPoint(int idx) const;
164 
166  void setPoint(int idx, const LUTRGBAPoint& point);
167 
169  virtual double getStartIndex (void) const;
170 
172  virtual double getEndIndex (void) const;
173 
175  virtual ColorInterpolation getColorInterpolation (void) const { return _colorInterpolation; }
176 
178  virtual void setColorInterpolation (ColorInterpolation c) { _colorInterpolation = c; changed(); }
179 
181  void setAlphaFactor(float factor) {
182  _alphaFactor = factor;
183  changed();
184  }
185 
187  float getAlphaFactor() const {
188  return _alphaFactor;
189  }
190 
193  bool relativeUsesNativeRange() const { return _relativeUsesNativeRange; }
194 
197  void setRelativeUsesNativeRange(bool flag) { _relativeUsesNativeRange = flag; }
198 
200 
201 
204 
206  bool isValid (void) const override;
207 
209  double getNativeMinIndex (void) const override;
210 
212  double getNativeMaxIndex (void) const override;
213 
215 
216 
217 protected:
218 
219  void addStateToTree(TreeNode *parent) const override;
220  void readStateFromTree(TreeNode *parent) override;
221 
224 
229  bool renderLUTNative (LUTDataBase *lutData, LUTIteratorBase *lutIterator) const override;
230 
237  bool renderLUTRescaled (LUTDataBase *lutData, LUTIteratorBase *lutIterator,
238  double minIndex, double maxIndex) const override;
239 
243  template <typename T>
244  bool renderLUT (LUTData<T> *lutData, LUTIterator<T> *lutIterator,
245  double startIndex, double endIndex) const;
246 
248 
249 
251  void copyPoint(int idx, double* array) const;
252 
253 
256 
259 
263 
266 
267 
269 
270 };
271 
272 
273 ML_END_NAMESPACE
274 
275 
276 #endif
277 // __mlLUTFLinear_H
Helper class that stores a list of typed enum values and their string names.
Definition: mlFields.h:531
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
A color/gray LUT with sampling points and linear, nearest neighbor or truncated interpolation inbetwe...
Definition: mlLUTFLinear.h:115
virtual double getStartIndex(void) const
Get start index.
void readStateFromTree(TreeNode *parent) override
Reads the object state from the children of the given parent node.
float getAlphaFactor() const
Get the global alpha factor.
Definition: mlLUTFLinear.h:187
ColorInterpolation _colorInterpolation
Color interpolation mode.
Definition: mlLUTFLinear.h:265
bool _relativeUsesNativeRange
Flag specifying whether the native index range is used as the range for relative mapping,...
Definition: mlLUTFLinear.h:262
bool isValid(void) const override
Return true if the LUT function is valid.
bool renderLUTRescaled(LUTDataBase *lutData, LUTIteratorBase *lutIterator, double minIndex, double maxIndex) const override
Render rescaled LUT into lutData using lutIterator to access and increment the LUT pointers.
void setAlphaFactor(float factor)
Set the global alpha factor (default is 1.)
Definition: mlLUTFLinear.h:181
const LUTRGBAPointList & getPoints() const
Get sampling point table as a const reference.
Definition: mlLUTFLinear.h:147
bool renderLUTNative(LUTDataBase *lutData, LUTIteratorBase *lutIterator) const override
Render the lookup table into lutData using lutIterator to access and increment the LUT pointers.
void setVisualType(LUTVisualType visualType)
Set the visual type of the table (this affects how the points in the list are handled)
Definition: mlLUTFLinear.h:154
ML_SET_ADDSTATE_VERSION(1)
double getNativeMinIndex(void) const override
Get native minimum index.
void copyPoint(int idx, double *array) const
Copy the point at table index idx to the given array (ordered like in the LUTIterator)
virtual void setColorInterpolation(ColorInterpolation c)
Set color interpolation mode.
Definition: mlLUTFLinear.h:178
virtual bool setPoints(const LUTRGBAPointList &points)
Set table with sampling points, data is copied to internal storage.
virtual double getEndIndex(void) const
Get end index.
void setRelativeUsesNativeRange(bool flag)
Specify whether the native index range (given by the first and last index position in the sampling po...
Definition: mlLUTFLinear.h:197
virtual ColorInterpolation getColorInterpolation(void) const
Get color interpolation mode.
Definition: mlLUTFLinear.h:175
bool renderLUT(LUTData< T > *lutData, LUTIterator< T > *lutIterator, double startIndex, double endIndex) const
Render the LUT table between startIndex and endIndex into lutData using lutIterator to access and inc...
LUTRGBAPointList _points
LUT sampling point table.
Definition: mlLUTFLinear.h:255
ML_CLASS_HEADER(LUTFLinear)
LUTFLinear(void)
Constructor.
bool relativeUsesNativeRange() const
Return true if the native index range (given by the first and last index position in the sampling poi...
Definition: mlLUTFLinear.h:193
void addStateToTree(TreeNode *parent) const override
Attaches the object state as children of the given parent node.
double getNativeMaxIndex(void) const override
Get native maximum index.
int insertPoint(const LUTRGBAPoint &point)
Insert a given point and return the resulting index in the sampling point table.
LUTRGBAPointList & getModifiablePoints()
Get modifiable sampling point table.
Definition: mlLUTFLinear.h:151
static EnumValues< ColorInterpolation > getColorInterpolationValues()
Color interpolation values.
const LUTRGBAPoint & getPoint(int idx) const
Get a point at given index.
ColorInterpolation
Color interpolation constants.
Definition: mlLUTFLinear.h:122
@ InterpolateHLS
Interpolation in HLS space, closest H direction.
Definition: mlLUTFLinear.h:124
@ InterpolateRGB
Interpolation in RGB space.
Definition: mlLUTFLinear.h:123
@ InterpolateHLSneg
Interpolation in HLS space, negative H direction.
Definition: mlLUTFLinear.h:126
@ InterpolateConstant
Interpolation by floor() truncation.
Definition: mlLUTFLinear.h:127
@ InterpolateSRGB
Convert to linear RGB, interpolate and convert back.
Definition: mlLUTFLinear.h:128
@ InterpolateHLSpos
Interpolation in HLS space, positive H direction.
Definition: mlLUTFLinear.h:125
void setPoint(int idx, const LUTRGBAPoint &point)
Set a point at given index, does not check if position is correct!
void removePoint(int idx)
Remove the point at the given index.
float _alphaFactor
Global alpha factor.
Definition: mlLUTFLinear.h:258
Common base class for lookup tables.
Definition: mlLUTFunction.h:55
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.
A LUT sampling point with index position and RGBA channel values,.
Definition: mlLUTFLinear.h:30
double b() const
Definition: mlLUTFLinear.h:47
double g() const
Definition: mlLUTFLinear.h:45
double r() const
Access the color/alpha components.
Definition: mlLUTFLinear.h:43
void setA(double aArg)
Definition: mlLUTFLinear.h:50
double pos() const
Get index position of point.
Definition: mlLUTFLinear.h:38
double l() const
Return luminance (assuming that R == G == B)
Definition: mlLUTFLinear.h:58
double a() const
Definition: mlLUTFLinear.h:49
void setR(double rArg)
Definition: mlLUTFLinear.h:44
void setPos(double posArg)
Set index position of point.
Definition: mlLUTFLinear.h:40
LUTRGBAPoint(double posArg, double rArg, double gArg, double bArg, double aArg)
Explicit value constructor.
void setB(double bArg)
Definition: mlLUTFLinear.h:48
void setRGBA(double rArg, double gArg, double bArg, double aArg)
Definition: mlLUTFLinear.h:62
void setG(double gArg)
Definition: mlLUTFLinear.h:46
void setRGB(double rArg, double gArg, double bArg)
Definition: mlLUTFLinear.h:69
void setL(double lArg)
Set R, G, B components to luminance l.
Definition: mlLUTFLinear.h:53
LUTRGBAPoint()
Default constructor.
The class TreeNode is the abstract base class for the import/export of ML objects.
Definition: mlTreeNode.h:170
#define MLLUT_EXPORT
System specific macro definitions.
Definition: mlLUTSystem.h:25
std::vector< LUTRGBAPoint > LUTRGBAPointList
Type definition for a vector of sampling points.
Definition: mlLUTFLinear.h:108
LUTVisualType
LUT visual type constants to identify the visual interpretation of the individual LUT channels.
Definition: mlLUTBasic.h:30