MeVisLab Toolbox Reference
mlDICOMTagPaletteTools.h
Go to the documentation of this file.
1// Copyright (c) Fraunhofer MEVIS, Germany. All rights reserved.
2// **InsertLicense** code
3//----------------------------------------------------------------------------------
5
10//----------------------------------------------------------------------------------
11#pragma once
12
13#include "MLDICOMTagsSystem.h"
14
15#include <mlUtilsSystem.h>
16#include <mlPagedImage.h>
17
18// DICOM Tree prototypes.
19#include <DCMTree_Lib.h>
20
21#include <FMEThirdPartyWarningsDisable.h>
22#include <cstring>
23#include <FMEThirdPartyWarningsRestore.h>
24
25ML_START_NAMESPACE
26
27//----------------------------------------------------------------------------------
29//----------------------------------------------------------------------------------
30namespace DICOMTagTools {
31
32//------------------------------------------------------------------------------------------------
34//------------------------------------------------------------------------------------------------
38 {
39 _setUpArrays();
40 }
41
44 {
45 _deleteArrays();
46 }
47
49 inline DicomPaletteInfo(const DicomPaletteInfo &inputInfo)
50 {
51 _setUpArrays();
52 *this = inputInfo;
53 }
54
57 {
58 if (this == &inputInfo){ return *this; }
59
60 dataType = inputInfo.dataType;
61 minVal = inputInfo.minVal;
62 maxVal = inputInfo.maxVal;
63 numEntries = inputInfo.numEntries;
64 usesAlpha = inputInfo.usesAlpha;
66
67 const size_t NumEntries = 65536u*4u;
68 memcpy(rgbaLUT, inputInfo.rgbaLUT, NumEntries*sizeof(MLuint16));
69 memcpy(rgbaFloatLUT, inputInfo.rgbaFloatLUT, NumEntries*sizeof(MLfloat));
70
71 minLUTEntry = inputInfo.minLUTEntry;
72 maxLUTEntry = inputInfo.maxLUTEntry;
73
74 return *this;
75 }
76
78 inline bool operator==(const DicomPaletteInfo &inputInfo) const
79 {
80 return (dataType == inputInfo.dataType) &&
81 (minVal == inputInfo.minVal) &&
82 (maxVal == inputInfo.maxVal) &&
83 (numEntries == inputInfo.numEntries) &&
84 (usesAlpha == inputInfo.usesAlpha) &&
86
87 (memcmp(rgbaLUT, inputInfo.rgbaLUT, static_cast<size_t>(numEntries)*4u*sizeof(MLuint16)) == 0) &&
88 (memcmp(rgbaFloatLUT, inputInfo.rgbaFloatLUT, static_cast<size_t>(numEntries)*4u*sizeof(MLfloat)) == 0) &&
89
90 (minLUTEntry == inputInfo.minLUTEntry) &&
91 (maxLUTEntry == inputInfo.maxLUTEntry);
92 }
93
95 inline bool operator!=(const DicomPaletteInfo& inputInfo) const
96 {
97 return !(this->operator==(inputInfo));
98 }
99
101 inline bool isValid() const
102 {
103 return ((dataType == MLuint8Type) ||
105 (dataType == MLfloatType)) &&
106 (numEntries > 0) &&
108 }
109
111 inline void reset()
112 {
114 minVal = 0;
115 maxVal = 0;
116 numEntries = 0;
117 usesAlpha = false;
121 _deleteArrays();
122 _setUpArrays();
123 }
124
128
132
135
138
140 bool usesAlpha = false;
141
145
147 MLuint16 *rgbaLUT = nullptr;
148
151
154
157
158 private:
160 void _setUpArrays()
161 {
162 const size_t NumEntries = 65536u*4u;
163 rgbaLUT = new MLuint16[NumEntries*sizeof(MLuint16)];
164 std::memset(rgbaLUT, 0, NumEntries*sizeof(MLuint16));
165
166 rgbaFloatLUT = new MLfloat[NumEntries*sizeof(MLfloat)];
167 std::memset(rgbaFloatLUT, 0, NumEntries*sizeof(MLfloat));
168 }
170 void _deleteArrays()
171 {
172 delete[] rgbaLUT;
173 rgbaLUT = nullptr;
174 delete[] rgbaFloatLUT;
175 rgbaFloatLUT = nullptr;
176 }
177};
178
183
184};
185
186ML_END_NAMESPACE
Project global and OS specific declarations.
#define MLDICOMTags_EXPORT
If included by external modules, exported symbols are declared as import symbols.
#define ML_INVALID_DATA_TYPE
Definition mlTypeDefs.h:612
MLint32 MLDataType
Definition mlTypeDefs.h:595
@ MLuint8Type
Enumerator for the unsigned 8-bit ML integer type.
Definition mlTypeDefs.h:620
@ MLfloatType
Enumerator for the signed 32-bit ML floating point type.
Definition mlTypeDefs.h:625
@ MLuint16Type
Enumerator for the unsigned 16-bit ML integer type.
Definition mlTypeDefs.h:622
#define ML_UINT16_MAX
Definition mlTypeDefs.h:145
unsigned int MLuint32
Definition mlTypeDefs.h:184
unsigned short MLuint16
Definition mlTypeDefs.h:141
#define ML_UINT16_MIN
Definition mlTypeDefs.h:144
signed int MLint32
Definition mlTypeDefs.h:160
float MLfloat
Definition mlTypeDefs.h:200
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:67
MLDICOMTags_EXPORT void determinePaletteInformation(DCMTree::Const_TreePtr dcmTree, DicomPaletteInfo &info)
DICOM palette container which is to be used for ML index image to RGB image voxel translation.
bool usesAlpha
True if alpha channel is valid, otherwise false.
MLint32 maxVal
Maximum voxel value to map to a color, all larger voxel values shall be clamped to it.
MLuint32 numEntries
Number of valid table entries in rgbLUT, at most 65536.
bool operator!=(const DicomPaletteInfo &inputInfo) const
Comparison operator, returns false on content inequality (different array pointers are not handled as...
MLuint16 * rgbaLUT
Table of RGB[A] values as MLuint16 values if isSupplementalPaletteLUT is false, otherwise undefined.
void reset()
Makes contents invalid, reset to default construction state.
bool operator==(const DicomPaletteInfo &inputInfo) const
Comparison operator, equals on content equality (arrays can have different pointers but need to have ...
bool isValid() const
Returns true if the palette looks valid, otherwise false.
MLuint16 maxLUTEntry
Maximum value found in all entries of LUT in any of the R, G, or B channels (but not Alpha even if it...
DicomPaletteInfo & operator=(const DicomPaletteInfo &inputInfo)
Assignment operator.
DicomPaletteInfo(const DicomPaletteInfo &inputInfo)
Copy constructor.
MLfloat * rgbaFloatLUT
Table of RGB[A] values as MLfloat values if isSupplementalPaletteLUT is true, otherwise undefined.
MLuint16 minLUTEntry
Minimum value found in all entries of LUT in any of the R, G, or B channels (but not Alpha even if it...