itkBinaryStatisticsKeepNObjectsImageFilter.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 __itkBinaryStatisticsKeepNObjectsImageFilter_h
00018 #define __itkBinaryStatisticsKeepNObjectsImageFilter_h
00019
00020 #include "itkImageToImageFilter.h"
00021 #include "itkStatisticsLabelObject.h"
00022 #include "itkLabelMap.h"
00023 #include "itkBinaryImageToLabelMapFilter.h"
00024 #include "itkStatisticsLabelMapFilter.h"
00025 #include "itkStatisticsKeepNObjectsLabelMapFilter.h"
00026 #include "itkLabelMapToBinaryImageFilter.h"
00027
00028
00029 namespace itk {
00030
00047 template<class TInputImage, class TFeatureImage>
00048 class ITK_EXPORT BinaryStatisticsKeepNObjectsImageFilter :
00049 public ImageToImageFilter<TInputImage, TInputImage>
00050 {
00051 public:
00053 typedef BinaryStatisticsKeepNObjectsImageFilter 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<unsigned long, itkGetStaticConstMacro(ImageDimension)> LabelObjectType;
00085 typedef LabelMap< LabelObjectType > LabelMapType;
00086 typedef BinaryImageToLabelMapFilter< InputImageType, LabelMapType > LabelizerType;
00087 typedef StatisticsLabelMapFilter< LabelMapType, TFeatureImage > LabelObjectValuatorType;
00088 typedef typename LabelObjectType::AttributeType AttributeType;
00089 typedef StatisticsKeepNObjectsLabelMapFilter< LabelMapType > KeepNObjectsType;
00090 typedef LabelMapToBinaryImageFilter< LabelMapType, OutputImageType > BinarizerType;
00091
00093 itkNewMacro(Self);
00094
00096 itkTypeMacro(BinaryStatisticsKeepNObjectsImageFilter,
00097 ImageToImageFilter);
00098
00105 itkSetMacro(FullyConnected, bool);
00106 itkGetConstReferenceMacro(FullyConnected, bool);
00107 itkBooleanMacro(FullyConnected);
00109
00110 #ifdef ITK_USE_CONCEPT_CHECKING
00111
00112 itkConceptMacro(InputEqualityComparableCheck,
00113 (Concept::EqualityComparable<InputImagePixelType>));
00114 itkConceptMacro(IntConvertibleToInputCheck,
00115 (Concept::Convertible<int, InputImagePixelType>));
00116 itkConceptMacro(InputOStreamWritableCheck,
00117 (Concept::OStreamWritable<InputImagePixelType>));
00118
00120 #endif
00121
00126 itkSetMacro(BackgroundValue, OutputImagePixelType);
00127 itkGetConstMacro(BackgroundValue, OutputImagePixelType);
00129
00134 itkSetMacro(ForegroundValue, OutputImagePixelType);
00135 itkGetConstMacro(ForegroundValue, OutputImagePixelType);
00137
00141 itkGetConstMacro(NumberOfObjects, unsigned long);
00142 itkSetMacro(NumberOfObjects, unsigned long);
00144
00150 itkGetConstMacro( ReverseOrdering, bool );
00151 itkSetMacro( ReverseOrdering, bool );
00152 itkBooleanMacro( ReverseOrdering );
00154
00159 itkGetConstMacro( Attribute, AttributeType );
00160 itkSetMacro( Attribute, AttributeType );
00161 void SetAttribute( const std::string & s )
00162 {
00163 this->SetAttribute( LabelObjectType::GetAttributeFromName( s ) );
00164 }
00166
00168 void SetFeatureImage(const TFeatureImage *input)
00169 {
00170
00171 this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
00172 }
00173
00175 const FeatureImageType * GetFeatureImage()
00176 {
00177 return static_cast<const FeatureImageType*>(this->ProcessObject::GetInput(1));
00178 }
00179
00181 void SetInput1(const InputImageType *input)
00182 {
00183 this->SetInput( input );
00184 }
00185
00187 void SetInput2(const FeatureImageType *input)
00188 {
00189 this->SetFeatureImage( input );
00190 }
00191
00192 protected:
00193 BinaryStatisticsKeepNObjectsImageFilter();
00194 ~BinaryStatisticsKeepNObjectsImageFilter() {};
00195 void PrintSelf(std::ostream& os, Indent indent) const;
00196
00200 void GenerateInputRequestedRegion();
00201
00203 void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
00204
00207 void GenerateData();
00208
00209 private:
00210 BinaryStatisticsKeepNObjectsImageFilter(const Self&);
00211 void operator=(const Self&);
00212
00213 bool m_FullyConnected;
00214 OutputImagePixelType m_BackgroundValue;
00215 OutputImagePixelType m_ForegroundValue;
00216 unsigned long m_NumberOfObjects;
00217 bool m_ReverseOrdering;
00218 AttributeType m_Attribute;
00219 };
00220
00221 }
00222
00223 #ifndef ITK_MANUAL_INSTANTIATION
00224 #include "itkBinaryStatisticsKeepNObjectsImageFilter.txx"
00225 #endif
00226
00227 #endif
00228