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);
void convert(const T1 *pixel, const int bits, const OFBool rgb)
convert input pixel data to intermediate representation
Interface class to DICOM data management (dcmdata).
Template class to handle YCbCr Full 4:2:2 pixel data.
void convertValue(T2 &red, T2 &green, T2 &blue, const T2 y, const T2 cb, const T2 cr, const T2 maxvalue)
convert a single YCbCr value to RGB
T2 * Data[3]
pointer to pixel data (3 components)
int PlanarConfiguration
planar configuration of the original pixel data (0 = color-by-pixel, 1 = color-by-plane) ...
Template class to handle color pixel data.
virtual ~DiYBR422PixelTemplate()
destructor
static unsigned long maxval(const int mv_bits, const unsigned long mv_pos=1)
calculate maximum value which could be stored in the specified number of bits
unsigned long InputCount
number of pixels in the input buffer
int Init(const void *pixel)
initialize internal memory
DiYBR422PixelTemplate(const DiDocument *docu, const DiInputPixel *pixel, EI_Status &status, const int bits, const OFBool rgb)
constructor
unsigned long Count
number of pixels