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 #ifndef DIQTPIX_H
00031 #define DIQTPIX_H
00032
00033
00034 #include "dcmtk/config/osconfig.h"
00035 #include "dcmtk/ofstd/oftypes.h"
00036 #include "dcmtk/dcmimage/diqttype.h"
00037 #include "dcmtk/dcmimage/diqtstab.h"
00038
00039
00044 class DcmQuantPixel
00045 {
00046 public:
00047
00050 DcmQuantPixel()
00051 : red(0)
00052 , green(0)
00053 , blue(0)
00054 {
00055 }
00056
00059 DcmQuantPixel(const DcmQuantPixel& arg)
00060 : red(arg.red)
00061 , green(arg.green)
00062 , blue(arg.blue)
00063 {
00064 }
00065
00066
00067
00069 inline OFBool operator==(const DcmQuantPixel& src) const
00070 {
00071 return (red == src.red) && (green == src.green) && (blue == src.blue);
00072 }
00073
00080 inline double luminance() const
00081 {
00082 return 0.299 * red + 0.587 * green + 0.114 * blue;
00083 }
00084
00090 inline unsigned long hash() const
00091 {
00092 return ((OFstatic_cast(unsigned long, red) * 33023UL + OFstatic_cast(unsigned long, green) * 30013UL +
00093 OFstatic_cast(unsigned long, blue) * 27011UL) & 0x7fffffffUL) % DcmQuantHashSize;
00094 }
00095
00099 inline DcmQuantComponent getRed() const
00100 {
00101 return red;
00102 }
00103
00107 inline DcmQuantComponent getGreen() const
00108 {
00109 return green;
00110 }
00111
00115 inline DcmQuantComponent getBlue() const
00116 {
00117 return blue;
00118 }
00119
00125 inline void assign(
00126 DcmQuantComponent r,
00127 DcmQuantComponent g,
00128 DcmQuantComponent b)
00129 {
00130 red = r;
00131 green = g;
00132 blue = b;
00133 }
00134
00143 inline void scale(
00144 DcmQuantComponent r,
00145 DcmQuantComponent g,
00146 DcmQuantComponent b,
00147 const DcmQuantScaleTable& table)
00148 {
00149 red = table[r];
00150 green = table[g];
00151 blue = table[b];
00152 }
00153
00154 private:
00156 DcmQuantComponent red;
00157
00159 DcmQuantComponent green;
00160
00162 DcmQuantComponent blue;
00163 };
00164
00165
00166 #endif
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187