00001 /* 00002 * 00003 * Copyright (C) 2002-2010, OFFIS e.V. 00004 * All rights reserved. See COPYRIGHT file for details. 00005 * 00006 * This software and supporting documentation were developed by 00007 * 00008 * OFFIS e.V. 00009 * R&D Division Health 00010 * Escherweg 2 00011 * D-26121 Oldenburg, Germany 00012 * 00013 * 00014 * Module: dcmimage 00015 * 00016 * Author: Marco Eichelberg 00017 * 00018 * Purpose: class DcmQuantHistogramItemList 00019 * 00020 * Last Update: $Author: joergr $ 00021 * Update Date: $Date: 2010-10-14 13:16:29 $ 00022 * CVS/RCS Revision: $Revision: 1.4 $ 00023 * Status: $State: Exp $ 00024 * 00025 * CVS/RCS Log at end of file 00026 * 00027 */ 00028 00029 00030 #ifndef DIQTHITL_H 00031 #define DIQTHITL_H 00032 00033 00034 #include "dcmtk/config/osconfig.h" 00035 #include "dcmtk/ofstd/oflist.h" /* for OFList */ 00036 #include "dcmtk/dcmimage/diqthitm.h" /* for DcmQuantHistogramItem */ 00037 00038 00042 class DcmQuantHistogramItemList 00043 { 00044 public: 00045 00047 DcmQuantHistogramItemList(); 00048 00050 ~DcmQuantHistogramItemList(); 00051 00060 void moveto(DcmQuantHistogramItemPointer *array, unsigned long& counter, unsigned long numcolors); 00061 00067 inline int lookup(const DcmQuantPixel& colorP) 00068 { 00069 first = list_.begin(); 00070 while (first != last) 00071 { 00072 if ((*first)->equals(colorP)) return (*first)->getValue(); 00073 ++first; 00074 } 00075 return -1; 00076 } 00077 00085 inline unsigned long add(const DcmQuantPixel& colorP) 00086 { 00087 first = list_.begin(); 00088 while (first != last) 00089 { 00090 if ((*first)->equals(colorP)) 00091 { 00092 (*first)->incValue(); 00093 return 0; 00094 } 00095 ++first; 00096 } 00097 00098 // not found in list, create new entry 00099 list_.push_front(new DcmQuantHistogramItem(colorP, 1)); 00100 return 1; 00101 } 00102 00107 inline void push_front(const DcmQuantPixel& colorP, int value) 00108 { 00109 list_.push_front(new DcmQuantHistogramItem(colorP, value)); 00110 } 00111 00113 inline size_t size() const 00114 { 00115 return list_.size(); 00116 } 00117 00118 private: 00119 00121 OFList<DcmQuantHistogramItem *> list_; 00122 00124 OFListIterator(DcmQuantHistogramItem *) first; 00125 00127 OFListIterator(DcmQuantHistogramItem *) last; 00128 00129 }; 00130 00131 00133 typedef DcmQuantHistogramItemList *DcmQuantHistogramItemListPointer; 00134 00135 00136 #endif 00137 00138 00139 /* 00140 * CVS/RCS Log: 00141 * $Log: diqthitl.h,v $ 00142 * Revision 1.4 2010-10-14 13:16:29 joergr 00143 * Updated copyright header. Added reference to COPYRIGHT file. 00144 * 00145 * Revision 1.3 2005/12/08 16:01:49 meichel 00146 * Changed include path schema for all DCMTK header files 00147 * 00148 * Revision 1.2 2003/12/17 16:57:55 joergr 00149 * Renamed parameters/variables "list" to avoid name clash with STL class. 00150 * 00151 * Revision 1.1 2002/01/25 13:32:05 meichel 00152 * Initial release of new color quantization classes and 00153 * the dcmquant tool in module dcmimage. 00154 * 00155 * 00156 */