OFFIS DCMTK  Version 3.6.0
diqtstab.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 DcmQuantScaleTable
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:16:30 $
22  * CVS/RCS Revision: $Revision: 1.5 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef DIQTSTAB_H
31 #define DIQTSTAB_H
32 
33 
34 #include "dcmtk/config/osconfig.h"
35 #include "dcmtk/ofstd/ofcast.h"
36 #include "dcmtk/dcmimage/diqttype.h" /* for DcmQuantComponent */
37 
38 #define INCLUDE_CSTDLIB
39 #define INCLUDE_CASSERT
40 #include "dcmtk/ofstd/ofstdinc.h"
41 
42 
49 {
50 public:
51 
54  : table(NULL)
55  , numEntries(0)
56  {
57  }
58 
61  {
62  cleanup();
63  }
64 
71  inline DcmQuantComponent operator[](unsigned int idx) const
72  {
73 #ifdef DEBUG
74  assert(idx < numEntries);
75 #endif
76  return table[idx];
77  }
78 
84  unsigned long oldmaxval,
85  unsigned long newmaxval)
86  {
87  cleanup();
88 
89  table = new DcmQuantComponent[oldmaxval+1];
90  if (table)
91  {
92  numEntries = OFstatic_cast(unsigned int, oldmaxval) + 1;
93  for (unsigned int i=0; i < numEntries; i++)
94  table[i] = OFstatic_cast(DcmQuantComponent, (OFstatic_cast(unsigned long, i) * newmaxval + oldmaxval/2) / oldmaxval);
95  }
96  }
97 
98 private:
99 
101  inline void cleanup()
102  {
103  delete[] table;
104  table = NULL;
105  numEntries = 0;
106  }
107 
110 
113 
115  DcmQuantComponent *table;
116 
118  unsigned int numEntries;
119 };
120 
121 
122 #endif
123 
124 
125 /*
126  * CVS/RCS Log:
127  * $Log: diqtstab.h,v $
128  * Revision 1.5 2010-10-14 13:16:30 joergr
129  * Updated copyright header. Added reference to COPYRIGHT file.
130  *
131  * Revision 1.4 2005/12/08 16:01:54 meichel
132  * Changed include path schema for all DCMTK header files
133  *
134  * Revision 1.3 2003/12/23 12:20:44 joergr
135  * Adapted type casts to new-style typecast operators defined in ofcast.h.
136  * Updated copyright header.
137  *
138  * Revision 1.2 2002/11/27 14:16:56 meichel
139  * Adapted module dcmimage to use of new header file ofstdinc.h
140  *
141  * Revision 1.1 2002/01/25 13:32:07 meichel
142  * Initial release of new color quantization classes and
143  * the dcmquant tool in module dcmimage.
144  *
145  *
146  */


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