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

itkBinaryShapeKeepNObjectsImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBinaryShapeKeepNObjectsImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-08-08 01:21:22 $
00007   Version:   $Revision: 1.3 $
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 __itkBinaryShapeKeepNObjectsImageFilter_h
00018 #define __itkBinaryShapeKeepNObjectsImageFilter_h
00019 
00020 #include "itkImageToImageFilter.h"
00021 #include "itkShapeLabelObject.h"
00022 #include "itkLabelMap.h"
00023 #include "itkBinaryImageToLabelMapFilter.h"
00024 #include "itkShapeLabelMapFilter.h"
00025 #include "itkShapeKeepNObjectsLabelMapFilter.h"
00026 #include "itkLabelMapToBinaryImageFilter.h"
00027 
00028 
00029 namespace itk {
00030 
00047 template<class TInputImage>
00048 class ITK_EXPORT BinaryShapeKeepNObjectsImageFilter : 
00049     public ImageToImageFilter<TInputImage, TInputImage>
00050 {
00051 public:
00053   typedef BinaryShapeKeepNObjectsImageFilter           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 
00071   itkStaticConstMacro(InputImageDimension, unsigned int,
00072                       TInputImage::ImageDimension);
00073   itkStaticConstMacro(OutputImageDimension, unsigned int,
00074                       TInputImage::ImageDimension);
00075   itkStaticConstMacro(ImageDimension, unsigned int,
00076                       TInputImage::ImageDimension);
00078 
00079   typedef ShapeLabelObject<unsigned long, itkGetStaticConstMacro(ImageDimension)>                            LabelObjectType;
00080   typedef LabelMap< LabelObjectType >                                                                        LabelMapType;
00081   typedef BinaryImageToLabelMapFilter< InputImageType, LabelMapType >                                        LabelizerType;
00082   typedef Image< typename OutputImageType::PixelType, itkGetStaticConstMacro(OutputImageDimension)>
00083                               ShapeLabelFilterOutput;
00084   typedef ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput >                                        LabelObjectValuatorType;
00085   typedef typename LabelObjectType::AttributeType                                                            AttributeType;
00086   typedef ShapeKeepNObjectsLabelMapFilter< LabelMapType >                                                    KeepNObjectsType;
00087   typedef LabelMapToBinaryImageFilter< LabelMapType, OutputImageType >                                       BinarizerType;
00088 
00090   itkNewMacro(Self);  
00091 
00093   itkTypeMacro(BinaryShapeKeepNObjectsImageFilter, 
00094                ImageToImageFilter);
00095 
00102   itkSetMacro(FullyConnected, bool);
00103   itkGetConstReferenceMacro(FullyConnected, bool);
00104   itkBooleanMacro(FullyConnected);
00106 
00107 #ifdef ITK_USE_CONCEPT_CHECKING
00108 
00109   itkConceptMacro(InputEqualityComparableCheck,
00110     (Concept::EqualityComparable<InputImagePixelType>));
00111   itkConceptMacro(IntConvertibleToInputCheck,
00112     (Concept::Convertible<int, InputImagePixelType>));
00113   itkConceptMacro(InputOStreamWritableCheck,
00114     (Concept::OStreamWritable<InputImagePixelType>));
00115 
00117 #endif
00118 
00123   itkSetMacro(BackgroundValue, OutputImagePixelType);
00124   itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00126 
00131   itkSetMacro(ForegroundValue, OutputImagePixelType);
00132   itkGetConstMacro(ForegroundValue, OutputImagePixelType);
00134 
00138   itkGetConstMacro(NumberOfObjects, unsigned long);
00139   itkSetMacro(NumberOfObjects, unsigned long);
00141 
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 
00164 protected:
00165   BinaryShapeKeepNObjectsImageFilter();
00166   ~BinaryShapeKeepNObjectsImageFilter() {};
00167   void PrintSelf(std::ostream& os, Indent indent) const;
00168 
00172   void GenerateInputRequestedRegion();
00173 
00175   void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00176 
00179   void GenerateData();
00180 
00181 private:
00182   BinaryShapeKeepNObjectsImageFilter(const Self&); //purposely not implemented
00183   void operator=(const Self&); //purposely not implemented
00184 
00185   bool                 m_FullyConnected;
00186   OutputImagePixelType m_BackgroundValue;
00187   OutputImagePixelType m_ForegroundValue;
00188   unsigned long        m_NumberOfObjects;
00189   bool                 m_ReverseOrdering;
00190   AttributeType        m_Attribute;
00191 }; // end of class
00192 
00193 } // end namespace itk
00194   
00195 #ifndef ITK_MANUAL_INSTANTIATION
00196 #include "itkBinaryShapeKeepNObjectsImageFilter.txx"
00197 #endif
00198 
00199 #endif
00200 

Generated at Mon Jul 12 2010 17:51:24 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000