OFFIS DCMTK  Version 3.6.0
diqtpix.h
1 /*
2  *
3  * Copyright (C) 2002-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: dcmimage
15  *
16  * Author: Marco Eichelberg
17  *
18  * Purpose: class DcmQuantPixel
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:16:30 $
22  * CVS/RCS Revision: $Revision: 1.4 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DIQTPIX_H
31 #define DIQTPIX_H
32 
33 
34 #include "dcmtk/config/osconfig.h"
35 #include "dcmtk/ofstd/oftypes.h" /* for OFBool */
36 #include "dcmtk/dcmimage/diqttype.h" /* for DcmQuantHashSize, DcmQuantComponent */
37 #include "dcmtk/dcmimage/diqtstab.h" /* for DcmScaleTable */
38 
39 
45 {
46 public:
47 
51  : red(0)
52  , green(0)
53  , blue(0)
54  {
55  }
56 
60  : red(arg.red)
61  , green(arg.green)
62  , blue(arg.blue)
63  {
64  }
65 
66  // we don't declare a destructor here, but the standard destructor will do.
67 
69  inline OFBool operator==(const DcmQuantPixel& src) const
70  {
71  return (red == src.red) && (green == src.green) && (blue == src.blue);
72  }
73 
80  inline double luminance() const
81  {
82  return 0.299 * red + 0.587 * green + 0.114 * blue;
83  }
84 
90  inline unsigned long hash() const
91  {
92  return ((OFstatic_cast(unsigned long, red) * 33023UL + OFstatic_cast(unsigned long, green) * 30013UL +
93  OFstatic_cast(unsigned long, blue) * 27011UL) & 0x7fffffffUL) % DcmQuantHashSize;
94  }
95 
99  inline DcmQuantComponent getRed() const
100  {
101  return red;
102  }
103 
107  inline DcmQuantComponent getGreen() const
108  {
109  return green;
110  }
111 
115  inline DcmQuantComponent getBlue() const
116  {
117  return blue;
118  }
119 
125  inline void assign(
126  DcmQuantComponent r,
127  DcmQuantComponent g,
128  DcmQuantComponent b)
129  {
130  red = r;
131  green = g;
132  blue = b;
133  }
134 
143  inline void scale(
144  DcmQuantComponent r,
145  DcmQuantComponent g,
146  DcmQuantComponent b,
147  const DcmQuantScaleTable& table)
148  {
149  red = table[r];
150  green = table[g];
151  blue = table[b];
152  }
153 
154 private:
156  DcmQuantComponent red;
157 
159  DcmQuantComponent green;
160 
162  DcmQuantComponent blue;
163 };
164 
165 
166 #endif
167 
168 
169 /*
170  * CVS/RCS Log:
171  * $Log: diqtpix.h,v $
172  * Revision 1.4 2010-10-14 13:16:30 joergr
173  * Updated copyright header. Added reference to COPYRIGHT file.
174  *
175  * Revision 1.3 2005/12/08 16:01:53 meichel
176  * Changed include path schema for all DCMTK header files
177  *
178  * Revision 1.2 2003/12/23 12:20:07 joergr
179  * Adapted type casts to new-style typecast operators defined in ofcast.h.
180  * Updated copyright header.
181  *
182  * Revision 1.1 2002/01/25 13:32:07 meichel
183  * Initial release of new color quantization classes and
184  * the dcmquant tool in module dcmimage.
185  *
186  *
187  */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2