ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkBinaryStatisticsOpeningImageFilter.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 __itkBinaryStatisticsOpeningImageFilter_h
00019 #define __itkBinaryStatisticsOpeningImageFilter_h
00020 
00021 #include "itkBinaryImageToLabelMapFilter.h"
00022 #include "itkStatisticsLabelMapFilter.h"
00023 #include "itkStatisticsOpeningLabelMapFilter.h"
00024 #include "itkLabelMapToBinaryImageFilter.h"
00025 
00026 namespace itk
00027 {
00045 template< class TInputImage, class TFeatureImage >
00046 class ITK_EXPORT BinaryStatisticsOpeningImageFilter:
00047   public ImageToImageFilter< TInputImage, TInputImage >
00048 {
00049 public:
00051   typedef BinaryStatisticsOpeningImageFilter             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, TInputImage::ImageDimension);
00075   itkStaticConstMacro(OutputImageDimension, unsigned int, TInputImage::ImageDimension);
00076   itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
00078 
00079   typedef SizeValueType LabelType;
00080 
00081   typedef StatisticsLabelObject< LabelType, itkGetStaticConstMacro(ImageDimension) >     LabelObjectType;
00082   typedef LabelMap< LabelObjectType >                                                    LabelMapType;
00083   typedef BinaryImageToLabelMapFilter< InputImageType, LabelMapType >                    LabelizerType;
00084   typedef StatisticsLabelMapFilter< LabelMapType, FeatureImageType >                     LabelObjectValuatorType;
00085   typedef typename LabelObjectType::AttributeType                                        AttributeType;
00086   typedef StatisticsOpeningLabelMapFilter< LabelMapType >                                OpeningType;
00087   typedef LabelMapToBinaryImageFilter< LabelMapType, OutputImageType >                   BinarizerType;
00088 
00090   itkNewMacro(Self);
00091 
00093   itkTypeMacro(BinaryStatisticsOpeningImageFilter, ImageToImageFilter);
00094 
00101   itkSetMacro(FullyConnected, bool);
00102   itkGetConstReferenceMacro(FullyConnected, bool);
00103   itkBooleanMacro(FullyConnected);
00105 
00106 #ifdef ITK_USE_CONCEPT_CHECKING
00107 
00108   itkConceptMacro( InputEqualityComparableCheck,
00109                    ( Concept::EqualityComparable< InputImagePixelType > ) );
00110   itkConceptMacro( IntConvertibleToInputCheck,
00111                    ( Concept::Convertible< int, InputImagePixelType > ) );
00112   itkConceptMacro( InputOStreamWritableCheck,
00113                    ( Concept::OStreamWritable< InputImagePixelType > ) );
00114 
00116 #endif
00117 
00122   itkSetMacro(BackgroundValue, OutputImagePixelType);
00123   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00125 
00130   itkSetMacro(ForegroundValue, OutputImagePixelType);
00131   itkGetConstMacro(ForegroundValue, OutputImagePixelType);
00133 
00137   itkGetConstMacro(Lambda, double);
00138   itkSetMacro(Lambda, double);
00140 
00147   itkGetConstMacro(ReverseOrdering, bool);
00148   itkSetMacro(ReverseOrdering, bool);
00149   itkBooleanMacro(ReverseOrdering);
00151 
00156   itkGetConstMacro(Attribute, AttributeType);
00157   itkSetMacro(Attribute, AttributeType);
00158   void SetAttribute(const std::string & s)
00159   {
00160     this->SetAttribute( LabelObjectType::GetAttributeFromName(s) );
00161   }
00163 
00165   void SetFeatureImage(const TFeatureImage *input)
00166   {
00167     // Process object is not const-correct so the const casting is required.
00168     this->SetNthInput( 1, const_cast< TFeatureImage * >( input ) );
00169   }
00170 
00172   const FeatureImageType * GetFeatureImage()
00173   {
00174     return static_cast< const FeatureImageType * >( this->ProcessObject::GetInput(1) );
00175   }
00176 
00178   void SetInput1(const InputImageType *input)
00179   {
00180     this->SetInput(input);
00181   }
00182 
00184   void SetInput2(const FeatureImageType *input)
00185   {
00186     this->SetFeatureImage(input);
00187   }
00188 
00189 protected:
00190   BinaryStatisticsOpeningImageFilter();
00191   ~BinaryStatisticsOpeningImageFilter() {}
00192   void PrintSelf(std::ostream & os, Indent indent) const;
00193 
00196   void GenerateInputRequestedRegion();
00197 
00199   void EnlargeOutputRequestedRegion( DataObject *itkNotUsed(output) );
00200 
00203   void GenerateData();
00204 
00205 private:
00206   BinaryStatisticsOpeningImageFilter(const Self &); //purposely not implemented
00207   void operator=(const Self &);                     //purposely not implemented
00208 
00209   bool                 m_FullyConnected;
00210   OutputImagePixelType m_BackgroundValue;
00211   OutputImagePixelType m_ForegroundValue;
00212   double               m_Lambda;
00213   bool                 m_ReverseOrdering;
00214   AttributeType        m_Attribute;
00215 }; // end of class
00216 } // end namespace itk
00217 
00218 #ifndef ITK_MANUAL_INSTANTIATION
00219 #include "itkBinaryStatisticsOpeningImageFilter.hxx"
00220 #endif
00221 
00222 #endif
00223