ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkHistogramToImageFilter.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 __itkHistogramToImageFilter_h
00019 #define __itkHistogramToImageFilter_h
00020 
00021 #include "itkImageSource.h"
00022 #include "itkConceptChecking.h"
00023 #include "itkHistogram.h"
00024 #include "itkImageRegionIteratorWithIndex.h"
00025 #include "itkSimpleDataObjectDecorator.h"
00026 
00027 namespace itk
00028 {
00049 template< class THistogram, class TImage, class TFunction >
00050 class ITK_EXPORT HistogramToImageFilter:
00051   public ImageSource< TImage >
00052 {
00053 public:
00054 
00056   typedef TFunction                                           FunctorType;
00057   typedef HistogramToImageFilter                              Self;
00058   typedef ImageSource< TImage >                               Superclass;
00059   typedef SmartPointer< Self >                                Pointer;
00060   typedef SmartPointer< const Self >                          ConstPointer;
00061 
00062   typedef TImage                                              OutputImageType;
00063   typedef typename Superclass::Pointer                        OutputImagePointer;
00064   typedef typename OutputImageType::SpacingType               SpacingType;
00065   typedef typename OutputImageType::PointType                 PointType;
00066   typedef typename OutputImageType::PixelType                 OutputPixelType;
00067 
00068   // Define an iterator to iterate through the image
00069   typedef itk::ImageRegionIteratorWithIndex< OutputImageType > ImageIteratorType;
00070 
00072   itkNewMacro(Self);
00073 
00075   itkTypeMacro(HistogramToImageFilter, ImageSource);
00076 
00078   typedef typename Superclass::OutputImageRegionType OutputImageRegionType;
00079 
00081   typedef THistogram                                    HistogramType;
00082   typedef typename HistogramType::MeasurementVectorType MeasurementVectorType;
00083   typedef typename HistogramType::SizeType              HistogramSizeType;
00084   typedef typename OutputImageType::SizeType            SizeType;
00085 
00087   itkStaticConstMacro(ImageDimension, unsigned int, OutputImageType::ImageDimension);
00088 
00090   using Superclass::SetInput;
00091   virtual void SetInput(const HistogramType *histogram);
00092 
00093   const HistogramType * GetInput(void);
00094 
00101   void SetFunctor(const FunctorType & functor)
00102   {
00103     m_Functor = functor;
00104     this->Modified();
00105   }
00107 
00112   FunctorType & GetFunctor() { return m_Functor; }
00113   const FunctorType & GetFunctor() const { return m_Functor; }
00115 
00116   void SetTotalFrequency(SizeValueType n);
00117 
00118 protected:
00119   HistogramToImageFilter();
00120   ~HistogramToImageFilter();
00121 
00122   virtual void GenerateOutputInformation();
00123 
00124   virtual void GenerateData();
00125 
00126   FunctorType m_Functor;
00127 
00128   virtual void PrintSelf(std::ostream & os, Indent indent) const;
00129 
00130 private:
00131   HistogramToImageFilter(const Self &); //purposely not implemented
00132   void operator=(const Self &);         //purposely not implemented
00133 };
00134 } // end namespace itk
00135 
00136 #ifndef ITK_MANUAL_INSTANTIATION
00137 #include "itkHistogramToImageFilter.hxx"
00138 #endif
00139 
00140 #endif
00141