ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImageToHistogramFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkImageToHistogramFilter_h
00019 #define __itkImageToHistogramFilter_h
00020 
00021 #include "itkHistogram.h"
00022 #include "itkImageTransformer.h"
00023 #include "itkBarrier.h"
00024 #include "itkSimpleDataObjectDecorator.h"
00025 #include "itkProgressReporter.h"
00026 
00027 namespace itk
00028 {
00029 namespace Statistics
00030 {
00042 template< class TImage >
00043 class ITK_EXPORT ImageToHistogramFilter:public ImageTransformer<TImage>
00044 {
00045 public:
00047   typedef ImageToHistogramFilter     Self;
00048   typedef ImageTransformer<TImage>   Superclass;
00049   typedef SmartPointer< Self >       Pointer;
00050   typedef SmartPointer< const Self > ConstPointer;
00051 
00053   itkTypeMacro(ImageToHistogramFilter, ImageTransformer);
00054 
00056   itkNewMacro(Self);
00057 
00058   typedef TImage                                         ImageType;
00059   typedef typename ImageType::PixelType                  PixelType;
00060   typedef typename ImageType::RegionType                 RegionType;
00061   typedef typename NumericTraits< PixelType >::ValueType ValueType;
00062   typedef typename NumericTraits< ValueType >::RealType  ValueRealType;
00063 
00064   typedef Histogram< ValueRealType >                    HistogramType;
00065   typedef typename HistogramType::Pointer               HistogramPointer;
00066   typedef typename HistogramType::ConstPointer          HistogramConstPointer;
00067   typedef typename HistogramType::SizeType              HistogramSizeType;
00068   typedef typename HistogramType::MeasurementType       HistogramMeasurementType;
00069   typedef typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType;
00070 
00071 public:
00072 
00074   const HistogramType * GetOutput() const;
00075   HistogramType * GetOutput();
00077 
00079   typedef SimpleDataObjectDecorator<
00080     HistogramSizeType > InputHistogramSizeObjectType;
00081 
00083   typedef SimpleDataObjectDecorator<
00084     HistogramMeasurementType > InputHistogramMeasurementObjectType;
00085 
00088   typedef SimpleDataObjectDecorator<
00089     HistogramMeasurementVectorType > InputHistogramMeasurementVectorObjectType;
00090 
00092   typedef SimpleDataObjectDecorator< bool > InputBooleanObjectType;
00093 
00100   itkSetGetDecoratedInputMacro(HistogramSize, HistogramSizeType);
00101 
00105   itkSetGetDecoratedInputMacro(MarginalScale, HistogramMeasurementType);
00106 
00109   itkSetGetDecoratedInputMacro(HistogramBinMinimum, HistogramMeasurementVectorType);
00110   itkSetGetDecoratedInputMacro(HistogramBinMaximum, HistogramMeasurementVectorType);
00112 
00116   itkSetGetDecoratedInputMacro(AutoMinimumMaximum, bool);
00117 
00120   virtual void GraftOutput(DataObject *output);
00121 
00122 protected:
00123   ImageToHistogramFilter();
00124   virtual ~ImageToHistogramFilter() {}
00125   void PrintSelf(std::ostream & os, Indent indent) const;
00126 
00127   void BeforeThreadedGenerateData(void);
00128   void ThreadedGenerateData(const RegionType & inputRegionForThread, ThreadIdType threadId);
00129   void AfterThreadedGenerateData(void);
00130 
00132   typedef ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
00133   using Superclass::MakeOutput;
00134   DataObject::Pointer  MakeOutput(DataObjectPointerArraySizeType);
00135 
00136   virtual void ThreadedComputeMinimumAndMaximum( const RegionType & inputRegionForThread, ThreadIdType threadId, ProgressReporter & progress );
00137   virtual void ThreadedComputeHistogram( const RegionType & inputRegionForThread, ThreadIdType threadId, ProgressReporter & progress );
00138 
00139   std::vector< HistogramPointer >               m_Histograms;
00140   std::vector< HistogramMeasurementVectorType > m_Minimums;
00141   std::vector< HistogramMeasurementVectorType > m_Maximums;
00142 
00143 private:
00144   ImageToHistogramFilter(const Self &); //purposely not implemented
00145   void operator=(const Self &);         //purposely not implemented
00146 
00147   void ApplyMarginalScale( HistogramMeasurementVectorType & min, HistogramMeasurementVectorType & max, HistogramSizeType & size );
00148   typename Barrier::Pointer                     m_Barrier;
00149 
00150 };
00151 } // end of namespace Statistics
00152 } // end of namespace itk
00153 
00154 #ifndef ITK_MANUAL_INSTANTIATION
00155 #include "itkImageToHistogramFilter.hxx"
00156 #endif
00157 
00158 #endif
00159