ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkLabelStatisticsOpeningImageFilter.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 __itkLabelStatisticsOpeningImageFilter_h
00019 #define __itkLabelStatisticsOpeningImageFilter_h
00020 
00021 #include "itkLabelImageToLabelMapFilter.h"
00022 #include "itkStatisticsLabelMapFilter.h"
00023 #include "itkStatisticsOpeningLabelMapFilter.h"
00024 #include "itkLabelMapToLabelImageFilter.h"
00025 
00026 namespace itk
00027 {
00045 template< class TInputImage, class TFeatureImage >
00046 class ITK_EXPORT LabelStatisticsOpeningImageFilter:
00047   public ImageToImageFilter< TInputImage, TInputImage >
00048 {
00049 public:
00051   typedef LabelStatisticsOpeningImageFilter              Self;
00052   typedef ImageToImageFilter< TInputImage, TInputImage > Superclass;
00053   typedef SmartPointer< Self >                           Pointer;
00054   typedef SmartPointer< const Self >                     ConstPointer;
00055 
00057   typedef TInputImage                            InputImageType;
00058   typedef TInputImage                            OutputImageType;
00059   typedef typename InputImageType::Pointer       InputImagePointer;
00060   typedef typename InputImageType::ConstPointer  InputImageConstPointer;
00061   typedef typename InputImageType::RegionType    InputImageRegionType;
00062   typedef typename InputImageType::PixelType     InputImagePixelType;
00063   typedef typename OutputImageType::Pointer      OutputImagePointer;
00064   typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
00065   typedef typename OutputImageType::RegionType   OutputImageRegionType;
00066   typedef typename OutputImageType::PixelType    OutputImagePixelType;
00067 
00068   typedef TFeatureImage                           FeatureImageType;
00069   typedef typename FeatureImageType::Pointer      FeatureImagePointer;
00070   typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
00071   typedef typename FeatureImageType::PixelType    FeatureImagePixelType;
00072 
00074   itkStaticConstMacro(InputImageDimension, unsigned int,
00075                       TInputImage::ImageDimension);
00076   itkStaticConstMacro(OutputImageDimension, unsigned int,
00077                       TInputImage::ImageDimension);
00078   itkStaticConstMacro(ImageDimension, unsigned int,
00079                       TInputImage::ImageDimension);
00081 
00082   typedef StatisticsLabelObject< InputImagePixelType, itkGetStaticConstMacro(ImageDimension) > LabelObjectType;
00083   typedef LabelMap< LabelObjectType >                                                          LabelMapType;
00084   typedef LabelImageToLabelMapFilter< InputImageType, LabelMapType >                           LabelizerType;
00085   typedef StatisticsLabelMapFilter< LabelMapType, TFeatureImage >                              LabelObjectValuatorType;
00086   typedef typename LabelObjectType::AttributeType                                              AttributeType;
00087   typedef StatisticsOpeningLabelMapFilter< LabelMapType >                                      OpeningType;
00088   typedef LabelMapToLabelImageFilter< LabelMapType, OutputImageType >                          BinarizerType;
00089 
00091   itkNewMacro(Self);
00092 
00094   itkTypeMacro(LabelStatisticsOpeningImageFilter,
00095                ImageToImageFilter);
00096 
00097 #ifdef ITK_USE_CONCEPT_CHECKING
00098 
00099   itkConceptMacro( InputEqualityComparableCheck,
00100                    ( Concept::EqualityComparable< InputImagePixelType > ) );
00101   itkConceptMacro( IntConvertibleToInputCheck,
00102                    ( Concept::Convertible< int, InputImagePixelType > ) );
00103   itkConceptMacro( InputOStreamWritableCheck,
00104                    ( Concept::OStreamWritable< InputImagePixelType > ) );
00105 
00107 #endif
00108 
00113   itkSetMacro(BackgroundValue, OutputImagePixelType);
00114   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00116 
00120   itkGetConstMacro(Lambda, double);
00121   itkSetMacro(Lambda, double);
00123 
00130   itkGetConstMacro(ReverseOrdering, bool);
00131   itkSetMacro(ReverseOrdering, bool);
00132   itkBooleanMacro(ReverseOrdering);
00134 
00139   itkGetConstMacro(Attribute, AttributeType);
00140   itkSetMacro(Attribute, AttributeType);
00141   void SetAttribute(const std::string & s)
00142   {
00143     this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
00144   }
00146 
00148   void SetFeatureImage(const TFeatureImage *input)
00149   {
00150     // Process object is not const-correct so the const casting is required.
00151     this->SetNthInput( 1, const_cast< TFeatureImage * >( input ) );
00152   }
00153 
00155   const FeatureImageType * GetFeatureImage()
00156   {
00157     return static_cast< const FeatureImageType * >( this->ProcessObject::GetInput(1) );
00158   }
00159 
00161   void SetInput1(const InputImageType *input)
00162   {
00163     this->SetInput(input);
00164   }
00165 
00167   void SetInput2(const FeatureImageType *input)
00168   {
00169     this->SetFeatureImage(input);
00170   }
00171 
00172 protected:
00173   LabelStatisticsOpeningImageFilter();
00174   ~LabelStatisticsOpeningImageFilter() {}
00175   void PrintSelf(std::ostream & os, Indent indent) const;
00176 
00180   void GenerateInputRequestedRegion();
00181 
00183   void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
00184 
00187   void GenerateData();
00188 
00189 private:
00190   LabelStatisticsOpeningImageFilter(const Self &); //purposely not implemented
00191   void operator=(const Self &);                    //purposely not implemented
00192 
00193   OutputImagePixelType m_BackgroundValue;
00194   double               m_Lambda;
00195   bool                 m_ReverseOrdering;
00196   AttributeType        m_Attribute;
00197 }; // end of class
00198 } // end namespace itk
00199 
00200 #ifndef ITK_MANUAL_INSTANTIATION
00201 #include "itkLabelStatisticsOpeningImageFilter.hxx"
00202 #endif
00203 
00204 #endif
00205