33 #include "dcmtk/config/osconfig.h"
35 #include "dcmtk/ofstd/ofbmanip.h"
36 #include "dcmtk/ofstd/ofcast.h"
38 #include "dcmtk/dcmimgle/dimopxt.h"
39 #include "dcmtk/dcmimgle/diinpx.h"
48 template<
class T1,
class T2,
class T3>
65 if ((this->
Data != NULL) && (this->InputCount < this->
Count))
67 if ((pixel != NULL) && (this->Count > 0))
104 const unsigned long ocnt)
107 if ((
sizeof(T1) <= 2) && (this->
InputCount > 3 * ocnt))
112 DCMIMGLE_DEBUG(
"using optimized routine with additional LUT");
125 const T1 *pixel = OFstatic_cast(
const T1 *, input->
getData());
126 if ((pixel != NULL) && (this->
Modality != NULL))
131 const int useInputBuffer = (
sizeof(T1) ==
sizeof(T3)) && (this->Count <= input->
getCount());
134 DCMIMGLE_DEBUG(
"re-using input buffer, do not copy pixel data");
139 if (this->
Data != NULL)
141 DCMIMGLE_DEBUG(
"applying modality tranformation with LUT (" << mlut->
getCount() <<
" entries)");
142 register T2 value = 0;
145 const T3 firstvalue = OFstatic_cast(T3, mlut->
getFirstValue());
146 const T3 lastvalue = OFstatic_cast(T3, mlut->
getLastValue());
148 register T3 *q = this->
Data;
149 register unsigned long i;
151 const unsigned long ocnt = OFstatic_cast(
unsigned long, input->
getAbsMaxRange());
156 for (i = 0; i < ocnt; ++i)
158 value = OFstatic_cast(T2, i) + absmin;
159 if (value <= firstentry)
161 else if (value >= lastentry)
164 *(q++) = OFstatic_cast(T3, mlut->
getValue(value));
166 const T3 *lut0 = lut - OFstatic_cast(T2, absmin);
169 *(q++) = *(lut0 + (*(p++)));
175 value = OFstatic_cast(T2, *(p++));
176 if (value <= firstentry)
178 else if (value >= lastentry)
181 *(q++) = OFstatic_cast(T3, mlut->
getValue(value));
197 const double slope = 1.0,
198 const double intercept = 0.0)
200 const T1 *pixel = OFstatic_cast(
const T1 *, input->
getData());
203 const int useInputBuffer = (
sizeof(T1) ==
sizeof(T3)) && (this->Count <= input->
getCount()) && (input->
getPixelStart() == 0);
206 DCMIMGLE_DEBUG(
"re-using input buffer, do not copy pixel data");
211 if (this->
Data != NULL)
213 register T3 *q = this->
Data;
214 register unsigned long i;
215 if ((slope == 1.0) && (intercept == 0.0))
221 *(q++) = OFstatic_cast(T3, *(p++));
224 DCMIMGLE_DEBUG(
"applying modality transformation with rescale slope = " << slope <<
", intercept = " << intercept);
227 const unsigned long ocnt = OFstatic_cast(
unsigned long, input->
getAbsMaxRange());
234 for (i = 0; i < ocnt; ++i)
235 *(q++) = OFstatic_cast(T3, OFstatic_cast(
double, i) + absmin + intercept);
237 if (intercept == 0.0)
239 for (i = 0; i < ocnt; ++i)
240 *(q++) = OFstatic_cast(T3, (OFstatic_cast(
double, i) + absmin) * slope);
242 for (i = 0; i < ocnt; ++i)
243 *(q++) = OFstatic_cast(T3, (OFstatic_cast(
double, i) + absmin) * slope + intercept);
246 const T3 *lut0 = lut - OFstatic_cast(T2, absmin);
249 *(q++) = *(lut0 + (*(p++)));
256 *(q++) = OFstatic_cast(T3, OFstatic_cast(
double, *(p++)) + intercept);
258 if (intercept == 0.0)
261 *(q++) = OFstatic_cast(T3, OFstatic_cast(
double, *(p++)) * slope);
264 *(q++) = OFstatic_cast(T3, OFstatic_cast(
double, *(p++)) * slope + intercept);
Template class to handle monochrome pixel data.
double getMaxValue() const
get maximum pixel value after modality transform
double getMinValue() const
get minimum pixel value after modality transform
T3 * Data
pointer to pixel data
Uint32 getCount() const
get number of LUT entries
Uint16 getLastValue() const
get value of last LUT entry.
Uint16 getFirstValue() const
get value of first LUT entry.
Class to handle modality specific transformations (incl.
void determineMinMax(T3minvalue=0, T3maxvalue=0, const int mode=0x1)
determine minimum and maximum pixel values
static void zeroMem(T *dest, const unsigned long count)
sets specified number of elements in destination memory to zero
DiMonoModality * Modality
pointer to modality transform object
Class to handle color palette look-up tables.
const DiLookupTable * getTableData() const
get pointer to lookup table data
int hasRescaling() const
check whether rescaling is present
int hasLookupTable() const
check whether lookup table is present
double getRescaleSlope() const
get rescale slope value
unsigned long InputCount
number of pixels in the input buffer
unsigned long getCount() const
get number of pixels
Uint16 getValue(const Uint16 pos) const
get value of specified LUT entry
Uint32 getLastEntry(const Uint32=0) const
get index of last LUT entry.
double getRescaleIntercept() const
get rescale intercept value
Uint32 getFirstEntry(const Uint32=0) const
get index of first LUT entry.
unsigned long Count
number of pixels