33 #include "dcmtk/config/osconfig.h"
35 #include "dcmtk/dcmimage/dicopxt.h"
36 #include "dcmtk/dcmimgle/diinpx.h"
45 template<
class T1,
class T2>
65 if ((pixel != NULL) && (this->
Count > 0) && (status == EIS_Normal))
69 status = EIS_InvalidValue;
70 DCMIMAGE_ERROR(
"invalid value for 'PlanarConfiguration' (" << this->
PlanarConfiguration <<
")");
94 if (this->
Init(pixel))
96 register T2 *r = this->
Data[0];
97 register T2 *g = this->
Data[1];
98 register T2 *b = this->
Data[2];
99 register unsigned long i;
106 register const T1 *p = pixel;
111 for (i = count / 2; i != 0; --i)
113 y1 = removeSign(*(p++), offset);
114 y2 = removeSign(*(p++), offset);
115 cb = removeSign(*(p++), offset);
116 cr = removeSign(*(p++), offset);
117 convertValue(*(r++), *(g++), *(b++), y1, cb, cr, maxvalue);
118 convertValue(*(r++), *(g++), *(b++), y2, cb, cr, maxvalue);
133 double dr = 1.1631 * OFstatic_cast(
double, y) + 1.5969 * OFstatic_cast(
double, cr) - 0.8713 * OFstatic_cast(
double, maxvalue);
134 double dg = 1.1631 * OFstatic_cast(
double, y) - 0.3913 * OFstatic_cast(
double, cb) - 0.8121 * OFstatic_cast(
double, cr) + 0.5290 * OFstatic_cast(
double, maxvalue);
135 double db = 1.1631 * OFstatic_cast(
double, y) + 2.0177 * OFstatic_cast(
double, cb) - 1.0820 * OFstatic_cast(
double, maxvalue);
136 red = (dr < 0.0) ? 0 : (dr > OFstatic_cast(
double, maxvalue)) ? maxvalue : OFstatic_cast(T2, dr);
137 green = (dg < 0.0) ? 0 : (dg > OFstatic_cast(
double, maxvalue)) ? maxvalue : OFstatic_cast(T2, dg);
138 blue = (db < 0.0) ? 0 : (db > OFstatic_cast(
double, maxvalue)) ? maxvalue : OFstatic_cast(T2, db);
Template class to handle YCbCr Partial 4:2:2 pixel data.
Interface class to DICOM data management (dcmdata).
virtual ~DiYBRPart422PixelTemplate()
destructor
DiYBRPart422PixelTemplate(const DiDocument *docu, const DiInputPixel *pixel, EI_Status &status, const int bits)
constructor
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.
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
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
void convert(const T1 *pixel, const int bits)
convert input pixel data to intermediate representation
unsigned long InputCount
number of pixels in the input buffer
int Init(const void *pixel)
initialize internal memory
unsigned long Count
number of pixels