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 __itkBinaryMorphologyImageFilter_h
00018 #define __itkBinaryMorphologyImageFilter_h
00019
00020
00021
00022
00023
00024 #include "itkConfigure.h"
00025
00026 #ifdef ITK_USE_CONSOLIDATED_MORPHOLOGY
00027 #include "itkOptBinaryMorphologyImageFilter.h"
00028 #else
00029
00030 #include <vector>
00031 #include <queue>
00032 #include "itkImageToImageFilter.h"
00033 #include "itkImage.h"
00034 #include "itkNumericTraits.h"
00035 #include "itkNeighborhoodIterator.h"
00036 #include "itkConstNeighborhoodIterator.h"
00037 #include "itkNeighborhood.h"
00038 #include "itkImageBoundaryCondition.h"
00039 #include "itkImageRegionIterator.h"
00040 #include "itkConceptChecking.h"
00041
00042 namespace itk
00043 {
00114 template <class TInputImage, class TOutputImage, class TKernel>
00115 class ITK_EXPORT BinaryMorphologyImageFilter :
00116 public ImageToImageFilter< TInputImage, TOutputImage >
00117 {
00118 public:
00119
00121 itkStaticConstMacro(InputImageDimension, unsigned int,
00122 TInputImage::ImageDimension);
00123 itkStaticConstMacro(OutputImageDimension, unsigned int,
00124 TOutputImage::ImageDimension);
00126
00128 itkStaticConstMacro(KernelDimension, unsigned int,
00129 TKernel::NeighborhoodDimension);
00130
00132 typedef TInputImage InputImageType;
00133 typedef TOutputImage OutputImageType;
00134
00136 typedef BinaryMorphologyImageFilter Self;
00137 typedef ImageToImageFilter< InputImageType, OutputImageType> Superclass;
00138 typedef SmartPointer<Self> Pointer;
00139 typedef SmartPointer<const Self> ConstPointer;
00140
00142 itkNewMacro(Self);
00143
00145 itkTypeMacro(BinaryMorphologyImageFilter, ImageToImageFilter);
00146
00148 typedef TKernel KernelType;
00149
00151 typedef typename KernelType::ConstIterator KernelIteratorType;
00152
00154 typedef typename InputImageType::PixelType InputPixelType;
00155 typedef typename OutputImageType::PixelType OutputPixelType;
00156 typedef typename NumericTraits<InputPixelType>::RealType InputRealType;
00157 typedef typename InputImageType::OffsetType OffsetType;
00158 typedef typename InputImageType::IndexType IndexType;
00159
00160 typedef typename InputImageType::RegionType InputImageRegionType;
00161 typedef typename OutputImageType::RegionType OutputImageRegionType;
00162 typedef typename InputImageType::SizeType InputSizeType;
00163
00165 itkConceptMacro(ImageDimensionCheck,
00166 (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),
00167 itkGetStaticConstMacro(OutputImageDimension)>));
00168
00170 void SetKernel( const KernelType& kernel );
00171
00173 itkGetConstReferenceMacro(Kernel, KernelType);
00174
00178 itkSetMacro(ForegroundValue, InputPixelType);
00179
00182 itkGetConstMacro(ForegroundValue, InputPixelType);
00183
00188 itkSetMacro(BackgroundValue, OutputPixelType);
00189
00194 itkGetConstMacro(BackgroundValue, OutputPixelType);
00195
00197 itkSetMacro(BoundaryToForeground, bool);
00198 itkGetConstReferenceMacro(BoundaryToForeground, bool);
00199 itkBooleanMacro(BoundaryToForeground);
00201
00202 protected:
00203 BinaryMorphologyImageFilter();
00204 virtual ~BinaryMorphologyImageFilter(){}
00205 void PrintSelf(std::ostream& os, Indent indent) const;
00206
00210 void AnalyzeKernel();
00211
00220 void GenerateInputRequestedRegion() throw (InvalidRequestedRegionError);
00221
00222
00223 typedef std::vector< OffsetType > NeighborIndexContainer;
00224
00225
00226 typedef std::vector<NeighborIndexContainer> NeighborIndexContainerContainer;
00227
00228
00229 typedef std::vector< OffsetType > ComponentVectorType;
00230
00231
00232 typedef typename ComponentVectorType::const_iterator
00233 ComponentVectorConstIterator;
00234
00238 NeighborIndexContainer& GetDifferenceSet(unsigned int code)
00239 { return m_KernelDifferenceSets[code]; }
00240
00244 ComponentVectorConstIterator KernelCCVectorBegin()
00245 { return m_KernelCCVector.begin(); }
00246
00250 ComponentVectorConstIterator KernelCCVectorEnd()
00251 { return m_KernelCCVector.end(); }
00252
00256 InputSizeType GetRadius() const
00257 { return m_Radius; }
00258
00259 bool m_BoundaryToForeground;
00260
00261 private:
00262 BinaryMorphologyImageFilter(const Self&);
00263 void operator=(const Self&);
00264
00267 InputSizeType m_Radius;
00268
00270 KernelType m_Kernel;
00271
00273 InputPixelType m_ForegroundValue;
00274
00276 OutputPixelType m_BackgroundValue;
00277
00278
00279 NeighborIndexContainerContainer m_KernelDifferenceSets;
00280
00281
00282
00283
00284 std::vector< OffsetType > m_KernelCCVector;
00285 };
00286
00287 }
00288
00289 #ifndef ITK_MANUAL_INSTANTIATION
00290 #include "itkBinaryMorphologyImageFilter.txx"
00291 #endif
00292
00293 #endif
00294
00295 #endif
00296