1 /* 2 * 3 * Copyright (C) 2002-2014, 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 DcmQuantHistogramItem 19 * 20 */ 21 22 23 #ifndef DIQTHITM_H 24 #define DIQTHITM_H 25 26 27 #include "dcmtk/config/osconfig.h" 28 #include "dcmtk/ofstd/oftypes.h" /* for OFBool */ 29 #include "dcmtk/dcmimage/diqtpix.h" /* for DcmQuantPixel */ 30 31 32 /** this class extends DcmQuantPixel by an integer value 33 * which is used for various purposes. 34 * The class is used as a helper class during computation of an image 35 * histogram, as a member of a color LUT and as a member of a color hash 36 * table. 37 */ 38 class DCMTK_DCMIMAGE_EXPORT DcmQuantHistogramItem: public DcmQuantPixel 39 { 40 public: 41 /** constructor 42 * @param colorP pixel value 43 * @param val initial value 44 */ DcmQuantHistogramItem(const DcmQuantPixel & colorP,int val)45 DcmQuantHistogramItem(const DcmQuantPixel& colorP, int val) 46 : DcmQuantPixel(colorP) 47 , value(val) 48 { 49 } 50 51 /// default constructor DcmQuantHistogramItem()52 DcmQuantHistogramItem() 53 : DcmQuantPixel() 54 , value(0) 55 { 56 } 57 58 // we don't declare a destructor here, but the standard destructor will do. 59 60 /** compares the stored pixel value with the given pixel. 61 * @param colorP pixel to compare with 62 * @return true if pixel values are equal, false otherwise 63 */ equals(const DcmQuantPixel & colorP)64 inline OFBool equals(const DcmQuantPixel& colorP) const 65 { 66 return *this == colorP; 67 } 68 69 /// returns the integer value maintained by this object getValue()70 inline int getValue() const 71 { 72 return value; 73 } 74 75 /** assigns a new integer value to this object 76 * @param v new value 77 */ setValue(int v)78 inline void setValue(int v) 79 { 80 value = v; 81 } 82 83 /// increases the integer value maintained by this object by one incValue()84 inline void incValue() 85 { 86 ++value; 87 } 88 89 private: 90 91 /** integer value assigned to this pixel. This value is used for different 92 * purposes. 93 * During computation of a histogram it is used as a counter that counts 94 * the instances of the current color. 95 * In a color hash table, it contains the index value from the color LUT 96 * assigned to this color. 97 * In a color LUT, it is the cluster value, i.e. the radius in which all 98 * color are guaranteed to be mapped to this palette color. 99 */ 100 int value; 101 102 }; 103 104 105 /// typedef for a pointer to a DcmQuantHistogramItem object 106 typedef DcmQuantHistogramItem *DcmQuantHistogramItemPointer; 107 108 109 #endif 110