/usr/include/dcmtk/dcmimage/diqtctab.h is in libdcmtk2-dev 3.6.0-15.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | /*
*
* Copyright (C) 2002-2010, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
*
* OFFIS e.V.
* R&D Division Health
* Escherweg 2
* D-26121 Oldenburg, Germany
*
*
* Module: dcmimage
*
* Author: Marco Eichelberg
*
* Purpose: class DcmQuantColorTable
*
* Last Update: $Author: joergr $
* Update Date: $Date: 2010-10-14 13:16:29 $
* CVS/RCS Revision: $Revision: 1.7 $
* Status: $State: Exp $
*
* CVS/RCS Log at end of file
*
*/
#ifndef DIQTCTAB_H
#define DIQTCTAB_H
#include "dcmtk/config/osconfig.h"
#include "dcmtk/ofstd/oftypes.h" /* for OFBool */
#include "dcmtk/ofstd/ofcond.h" /* for OFCondition */
#include "dcmtk/dcmimage/diqtpix.h" /* for DcmQuantPixel */
#include "dcmtk/dcmimage/diqthash.h" /* for DcmQuantHistogramItem */
#include "dcmtk/ofstd/ofstring.h" /* for class OFString */
class DicomImage;
class DcmItem;
/** this class implements a color table that can either be
* a look-up table or an image color histogram.
*/
class DcmQuantColorTable
{
public:
/// constructor
DcmQuantColorTable();
/// destructor
~DcmQuantColorTable();
/// resets the object to default-constructed state
void clear();
/** returns the number of colors in the color table
* @return number of colors in color table
*/
inline unsigned long getColors() const
{
return numColors;
}
/** creates a description string suitable for use as
* Derivation Description.
* @param str description string returned in this parameter
*/
void setDescriptionString(OFString& str) const;
/** creates a color table containing a histogram of the given
* image. Pixel sample values are downsampled if necessary
* to make sure the histogram fits into the given size limit.
* @param image color image for which a histogram is computed
* @param maxcolors maximum number of colors allowed in histogram.
* If necessary, pixel sample values are down-sampled to enforce
* this maximum.
* @return EC_Normal if successful, an error code otherwise.
*/
OFCondition computeHistogram(DicomImage& image, unsigned long maxcolors);
/** after a call to computeHistogram(), this method
* returns the maximum pixel value to which all color samples
* were down-sampled during computation of the histogram.
*/
inline unsigned long getMaxVal() const
{
return maxval;
}
/** returns the color at index idx.
* @param idx index, must be < getColors()
* @return const reference to color
*/
inline const DcmQuantPixel& getPixel(unsigned long idx) const
{
#ifdef DEBUG
assert(array && idx < numColors);
#endif
return *(array[idx]);
}
/** returns the red color component at index idx
* @param idx index, must be < getColors()
* @return red color component
*/
inline DcmQuantComponent getRed(unsigned long idx) const
{
#ifdef DEBUG
assert(array && idx < numColors);
#endif
return array[idx]->getRed();
}
/** returns the green color component at index idx
* @param idx index, must be < getColors()
* @return green color component
*/
inline DcmQuantComponent getGreen(unsigned long idx) const
{
#ifdef DEBUG
assert(array && idx < numColors);
#endif
return array[idx]->getGreen();
}
/** returns the blue color component at index idx
* @param idx index, must be < getColors()
* @return blue color component
*/
inline DcmQuantComponent getBlue(unsigned long idx) const
{
#ifdef DEBUG
assert(array && idx < numColors);
#endif
return array[idx]->getBlue();
}
/** computes a color LUT for the given image histogram.
* This median-cut colormap generator is based
* on Paul Heckbert's paper "Color Image Quantization for Frame Buffer
* Display", SIGGRAPH '82 Proceedings, page 297.
* @param histogram image color histogram
* @param sum number of pixels in image (colums * rows * frames)
* @param theMaxval maximum value to which pixels were
* downsampled for histogram computation
* @param numberOfColors desired number of colors in color LUT
* @param largeType algorithm used for determining the largest dimension
* in the Median Cut algorithm
* @param repType algorithm for choosing a representative color for each
* box in the Median Cut algorithm
* @return EC_Normal if successful, an error code otherwise.
*/
OFCondition medianCut(
DcmQuantColorTable& histogram,
unsigned long sum,
unsigned long theMaxval,
unsigned long numberOfColors,
DcmLargestDimensionType largeType,
DcmRepresentativeColorType repType);
/** determines for a given color the closest match in the color LUT.
* @param px color to look up in LUT
* @return index of closest match in LUT, -1 if look-up table empty
*/
inline int computeIndex(const DcmQuantPixel& px) const
{
int result = -1;
register int r2, g2, b2;
register long newdist;
register int r1 = OFstatic_cast(int, px.getRed());
register int g1 = OFstatic_cast(int, px.getGreen());
register int b1 = OFstatic_cast(int, px.getBlue());
register long dist = 2000000000;
for (unsigned long i = 0; i < numColors; ++i)
{
r2 = r1 - OFstatic_cast(int, array[i]->getRed());
g2 = g1 - OFstatic_cast(int, array[i]->getGreen());
b2 = b1 - OFstatic_cast(int, array[i]->getBlue());
newdist = r2*r2 + g2*g2 + b2*b2;
if (newdist < dist)
{
result = OFstatic_cast(int, i);
dist = newdist;
if (dist < array[i]->getValue()) i=numColors; // break out of for loop
}
}
return result;
}
/** writes the current color table into a DICOM object, encoded as
* Red/Green/Blue Palette Color Lookup Table and Data.
* @param target DICOM dataset to write to
* @param writeAsOW if true, LUT data is encoded as OW, otherwise LUT data
* is encoded as US. A LUT with 64k entries is always encoded as OW since
* a US data element with 64k entries cannot be written in explicit VR.
* @param write16BitEntries if true, LUT data is encoded with 16 bits per entry
* @return EC_Normal if successful, an error code otherwise.
*/
OFCondition write(
DcmItem& target,
OFBool writeAsOW,
OFBool write16BitEntries);
private:
/** after a call to medianCut(), this method computes for each entry in
* the color map the minimum of the euclidean distances to any other
* of the entries. Any color which has an euclidean distance of less
* than half of this distance is necessarily mapped to this entry.
* This data is used by computeIndex()
*/
void computeClusters();
/// private undefined copy constructor
DcmQuantColorTable(const DcmQuantColorTable& src);
/// private undefined copy assignment operator
DcmQuantColorTable& operator=(const DcmQuantColorTable& src);
/// color table data
DcmQuantHistogramItemPointer *array;
/// number of entries in color table
unsigned long numColors;
/** maximum pixel value to which all color samples
* were down-sampled during computation of the histogram.
*/
unsigned long maxval;
};
#endif
/*
* CVS/RCS Log:
* $Log: diqtctab.h,v $
* Revision 1.7 2010-10-14 13:16:29 joergr
* Updated copyright header. Added reference to COPYRIGHT file.
*
* Revision 1.6 2005/12/08 16:01:45 meichel
* Changed include path schema for all DCMTK header files
*
* Revision 1.5 2003/12/23 12:15:40 joergr
* Adapted type casts to new-style typecast operators defined in ofcast.h.
* Updated copyright header.
*
* Revision 1.4 2003/07/04 13:25:40 meichel
* Replaced forward declarations for OFString with explicit includes,
* needed when compiling with HAVE_STD_STRING
*
* Revision 1.3 2003/06/12 15:09:41 joergr
* Fixed inconsistent API documentation reported by Doxygen.
*
* Revision 1.2 2002/05/15 09:53:29 meichel
* Minor corrections to avoid warnings on Sun CC 2.0.1
*
* Revision 1.1 2002/01/25 13:32:04 meichel
* Initial release of new color quantization classes and
* the dcmquant tool in module dcmimage.
*
*
*/
|