00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef DIQTPIX_H
00035 #define DIQTPIX_H
00036
00037
00038 #include "dcmtk/config/osconfig.h"
00039 #include "dcmtk/ofstd/oftypes.h"
00040 #include "dcmtk/dcmimage/diqttype.h"
00041 #include "dcmtk/dcmimage/diqtstab.h"
00042
00043
00048 class DcmQuantPixel
00049 {
00050 public:
00051
00054 DcmQuantPixel()
00055 : red(0)
00056 , green(0)
00057 , blue(0)
00058 {
00059 }
00060
00063 DcmQuantPixel(const DcmQuantPixel& arg)
00064 : red(arg.red)
00065 , green(arg.green)
00066 , blue(arg.blue)
00067 {
00068 }
00069
00070
00071
00073 inline OFBool operator==(const DcmQuantPixel& src) const
00074 {
00075 return (red == src.red) && (green == src.green) && (blue == src.blue);
00076 }
00077
00084 inline double luminance() const
00085 {
00086 return 0.299 * red + 0.587 * green + 0.114 * blue;
00087 }
00088
00094 inline unsigned long hash() const
00095 {
00096 return ((OFstatic_cast(unsigned long, red) * 33023UL + OFstatic_cast(unsigned long, green) * 30013UL +
00097 OFstatic_cast(unsigned long, blue) * 27011UL) & 0x7fffffffUL) % DcmQuantHashSize;
00098 }
00099
00103 inline DcmQuantComponent getRed() const
00104 {
00105 return red;
00106 }
00107
00111 inline DcmQuantComponent getGreen() const
00112 {
00113 return green;
00114 }
00115
00119 inline DcmQuantComponent getBlue() const
00120 {
00121 return blue;
00122 }
00123
00129 inline void assign(
00130 DcmQuantComponent r,
00131 DcmQuantComponent g,
00132 DcmQuantComponent b)
00133 {
00134 red = r;
00135 green = g;
00136 blue = b;
00137 }
00138
00147 inline void scale(
00148 DcmQuantComponent r,
00149 DcmQuantComponent g,
00150 DcmQuantComponent b,
00151 const DcmQuantScaleTable& table)
00152 {
00153 red = table[r];
00154 green = table[g];
00155 blue = table[b];
00156 }
00157
00158 private:
00160 DcmQuantComponent red;
00161
00163 DcmQuantComponent green;
00164
00166 DcmQuantComponent blue;
00167 };
00168
00169
00170 #endif
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188