itkLabelShapeKeepNObjectsImageFilter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkLabelShapeKeepNObjectsImageFilter_h
00018 #define __itkLabelShapeKeepNObjectsImageFilter_h
00019
00020 #include "itkImageToImageFilter.h"
00021 #include "itkShapeLabelObject.h"
00022 #include "itkLabelMap.h"
00023 #include "itkLabelImageToLabelMapFilter.h"
00024 #include "itkShapeLabelMapFilter.h"
00025 #include "itkShapeKeepNObjectsLabelMapFilter.h"
00026 #include "itkLabelMapToLabelImageFilter.h"
00027
00028
00029 namespace itk {
00030
00047 template<class TInputImage>
00048 class ITK_EXPORT LabelShapeKeepNObjectsImageFilter :
00049 public ImageToImageFilter<TInputImage, TInputImage>
00050 {
00051 public:
00053 typedef LabelShapeKeepNObjectsImageFilter 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<InputImagePixelType, itkGetStaticConstMacro(ImageDimension)> LabelObjectType;
00080 typedef LabelMap< LabelObjectType > LabelMapType;
00081 typedef LabelImageToLabelMapFilter< InputImageType, LabelMapType > LabelizerType;
00082 typedef Image< typename OutputImageType::PixelType, itkGetStaticConstMacro(OutputImageDimension)> ShapeLabelFilterOutput;
00083 typedef ShapeLabelMapFilter< LabelMapType, ShapeLabelFilterOutput > LabelObjectValuatorType;
00084 typedef typename LabelObjectType::AttributeType AttributeType;
00085 typedef ShapeKeepNObjectsLabelMapFilter< LabelMapType > KeepNObjectsType;
00086 typedef LabelMapToLabelImageFilter< LabelMapType, OutputImageType > BinarizerType;
00087
00089 itkNewMacro(Self);
00090
00092 itkTypeMacro(LabelShapeKeepNObjectsImageFilter,
00093 ImageToImageFilter);
00094
00095 #ifdef ITK_USE_CONCEPT_CHECKING
00096
00097 itkConceptMacro(InputEqualityComparableCheck,
00098 (Concept::EqualityComparable<InputImagePixelType>));
00099 itkConceptMacro(IntConvertibleToInputCheck,
00100 (Concept::Convertible<int, InputImagePixelType>));
00101 itkConceptMacro(InputOStreamWritableCheck,
00102 (Concept::OStreamWritable<InputImagePixelType>));
00103
00105 #endif
00106
00111 itkSetMacro(BackgroundValue, OutputImagePixelType);
00112 itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00114
00118 itkGetConstMacro(NumberOfObjects, unsigned long);
00119 itkSetMacro(NumberOfObjects, unsigned long);
00121
00127 itkGetConstMacro( ReverseOrdering, bool );
00128 itkSetMacro( ReverseOrdering, bool );
00129 itkBooleanMacro( ReverseOrdering );
00131
00136 itkGetConstMacro( Attribute, AttributeType );
00137 itkSetMacro( Attribute, AttributeType );
00138 void SetAttribute( const std::string & s )
00139 {
00140 this->SetAttribute( LabelObjectType::GetAttributeFromName( s ) );
00141 }
00143
00144
00145 protected:
00146 LabelShapeKeepNObjectsImageFilter();
00147 ~LabelShapeKeepNObjectsImageFilter() {};
00148 void PrintSelf(std::ostream& os, Indent indent) const;
00149
00153 void GenerateInputRequestedRegion();
00154
00156 void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00157
00160 void GenerateData();
00161
00162 private:
00163 LabelShapeKeepNObjectsImageFilter(const Self&);
00164 void operator=(const Self&);
00165
00166 OutputImagePixelType m_BackgroundValue;
00167 unsigned long m_NumberOfObjects;
00168 bool m_ReverseOrdering;
00169 AttributeType m_Attribute;
00170 };
00171
00172 }
00173
00174 #ifndef ITK_MANUAL_INSTANTIATION
00175 #include "itkLabelShapeKeepNObjectsImageFilter.txx"
00176 #endif
00177
00178 #endif
00179