MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
27
30{
31public:
35 LUTRGBAPoint(double posArg, double rArg, double gArg, double bArg, double aArg);
36
38 double pos() const
39 {
40 return _v[0];
41 }
43 void setPos(double posArg)
44 {
45 _v[0] = posArg;
46 }
47
49 double r() const
50 {
51 return _v[1];
52 }
53 void setR(double rArg)
54 {
55 _v[1] = rArg;
56 }
57 double g() const
58 {
59 return _v[2];
60 }
61 void setG(double gArg)
62 {
63 _v[2] = gArg;
64 }
65 double b() const
66 {
67 return _v[3];
68 }
69 void setB(double bArg)
70 {
71 _v[3] = bArg;
72 }
73 double a() const
74 {
75 return _v[4];
76 }
77 void setA(double aArg)
78 {
79 _v[4] = aArg;
80 }
81
83 void setL(double lArg)
84 {
85 _v[1] = lArg;
86 _v[2] = lArg;
87 _v[3] = lArg;
88 }
89
91 double l() const
92 {
93 return _v[1];
94 }
95
96 void setRGBA(double rArg, double gArg, double bArg, double aArg)
97 {
98 _v[1] = rArg;
99 _v[2] = gArg;
100 _v[3] = bArg;
101 _v[4] = aArg;
102 }
103
104 void setRGB(double rArg, double gArg, double bArg)
105 {
106 _v[1] = rArg;
107 _v[2] = gArg;
108 _v[3] = bArg;
109 }
110
112
115 double& operator[](int idx)
116 {
117 return _v[idx];
118 }
119
123 const double& operator[](int idx) const
124 {
125 return _v[idx];
126 }
127
129 bool operator<(const LUTRGBAPoint& p) const
130 {
131 return this->pos() < p.pos();
132 }
133
135 bool operator>(const LUTRGBAPoint& p) const
136 {
137 return this->pos() > p.pos();
138 }
139
140private:
142 double _v[5];
143};
144
145
147typedef std::vector<LUTRGBAPoint> LUTRGBAPointList;
148
149
153{
154public:
155 // Set current version number
157
167
170
171
174
175
178
181 virtual bool setPoints(const LUTRGBAPointList& points);
182
185 {
186 return _points;
187 }
188
192 {
193 return _points;
194 }
195
198 {
199 _visualType = visualType;
200 changed();
201 }
202
205
207 void removePoint(int idx);
208
210 const LUTRGBAPoint& getPoint(int idx) const;
211
213 void setPoint(int idx, const LUTRGBAPoint& point);
214
216 virtual double getStartIndex(void) const;
217
219 virtual double getEndIndex(void) const;
220
223 {
224 return _colorInterpolation;
225 }
226
229 {
230 _colorInterpolation = c;
231 changed();
232 }
233
235 void setAlphaFactor(float factor)
236 {
237 _alphaFactor = factor;
238 changed();
239 }
240
242 float getAlphaFactor() const
243 {
244 return _alphaFactor;
245 }
246
250 {
251 return _relativeUsesNativeRange;
252 }
253
257 {
258 _relativeUsesNativeRange = flag;
259 }
260
262
263
266
268 bool isValid(void) const override;
269
271 double getNativeMinIndex(void) const override;
272
274 double getNativeMaxIndex(void) const override;
275
277
278
279protected:
280 void addStateToTree(TreeNode* parent) const override;
281 void readStateFromTree(TreeNode* parent) override;
282
285
291
299 double maxIndex) const override;
300
304 template <typename T>
306
308
309
311 void copyPoint(int idx, double* array) const;
312
313
316
319
323
326
327
329};
330
331
333
334
335#endif
336// __mlLUTFLinear_H
Helper class that stores a list of typed enum values and their string names.
Definition mlFields.h:318
Untyped base class for LUTData template classes.
Definition mlLUTData.h:65
A LUTData object stores an instance of a LUT, rendered for a specified visual type,...
Definition mlLUTData.h:308
A color/gray LUT with sampling points and linear, nearest neighbor or truncated interpolation inbetwe...
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.
const LUTRGBAPoint & getPoint(int idx) const
Get a point at given index.
ColorInterpolation _colorInterpolation
Color interpolation mode.
bool _relativeUsesNativeRange
Flag specifying whether the native index range is used as the range for relative mapping,...
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.)
bool renderLUTNative(LUTDataBase *lutData, LUTIteratorBase *lutIterator) const override
Render the lookup table into lutData using lutIterator to access and increment the LUT pointers.
const LUTRGBAPointList & getPoints() const
Get sampling point table as a const reference.
void setVisualType(LUTVisualType visualType)
Set the visual type of the table (this affects how the points in the list are handled)
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.
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...
static EnumValues< ColorInterpolation > getColorInterpolationValues()
Color interpolation values.
virtual ColorInterpolation getColorInterpolation(void) const
Get color interpolation mode.
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 & getModifiablePoints()
Get modifiable sampling point table.
LUTRGBAPointList _points
LUT sampling point table.
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...
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.
ColorInterpolation
Color interpolation constants.
@ InterpolateHLS
Interpolation in HLS space, closest H direction.
@ InterpolateRGB
Interpolation in RGB space.
@ InterpolateHLSneg
Interpolation in HLS space, negative H direction.
@ InterpolateConstant
Interpolation by floor() truncation.
@ InterpolateSRGB
Convert to linear RGB, interpolate and convert back.
@ InterpolateHLSpos
Interpolation in HLS space, positive H direction.
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.
Common base class for lookup tables.
LUT iterator base class with type independent functionality and declarations.
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,.
double b() const
double & operator[](int idx)
Access the components, 0 = pos, 1 = r , 2 = g, 3 = b, 4 = a No check for validity of idx!
double g() const
double r() const
Access the color/alpha components.
void setA(double aArg)
double pos() const
Get index position of point.
double l() const
Return luminance (assuming that R == G == B)
double a() const
void setR(double rArg)
const double & operator[](int idx) const
Access the components, 0 = pos, 1 = r , 2 = g, 3 = b, 4 = a No check for validity of idx!...
void setPos(double posArg)
Set index position of point.
bool operator>(const LUTRGBAPoint &p) const
"Greater than" comparison operator, refers to index position
LUTRGBAPoint(double posArg, double rArg, double gArg, double bArg, double aArg)
Explicit value constructor.
bool operator<(const LUTRGBAPoint &p) const
"Less than" comparison operator, refers to index position
void setB(double bArg)
void setRGBA(double rArg, double gArg, double bArg, double aArg)
void setG(double gArg)
void setRGB(double rArg, double gArg, double bArg)
void setL(double lArg)
Set R, G, B components to luminance l.
LUTRGBAPoint()
Default constructor.
The class TreeNode is the abstract base class for the import/export of ML objects.
Definition mlTreeNode.h:160
#define MLLUT_EXPORT
System specific macro definitions.
Definition mlLUTSystem.h:25
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
std::vector< LUTRGBAPoint > LUTRGBAPointList
Type definition for a vector of sampling points.
LUTVisualType
LUT visual type constants to identify the visual interpretation of the individual LUT channels.
Definition mlLUTBasic.h:30