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
27
30{
31public:
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
100private:
102 double _v[5];
103};
104
105
106
108typedef std::vector<LUTRGBAPoint> LUTRGBAPointList;
109
110
111
115{
116public:
117
118 // Set current version number
120
130
133
134
137
138
141
144 virtual bool setPoints(const LUTRGBAPointList& points);
145
147 const LUTRGBAPointList& getPoints() const { return _points; }
148
152
154 void setVisualType(LUTVisualType visualType) { _visualType = visualType; changed(); }
155
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
217protected:
218
219 void addStateToTree(TreeNode *parent) const override;
220 void readStateFromTree(TreeNode *parent) override;
221
224
230
238 double minIndex, double maxIndex) const override;
239
243 template <typename T>
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
274
275
276#endif
277// __mlLUTFLinear_H
Helper class that stores a list of typed enum values and their string names.
Definition mlFields.h:319
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...
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 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)
void setPos(double posArg)
Set index position of point.
LUTRGBAPoint(double posArg, double rArg, double gArg, double bArg, double aArg)
Explicit value constructor.
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:154
#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