diff --git a/Modules/MitkExt/Algorithms/mitkSimpleHistogram.h b/Modules/MitkExt/Algorithms/mitkSimpleHistogram.h index d089f3a05a..c07919851c 100644 --- a/Modules/MitkExt/Algorithms/mitkSimpleHistogram.h +++ b/Modules/MitkExt/Algorithms/mitkSimpleHistogram.h @@ -1,155 +1,162 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKSIMPLEHISTOGRAM_H #define MITKSIMPLEHISTOGRAM_H #include "MitkExtExports.h" #include #include #include #include namespace mitk { + +//##Documentation +//## @brief Abstract superclass for histograms with double values. +//## Classes which are deriving from this class can be cached +//## in the same way. class MitkExt_EXPORT SimpleHistogram { public: + /** @brief Returns the minimal value of the histogram. */ virtual double GetMin() const = 0; + /** @brief Returns the maximum value of the histogram. */ virtual double GetMax() const = 0; - + /** @brief Creates a new histogram out the source. */ virtual void ComputeFromBaseData( BaseData* source ) = 0; + /** @brief TODO: What should this method do?*/ virtual float GetRelativeBin( double start, double end ) const = 0; - }; class MitkExt_EXPORT SimpleImageHistogram : public SimpleHistogram { public: SimpleImageHistogram() { valid=false; histogram=0; } ~SimpleImageHistogram() { if(histogram) delete histogram; } typedef itk::Image CTImage; typedef itk::ImageRegionIterator< CTImage > CTIteratorType; typedef itk::ImageRegionIteratorWithIndex< CTImage > CTIteratorIndexType; typedef itk::Image BinImage; typedef itk::ImageRegionIterator< BinImage > BinIteratorType; typedef itk::ImageRegionIteratorWithIndex< BinImage > BinIteratorIndexType; typedef unsigned long CountType; protected: CountType *histogram; bool valid; int first; int last; int min; int max; CountType highest; double invLogHighest; public: double GetMin() const { if(!valid) return 0; return min; } double GetMax() const { if(!valid) return 1; return max; } void ComputeFromBaseData( BaseData* source ); float GetRelativeBin( double start, double end ) const; }; class MitkExt_EXPORT SimpleHistogramCache { public: static const unsigned int maxCacheSize = 64; class Element { public: mitk::WeakPointer baseData; itk::TimeStamp m_LastUpdateTime; virtual void ComputeFromBaseData(BaseData* baseData) = 0; virtual SimpleHistogram* GetHistogram() = 0; }; typedef std::list CacheContainer; CacheContainer cache; SimpleHistogramCache() { } ~SimpleHistogramCache() { TrimCache(true); } SimpleHistogram *operator[](BaseData::Pointer sp_BaseData); protected: void TrimCache(bool full=false) { unsigned int targetSize = full?0:maxCacheSize; while(cache.size()>targetSize) { delete cache.back(); cache.pop_back(); } } }; } #endif // MITKSIMPLEHISTOGRAM_H