00001 /* 00002 * 00003 * Copyright (C) 2002-2005, OFFIS 00004 * 00005 * This software and supporting documentation were developed by 00006 * 00007 * Kuratorium OFFIS e.V. 00008 * Healthcare Information and Communication Systems 00009 * Escherweg 2 00010 * D-26121 Oldenburg, Germany 00011 * 00012 * THIS SOFTWARE IS MADE AVAILABLE, AS IS, AND OFFIS MAKES NO WARRANTY 00013 * REGARDING THE SOFTWARE, ITS PERFORMANCE, ITS MERCHANTABILITY OR 00014 * FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR 00015 * ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND 00016 * PERFORMANCE OF THE SOFTWARE IS WITH THE USER. 00017 * 00018 * Module: dcmimage 00019 * 00020 * Author: Marco Eichelberg 00021 * 00022 * Purpose: class DcmQuantPixel 00023 * 00024 * Last Update: $Author: meichel $ 00025 * Update Date: $Date: 2005/12/08 16:01:53 $ 00026 * CVS/RCS Revision: $Revision: 1.3 $ 00027 * Status: $State: Exp $ 00028 * 00029 * CVS/RCS Log at end of file 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" /* for OFBool */ 00040 #include "dcmtk/dcmimage/diqttype.h" /* for DcmQuantHashSize, DcmQuantComponent */ 00041 #include "dcmtk/dcmimage/diqtstab.h" /* for DcmScaleTable */ 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 // we don't declare a destructor here, but the standard destructor will do. 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 * CVS/RCS Log: 00175 * $Log: diqtpix.h,v $ 00176 * Revision 1.3 2005/12/08 16:01:53 meichel 00177 * Changed include path schema for all DCMTK header files 00178 * 00179 * Revision 1.2 2003/12/23 12:20:07 joergr 00180 * Adapted type casts to new-style typecast operators defined in ofcast.h. 00181 * Updated copyright header. 00182 * 00183 * Revision 1.1 2002/01/25 13:32:07 meichel 00184 * Initial release of new color quantization classes and 00185 * the dcmquant tool in module dcmimage. 00186 * 00187 * 00188 */