|
Slicer 4.2
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
|
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkComputeRestrictedHistogram.h,v $ 00005 Language: C++ 00006 Date: $Date: 2006/03/29 14:53:40 $ 00007 Version: $Revision: 1.5 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkComputeRestrictedHistogram_h 00018 #define __itkComputeRestrictedHistogram_h 00019 00020 #include "itkImageToImageFilter.h" 00021 #include "itkImage.h" 00022 #include "itkArray2D.h" 00023 #include "itkArray.h" 00024 00025 namespace itk 00026 { 00030 template <class TInputImage, class TOutputImage> 00031 class ITK_EXPORT ComputeRestrictedHistogram : public ImageToImageFilter<TInputImage, TOutputImage> 00032 { 00033 public: 00035 typedef TInputImage InputImageType; 00036 typedef TOutputImage OutputImageType; 00037 00039 typedef ComputeRestrictedHistogram Self; 00040 typedef ImageToImageFilter<InputImageType, OutputImageType> Superclass; 00041 typedef SmartPointer<Self> Pointer; 00042 typedef SmartPointer<const Self> ConstPointer; 00043 00045 itkNewMacro(Self); 00046 00048 itkTypeMacro( ComputeRestrictedHistogram, ImageToImageFilter ); 00049 00051 typedef typename InputImageType::PixelType InputPixelType; 00052 typedef typename OutputImageType::PixelType OutputPixelType; 00053 typedef typename NumericTraits<InputPixelType>::RealType InputRealType; 00054 typedef typename InputImageType::RegionType InputImageRegionType; 00055 typedef typename OutputImageType::RegionType OutputImageRegionType; 00056 typedef typename InputImageType::SizeType InputSizeType; 00057 00059 typedef itk::Array2D<unsigned long> ThreadHistogramType; 00060 typedef itk::Array<unsigned long> HistogramType; 00061 00063 itkGetConstReferenceMacro( Min, double ); 00064 itkGetConstReferenceMacro( Max, double ); 00065 itkSetMacro( Min, double ); 00066 itkSetMacro( Max, double ); 00067 itkGetConstReferenceMacro( Bins, unsigned int ); 00068 itkSetMacro( Bins, unsigned int ); 00069 itkGetConstReferenceMacro( Mode, double ); 00070 itkGetConstReferenceMacro( Ready, bool ); 00071 itkGetConstReferenceMacro( Histogram, HistogramType ); 00072 protected: 00073 ComputeRestrictedHistogram(); 00074 virtual ~ComputeRestrictedHistogram() 00075 { 00076 } 00077 #if ITK_VERSION_MAJOR < 4 00078 void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, int threadId ); 00079 00080 #else 00081 void ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId ); 00082 00083 #endif 00084 // Override Modified() method to fix the ready variable: 00085 void Modified() 00086 { 00087 this->Superclass::Modified(); 00088 m_Ready = false; 00089 } 00090 00091 using itk::Object::Modified; 00092 void BeforeThreadedGenerateData(); 00093 00094 void AfterThreadedGenerateData(); 00095 00096 private: 00097 ComputeRestrictedHistogram(const Self &); // purposely not implemented 00098 void operator=(const Self &); // purposely not implemented 00099 00100 // Per-thread histogram: 00101 ThreadHistogramType m_THist; 00102 // Complete histogram: 00103 HistogramType m_Histogram; 00104 00105 // Parameters: 00106 double m_Min; 00107 double m_Max; 00108 unsigned int m_Bins; 00109 00110 // Mode of the distribution value: 00111 double m_Mode; 00112 00113 // Are the data already computed? 00114 bool m_Ready; 00115 }; 00116 00117 } // end namespace itk 00118 00119 #ifndef ITK_MANUAL_INSTANTIATION 00120 #include "itkComputeRestrictedHistogram.txx" 00121 #endif 00122 00123 #endif
1.7.4