ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkLabelImageToStatisticsLabelMapFilter.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 __itkLabelImageToStatisticsLabelMapFilter_h
00019 #define __itkLabelImageToStatisticsLabelMapFilter_h
00020 
00021 #include "itkStatisticsLabelObject.h"
00022 #include "itkLabelImageToLabelMapFilter.h"
00023 #include "itkStatisticsLabelMapFilter.h"
00024 
00025 namespace itk
00026 {
00040 template< class TInputImage, class TFeatureImage, class TOutputImage =
00041             LabelMap< StatisticsLabelObject< typename TInputImage::PixelType,
00042                                              ::itk::GetImageDimension< TInputImage >::ImageDimension > > >
00043 class ITK_EXPORT LabelImageToStatisticsLabelMapFilter:
00044   public ImageToImageFilter< TInputImage, TOutputImage >
00045 {
00046 public:
00048   typedef LabelImageToStatisticsLabelMapFilter            Self;
00049   typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
00050   typedef SmartPointer< Self >                            Pointer;
00051   typedef SmartPointer< const Self >                      ConstPointer;
00052 
00054   typedef TInputImage                           InputImageType;
00055   typedef typename InputImageType::Pointer      InputImagePointer;
00056   typedef typename InputImageType::ConstPointer InputImageConstPointer;
00057   typedef typename InputImageType::RegionType   InputImageRegionType;
00058   typedef typename InputImageType::PixelType    InputImagePixelType;
00059 
00060   typedef TOutputImage                              OutputImageType;
00061   typedef typename OutputImageType::Pointer         OutputImagePointer;
00062   typedef typename OutputImageType::ConstPointer    OutputImageConstPointer;
00063   typedef typename OutputImageType::RegionType      OutputImageRegionType;
00064   typedef typename OutputImageType::PixelType       OutputImagePixelType;
00065   typedef typename OutputImageType::LabelObjectType LabelObjectType;
00066 
00067   typedef TFeatureImage                           FeatureImageType;
00068   typedef typename FeatureImageType::Pointer      FeatureImagePointer;
00069   typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
00070   typedef typename FeatureImageType::PixelType    FeatureImagePixelType;
00071 
00073   itkStaticConstMacro(InputImageDimension, unsigned int,
00074                       TInputImage::ImageDimension);
00075   itkStaticConstMacro(OutputImageDimension, unsigned int,
00076                       TInputImage::ImageDimension);
00077   itkStaticConstMacro(ImageDimension, unsigned int,
00078                       TInputImage::ImageDimension);
00080 
00081   typedef LabelImageToLabelMapFilter< InputImageType, OutputImageType > LabelizerType;
00082   typedef StatisticsLabelMapFilter< OutputImageType, FeatureImageType > LabelObjectValuatorType;
00083 
00085   itkNewMacro(Self);
00086 
00088   itkTypeMacro(LabelImageToStatisticsLabelMapFilter,
00089                ImageToImageFilter);
00090 
00091 #ifdef ITK_USE_CONCEPT_CHECKING
00092 
00093   itkConceptMacro( InputEqualityComparableCheck,
00094                    ( Concept::EqualityComparable< InputImagePixelType > ) );
00095   itkConceptMacro( IntConvertibleToInputCheck,
00096                    ( Concept::Convertible< int, InputImagePixelType > ) );
00097   itkConceptMacro( InputOStreamWritableCheck,
00098                    ( Concept::OStreamWritable< InputImagePixelType > ) );
00099 
00101 #endif
00102 
00107   itkSetMacro(BackgroundValue, OutputImagePixelType);
00108   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00110 
00115   itkSetMacro(ComputeFeretDiameter, bool);
00116   itkGetConstReferenceMacro(ComputeFeretDiameter, bool);
00117   itkBooleanMacro(ComputeFeretDiameter);
00119 
00124   itkSetMacro(ComputePerimeter, bool);
00125   itkGetConstReferenceMacro(ComputePerimeter, bool);
00126   itkBooleanMacro(ComputePerimeter);
00128 
00130   void SetFeatureImage(const TFeatureImage *input)
00131   {
00132     // Process object is not const-correct so the const casting is required.
00133     this->SetNthInput( 1, const_cast< TFeatureImage * >( input ) );
00134   }
00135 
00137   const FeatureImageType * GetFeatureImage()
00138   {
00139     return static_cast< FeatureImageType * >( this->ProcessObject::GetInput(1) );
00140   }
00141 
00143   void SetInput1(const InputImageType *input)
00144   {
00145     this->SetInput(input);
00146   }
00147 
00149   void SetInput2(const FeatureImageType *input)
00150   {
00151     this->SetFeatureImage(input);
00152   }
00153 
00160   itkSetMacro(ComputeHistogram, bool);
00161   itkGetConstReferenceMacro(ComputeHistogram, bool);
00162   itkBooleanMacro(ComputeHistogram);
00164 
00170   itkSetMacro(NumberOfBins, unsigned int);
00171   itkGetConstReferenceMacro(NumberOfBins, unsigned int);
00172 protected:
00173   LabelImageToStatisticsLabelMapFilter();
00174   ~LabelImageToStatisticsLabelMapFilter() {}
00175   void PrintSelf(std::ostream & os, Indent indent) const;
00177 
00181   void GenerateInputRequestedRegion();
00182 
00184   void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
00185 
00188   void GenerateData();
00189 
00190 private:
00191   LabelImageToStatisticsLabelMapFilter(const Self &); //purposely not
00192                                                       // implemented
00193   void operator=(const Self &);                       //purposely not
00194                                                       // implemented
00195 
00196   OutputImagePixelType m_BackgroundValue;
00197   bool                 m_ComputeFeretDiameter;
00198   bool                 m_ComputePerimeter;
00199   unsigned int         m_NumberOfBins;
00200   bool                 m_ComputeHistogram;
00201 }; // end of class
00202 } // end namespace itk
00203 
00204 #ifndef ITK_MANUAL_INSTANTIATION
00205 #include "itkLabelImageToStatisticsLabelMapFilter.hxx"
00206 #endif
00207 
00208 #endif
00209