OFFIS DCMTK
Version 3.6.0
Main Page
Related Pages
Classes
Files
File List
File Members
dcmimage
include
dcmtk
dcmimage
diqtctab.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 DcmQuantColorTable
19
*
20
* Last Update: $Author: joergr $
21
* Update Date: $Date: 2010-10-14 13:16:29 $
22
* CVS/RCS Revision: $Revision: 1.7 $
23
* Status: $State: Exp $
24
*
25
* CVS/RCS Log at end of file
26
*
27
*/
28
29
30
#ifndef DIQTCTAB_H
31
#define DIQTCTAB_H
32
33
#include "dcmtk/config/osconfig.h"
34
#include "dcmtk/ofstd/oftypes.h"
/* for OFBool */
35
#include "dcmtk/ofstd/ofcond.h"
/* for OFCondition */
36
#include "dcmtk/dcmimage/diqtpix.h"
/* for DcmQuantPixel */
37
#include "dcmtk/dcmimage/diqthash.h"
/* for DcmQuantHistogramItem */
38
#include "dcmtk/ofstd/ofstring.h"
/* for class OFString */
39
40
41
class
DicomImage
;
42
class
DcmItem
;
43
44
48
class
DcmQuantColorTable
49
{
50
public
:
51
53
DcmQuantColorTable
();
54
56
~DcmQuantColorTable
();
57
59
void
clear
();
60
64
inline
unsigned
long
getColors
()
const
65
{
66
return
numColors
;
67
}
68
73
void
setDescriptionString
(
OFString
& str)
const
;
74
84
OFCondition
computeHistogram
(
DicomImage
& image,
unsigned
long
maxcolors);
85
90
inline
unsigned
long
getMaxVal
()
const
91
{
92
return
maxval
;
93
}
94
99
inline
const
DcmQuantPixel
&
getPixel
(
unsigned
long
idx)
const
100
{
101
#ifdef DEBUG
102
assert(
array
&& idx <
numColors
);
103
#endif
104
return
*(
array
[idx]);
105
}
106
111
inline
DcmQuantComponent
getRed
(
unsigned
long
idx)
const
112
{
113
#ifdef DEBUG
114
assert(
array
&& idx <
numColors
);
115
#endif
116
return
array
[idx]->
getRed
();
117
}
118
123
inline
DcmQuantComponent
getGreen
(
unsigned
long
idx)
const
124
{
125
#ifdef DEBUG
126
assert(
array
&& idx <
numColors
);
127
#endif
128
return
array
[idx]->
getGreen
();
129
}
130
135
inline
DcmQuantComponent
getBlue
(
unsigned
long
idx)
const
136
{
137
#ifdef DEBUG
138
assert(
array
&& idx <
numColors
);
139
#endif
140
return
array
[idx]->
getBlue
();
141
}
142
158
OFCondition
medianCut
(
159
DcmQuantColorTable
& histogram,
160
unsigned
long
sum,
161
unsigned
long
theMaxval,
162
unsigned
long
numberOfColors,
163
DcmLargestDimensionType largeType,
164
DcmRepresentativeColorType repType);
165
170
inline
int
computeIndex
(
const
DcmQuantPixel
& px)
const
171
{
172
int
result = -1;
173
register
int
r2, g2, b2;
174
register
long
newdist;
175
register
int
r1 = OFstatic_cast(
int
, px.
getRed
());
176
register
int
g1 = OFstatic_cast(
int
, px.
getGreen
());
177
register
int
b1 = OFstatic_cast(
int
, px.
getBlue
());
178
register
long
dist = 2000000000;
179
for
(
unsigned
long
i = 0; i <
numColors
; ++i)
180
{
181
r2 = r1 - OFstatic_cast(
int
,
array
[i]->
getRed
());
182
g2 = g1 - OFstatic_cast(
int
,
array
[i]->
getGreen
());
183
b2 = b1 - OFstatic_cast(
int
,
array
[i]->
getBlue
());
184
newdist = r2*r2 + g2*g2 + b2*b2;
185
if
(newdist < dist)
186
{
187
result = OFstatic_cast(
int
, i);
188
dist = newdist;
189
if
(dist <
array
[i]->getValue()) i=
numColors
;
// break out of for loop
190
}
191
}
192
return
result;
193
}
194
204
OFCondition
write
(
205
DcmItem
& target,
206
OFBool writeAsOW,
207
OFBool write16BitEntries);
208
209
210
private
:
211
218
void
computeClusters
();
219
221
DcmQuantColorTable
(
const
DcmQuantColorTable
& src);
222
224
DcmQuantColorTable
&
operator=
(
const
DcmQuantColorTable
& src);
225
227
DcmQuantHistogramItemPointer
*
array
;
228
230
unsigned
long
numColors
;
231
235
unsigned
long
maxval
;
236
237
};
238
239
#endif
240
241
242
/*
243
* CVS/RCS Log:
244
* $Log: diqtctab.h,v $
245
* Revision 1.7 2010-10-14 13:16:29 joergr
246
* Updated copyright header. Added reference to COPYRIGHT file.
247
*
248
* Revision 1.6 2005/12/08 16:01:45 meichel
249
* Changed include path schema for all DCMTK header files
250
*
251
* Revision 1.5 2003/12/23 12:15:40 joergr
252
* Adapted type casts to new-style typecast operators defined in ofcast.h.
253
* Updated copyright header.
254
*
255
* Revision 1.4 2003/07/04 13:25:40 meichel
256
* Replaced forward declarations for OFString with explicit includes,
257
* needed when compiling with HAVE_STD_STRING
258
*
259
* Revision 1.3 2003/06/12 15:09:41 joergr
260
* Fixed inconsistent API documentation reported by Doxygen.
261
*
262
* Revision 1.2 2002/05/15 09:53:29 meichel
263
* Minor corrections to avoid warnings on Sun CC 2.0.1
264
*
265
* Revision 1.1 2002/01/25 13:32:04 meichel
266
* Initial release of new color quantization classes and
267
* the dcmquant tool in module dcmimage.
268
*
269
*
270
*/
Generated on Thu Dec 20 2012 for
OFFIS DCMTK
Version 3.6.0 by
Doxygen
1.8.2