Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkLabelStatisticsKeepNObjectsImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkLabelStatisticsKeepNObjectsImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-08-11 14:24:43 $
00007   Version:   $Revision: 1.4 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkLabelStatisticsKeepNObjectsImageFilter_h
00018 #define __itkLabelStatisticsKeepNObjectsImageFilter_h
00019 
00020 #include "itkImageToImageFilter.h"
00021 #include "itkStatisticsLabelObject.h"
00022 #include "itkLabelMap.h"
00023 #include "itkLabelImageToLabelMapFilter.h"
00024 #include "itkStatisticsLabelMapFilter.h"
00025 #include "itkStatisticsKeepNObjectsLabelMapFilter.h"
00026 #include "itkLabelMapToLabelImageFilter.h"
00027 
00028 
00029 namespace itk {
00030 
00047 template<class TInputImage, class TFeatureImage>
00048 class ITK_EXPORT LabelStatisticsKeepNObjectsImageFilter : 
00049     public ImageToImageFilter<TInputImage, TInputImage>
00050 {
00051 public:
00053   typedef LabelStatisticsKeepNObjectsImageFilter       Self;
00054   typedef ImageToImageFilter<TInputImage, TInputImage> Superclass;
00055   typedef SmartPointer<Self>                           Pointer;
00056   typedef SmartPointer<const Self>                     ConstPointer;
00057 
00059   typedef TInputImage                              InputImageType;
00060   typedef TInputImage                              OutputImageType;
00061   typedef typename InputImageType::Pointer         InputImagePointer;
00062   typedef typename InputImageType::ConstPointer    InputImageConstPointer;
00063   typedef typename InputImageType::RegionType      InputImageRegionType;
00064   typedef typename InputImageType::PixelType       InputImagePixelType;
00065   typedef typename OutputImageType::Pointer        OutputImagePointer;
00066   typedef typename OutputImageType::ConstPointer   OutputImageConstPointer;
00067   typedef typename OutputImageType::RegionType     OutputImageRegionType;
00068   typedef typename OutputImageType::PixelType      OutputImagePixelType;
00069 
00070   typedef TFeatureImage                              FeatureImageType;
00071   typedef typename FeatureImageType::Pointer         FeatureImagePointer;
00072   typedef typename FeatureImageType::ConstPointer    FeatureImageConstPointer;
00073   typedef typename FeatureImageType::PixelType       FeatureImagePixelType;
00074 
00076   itkStaticConstMacro(InputImageDimension, unsigned int,
00077                       TInputImage::ImageDimension);
00078   itkStaticConstMacro(OutputImageDimension, unsigned int,
00079                       TInputImage::ImageDimension);
00080   itkStaticConstMacro(ImageDimension, unsigned int,
00081                       TInputImage::ImageDimension);
00083 
00084   typedef StatisticsLabelObject<InputImagePixelType, itkGetStaticConstMacro(ImageDimension)>                LabelObjectType;
00085   typedef LabelMap< LabelObjectType >                                               LabelMapType;
00086   typedef LabelImageToLabelMapFilter< InputImageType, LabelMapType >                LabelizerType;
00087   typedef StatisticsLabelMapFilter< LabelMapType, TFeatureImage >                   LabelObjectValuatorType;
00088   typedef typename LabelObjectType::AttributeType                                   AttributeType;
00089   typedef StatisticsKeepNObjectsLabelMapFilter< LabelMapType >                      KeepNObjectsType;
00090   typedef LabelMapToLabelImageFilter< LabelMapType, OutputImageType >               BinarizerType;
00091 
00093   itkNewMacro(Self);  
00094 
00096   itkTypeMacro(LabelStatisticsKeepNObjectsImageFilter, 
00097                ImageToImageFilter);
00098 
00099 #ifdef ITK_USE_CONCEPT_CHECKING
00100 
00101   itkConceptMacro(InputEqualityComparableCheck,
00102     (Concept::EqualityComparable<InputImagePixelType>));
00103   itkConceptMacro(IntConvertibleToInputCheck,
00104     (Concept::Convertible<int, InputImagePixelType>));
00105   itkConceptMacro(InputOStreamWritableCheck,
00106     (Concept::OStreamWritable<InputImagePixelType>));
00107 
00109 #endif
00110 
00115   itkSetMacro(BackgroundValue, OutputImagePixelType);
00116   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00118 
00122   itkGetConstMacro(NumberOfObjects, unsigned long);
00123   itkSetMacro(NumberOfObjects, unsigned long);
00125 
00131   itkGetConstMacro( ReverseOrdering, bool );
00132   itkSetMacro( ReverseOrdering, bool );
00133   itkBooleanMacro( ReverseOrdering );
00135 
00140   itkGetConstMacro( Attribute, AttributeType );
00141   itkSetMacro( Attribute, AttributeType );
00142   void SetAttribute( const std::string & s )
00143     {
00144     this->SetAttribute( LabelObjectType::GetAttributeFromName( s ) );
00145     }
00147 
00149   void SetFeatureImage(const TFeatureImage *input)
00150     {
00151     // Process object is not const-correct so the const casting is required.
00152     this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
00153     }
00154 
00156   const FeatureImageType * GetFeatureImage()
00157     {
00158     return static_cast<const FeatureImageType*>(this->ProcessObject::GetInput(1));
00159     }
00160 
00162   void SetInput1(const InputImageType *input)
00163     {
00164     this->SetInput( input );
00165     }
00166 
00168   void SetInput2(const FeatureImageType *input)
00169     {
00170     this->SetFeatureImage( input );
00171     }
00172 
00173 
00174 protected:
00175   LabelStatisticsKeepNObjectsImageFilter();
00176   ~LabelStatisticsKeepNObjectsImageFilter() {};
00177   void PrintSelf(std::ostream& os, Indent indent) const;
00178 
00182   void GenerateInputRequestedRegion();
00183 
00185   void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00186 
00189   void GenerateData();
00190 
00191 private:
00192   LabelStatisticsKeepNObjectsImageFilter(const Self&); //purposely not implemented
00193   void operator=(const Self&); //purposely not implemented
00194 
00195   OutputImagePixelType m_BackgroundValue;
00196   unsigned long        m_NumberOfObjects;
00197   bool                 m_ReverseOrdering;
00198   AttributeType        m_Attribute;
00199 }; // end of class
00200 
00201 } // end namespace itk
00202   
00203 #ifndef ITK_MANUAL_INSTANTIATION
00204 #include "itkLabelStatisticsKeepNObjectsImageFilter.txx"
00205 #endif
00206 
00207 #endif
00208 

Generated at Tue Sep 15 03:48:39 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000