33 #include "dcmtk/config/osconfig.h"
35 #include "dcmtk/dcmimage/dicopxt.h"
36 #include "dcmtk/dcmimgle/diinpx.h"
45 template<
class T1,
class T2>
67 if ((pixel != NULL) && (this->
Count > 0) && (status == EIS_Normal))
71 status = EIS_InvalidValue;
72 DCMIMAGE_ERROR(
"invalid value for 'PlanarConfiguration' (" << this->
PlanarConfiguration <<
")");
98 if (this->
Init(pixel))
101 register unsigned long i;
102 register const T1 *p = pixel;
103 register T2 *r = this->
Data[0];
104 register T2 *g = this->
Data[1];
105 register T2 *b = this->
Data[2];
116 for (i = count / 2; i != 0; --i)
118 y1 = removeSign(*(p++), offset);
119 y2 = removeSign(*(p++), offset);
120 cb = removeSign(*(p++), offset);
121 cr = removeSign(*(p++), offset);
122 convertValue(*(r++), *(g++), *(b++), y1, cb, cr, maxvalue);
123 convertValue(*(r++), *(g++), *(b++), y2, cb, cr, maxvalue);
126 for (i = count / 2; i != 0; --i)
128 y1 = removeSign(*(p++), offset);
129 y2 = removeSign(*(p++), offset);
130 cb = removeSign(*(p++), offset);
131 cr = removeSign(*(p++), offset);
153 double dr = OFstatic_cast(
double, y) + 1.4020 * OFstatic_cast(
double, cr) - 0.7010 * OFstatic_cast(
double, maxvalue);
154 double dg = OFstatic_cast(
double, y) - 0.3441 * OFstatic_cast(
double, cb) - 0.7141 * OFstatic_cast(
double, cr) + 0.5291 * OFstatic_cast(
double, maxvalue);
155 double db = OFstatic_cast(
double, y) + 1.7720 * OFstatic_cast(
double, cb) - 0.8859 * OFstatic_cast(
double, maxvalue);
156 red = (dr < 0.0) ? 0 : (dr > OFstatic_cast(
double, maxvalue)) ? maxvalue : OFstatic_cast(T2, dr);
157 green = (dg < 0.0) ? 0 : (dg > OFstatic_cast(
double, maxvalue)) ? maxvalue : OFstatic_cast(T2, dg);
158 blue = (db < 0.0) ? 0 : (db > OFstatic_cast(
double, maxvalue)) ? maxvalue : OFstatic_cast(T2, db);