14 #ifndef GDCMIMAGECHANGEPHOTOMETRICINTERPRETATION_H
15 #define GDCMIMAGECHANGEPHOTOMETRICINTERPRETATION_H
43 static void RGB2YBR(T ybr[3],
const T rgb[3]);
45 static void YBR2RGB(T rgb[3],
const T ybr[3]);
48 bool ChangeMonochrome();
60 ybr[0] = 65.738 * rgb[0] + 129.057 * rgb[1] + 25.064 * rgb[2] + 16;
61 ybr[1] = -37.945 * rgb[0] + -74.494 * rgb[1] + 112.439 * rgb[2] + 128;
62 ybr[2] = 112.439 * rgb[0] + -94.154 * rgb[1] + -18.285 * rgb[2] + 128;
65 const double R = rgb[0];
66 const double G = rgb[1];
67 const double B = rgb[2];
68 const double Y = .2990 * R + .5870 * G + .1140 * B;
69 const double CB = -.168736 * R - .331264 * G + .5000 * B + 128;
70 const double CR = .5000 * R - .418688 * G - .081312 * B + 128;
85 rgb[0] = 298.082 * ((int)ybr[0]-16) + 0. * ((int)ybr[1]-128) + 408.583 * ((int)ybr[2]-128) - 1. / 256;
86 rgb[1] = 298.082 * ((int)ybr[0]-16) + -100.291 * ((int)ybr[1]-128) + -208.12 * ((int)ybr[2]-128) - 1. / 256;
87 rgb[2] = 298.082 * ((int)ybr[0]-16) + 516.411 * ((int)ybr[1]-128) + 0. * ((int)ybr[2]-128) - 1. / 256;
90 const double Y = ybr[0];
91 const double Cb = ybr[1];
92 const double Cr = ybr[2];
96 const double r = Y + 1.402 * (Cr-128);
97 const double g = Y - 0.344136 * (Cb-128) - 0.714136 * (Cr-128);
98 const double b = Y + 1.772 * (Cb-128);
99 double R = r < 0 ? 0 : r;
100 R = R > 255 ? 255 : R;
101 double G = g < 0 ? 0 : g;
102 G = G > 255 ? 255 : G;
103 double B = b < 0 ? 0 : b;
104 B = B > 255 ? 255 : B;
105 assert( R >= 0 && R <= 255 );
106 assert( G >= 0 && G <= 255 );
107 assert( B >= 0 && B <= 255 );
108 rgb[0] = ((R < 0 ? 0 : R) > 255 ? 255 : R);
117 #endif //GDCMIMAGECHANGEPHOTOMETRICINTERPRETATION_H
~ImageChangePhotometricInterpretation()
Definition: gdcmImageChangePhotometricInterpretation.h:32
static void RGB2YBR(T ybr[3], const T rgb[3])
colorspace converstion (based on CCIR Recommendation 601-2)
Definition: gdcmImageChangePhotometricInterpretation.h:57
ImageToImageFilter class Super class for all filter taking an image and producing an output image...
Definition: gdcmImageToImageFilter.h:27
static void YBR2RGB(T rgb[3], const T ybr[3])
Definition: gdcmImageChangePhotometricInterpretation.h:81
#define GDCM_EXPORT
Definition: gdcmWin32.h:34
const PhotometricInterpretation & GetPhotometricInterpretation() const
Definition: gdcmImageChangePhotometricInterpretation.h:36
Class to represent an PhotometricInterpretation.
Definition: gdcmPhotometricInterpretation.h:28
ImageChangePhotometricInterpretation()
Definition: gdcmImageChangePhotometricInterpretation.h:31
ImageChangePhotometricInterpretation class Class to change the Photometric Interpetation of an input ...
Definition: gdcmImageChangePhotometricInterpretation.h:28
void SetPhotometricInterpretation(PhotometricInterpretation const &pi)
Set/Get requested PhotometricInterpretation.
Definition: gdcmImageChangePhotometricInterpretation.h:35