00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkKLMRegionGrowImageFilter_h
00018 #define _itkKLMRegionGrowImageFilter_h
00019
00020 #include "itkImage.h"
00021 #include "itkObject.h"
00022 #include "itkImageToImageFilter.h"
00023 #include "itkRegionGrowImageFilter.h"
00024 #include "itkKLMSegmentationRegion.h"
00025 #include "itkKLMSegmentationBorder.h"
00026 #include "itkImageRegionIterator.h"
00027 #include "itkImageRegionConstIterator.h"
00028 #include "itkConceptChecking.h"
00029 #include <algorithm>
00030 #include <functional>
00031
00032 namespace itk
00033 {
00034
00167 template <class TInputImage, class TOutputImage>
00168 class ITK_EXPORT KLMRegionGrowImageFilter : public RegionGrowImageFilter<TInputImage,TOutputImage>
00169 {
00170 public:
00172 typedef KLMRegionGrowImageFilter Self;
00173 typedef RegionGrowImageFilter< TInputImage, TOutputImage > Superclass;
00174 typedef SmartPointer< Self > Pointer;
00175 typedef SmartPointer< const Self > ConstPointer;
00176
00178 itkNewMacro(Self);
00179
00181 itkTypeMacro(KLMRegionGrowImageFilter, RegionGrowImageFilter);
00182
00184 typedef TInputImage InputImageType;
00185 typedef typename TInputImage::Pointer InputImagePointer;
00186 typedef typename TInputImage::ConstPointer InputImageConstPointer;
00187
00189 typedef typename TInputImage::PixelType InputImagePixelType;
00190
00192 typedef typename TInputImage::PixelType::VectorType InputImageVectorType;
00193
00195 itkStaticConstMacro(InputImageVectorDimension, unsigned int,
00196 InputImagePixelType::Dimension);
00197
00199 typedef typename TInputImage::IndexType InputImageIndexType;
00200
00202 typedef ImageRegionIterator< TInputImage > InputImageIterator;
00203 typedef ImageRegionConstIterator< TInputImage > InputImageConstIterator;
00204
00206 typedef typename TInputImage::RegionType InputRegionType;
00207
00210 typedef typename Superclass::GridSizeType GridSizeType;
00211
00213 typedef TOutputImage OutputImageType;
00214 typedef typename TOutputImage::Pointer OutputImagePointer;
00215
00217 itkStaticConstMacro(InputImageDimension, unsigned int,
00218 TInputImage::ImageDimension);
00219
00221 itkStaticConstMacro(OutputImageDimension, unsigned int,
00222 TOutputImage::ImageDimension);
00223
00225 typedef typename TOutputImage::PixelType OutputImagePixelType;
00226
00228 typedef typename TOutputImage::PixelType::VectorType OutputImageVectorType;
00229
00231 itkStaticConstMacro(OutputImageVectorDimension, unsigned int,
00232 OutputImagePixelType::Dimension);
00233
00235 typedef typename TOutputImage::IndexType OutputImageIndexType;
00236
00238 typedef ImageRegionIterator< TOutputImage > OutputImageIterator;
00239
00242 itkConceptMacro(SameDimension,
00243 (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),itkGetStaticConstMacro(OutputImageDimension)>));
00244
00245 #if THIS_CONCEPT_FAILS_ON_GCC
00246
00248 itkConceptMacro(SameVectorDimension,
00249 (Concept::SameDimension<itkGetStaticConstMacro(InputImageVectorDimension),itkGetStaticConstMacro(OutputImageVectorDimension)>));
00250 #endif
00251
00253 typedef typename KLMSegmentationRegion::RegionLabelType RegionLabelType;
00254
00256 itkStaticConstMacro(LabelImageDimension, RegionLabelType,
00257 InputImageDimension);
00258
00260 typedef Image< RegionLabelType, itkGetStaticConstMacro(LabelImageDimension) > LabelImageType;
00261
00263 typedef typename LabelImageType::Pointer LabelImagePointer;
00264
00266 typedef typename LabelImageType::PixelType LabelImagePixelType;
00267
00269 typedef typename LabelImageType::IndexType LabelImageIndexType;
00270
00272 typedef ImageRegionIterator< LabelImageType > LabelImageIterator;
00273
00275 typedef vnl_vector< double > MeanRegionIntensityType;
00276
00278 typedef KLMSegmentationBorder BorderType;
00279
00281 typedef KLMDynamicBorderArray< BorderType > KLMSegmentationBorderArrayPtr;
00282
00286 itkSetMacro(MaximumLambda, double);
00287 itkGetConstReferenceMacro(MaximumLambda, double);
00288
00290 itkSetMacro(NumberOfRegions, unsigned int);
00291 itkGetConstReferenceMacro(NumberOfRegions, unsigned int);
00292
00294 LabelImagePointer GetLabelledImage(void);
00295
00297 void PrintAlgorithmRegionStats(void);
00298
00300 void PrintAlgorithmBorderStats(void);
00301
00302 protected:
00303 KLMRegionGrowImageFilter();
00304 ~KLMRegionGrowImageFilter();
00305 void PrintSelf(std::ostream& os, Indent indent) const;
00306
00310 virtual void GenerateData();
00311
00315 virtual void GenerateInputRequestedRegion();
00316
00321 virtual void EnlargeOutputRequestedRegion( DataObject * );
00322
00325 void ApplyRegionGrowImageFilter();
00326
00330 virtual void MergeRegions();
00331
00333 virtual void GenerateOutputImage();
00334
00336 void ApplyKLM();
00337
00339 void InitializeKLM();
00340
00342 LabelImagePointer GenerateLabelledImage( LabelImageType *labelImagePtr );
00343
00349 virtual void InitializeRegionParameters( InputRegionType region );
00350
00354 virtual void ResolveRegions();
00355
00356 private:
00357 KLMRegionGrowImageFilter(const Self&);
00358 void operator=(const Self&);
00359
00360 typedef typename TInputImage::SizeType InputImageSizeType;
00361 typedef typename KLMSegmentationRegion::Pointer KLMSegmentationRegionPtr;
00362 typedef typename KLMSegmentationBorder::Pointer KLMSegmentationBorderPtr;
00363
00364 double m_MaximumLambda;
00365 unsigned int m_NumberOfRegions;
00366
00369 double m_InternalLambda;
00370 unsigned int m_InitialNumberOfRegions;
00371 double m_TotalBorderLength;
00372
00373 std::vector< KLMSegmentationRegionPtr > m_RegionsPointer;
00374 std::vector< KLMSegmentationBorderPtr > m_BordersPointer;
00375 std::vector< KLMSegmentationBorderArrayPtr > m_BordersDynamicPointer;
00376 KLMSegmentationBorderArrayPtr *m_BorderCandidate;
00377
00378 MeanRegionIntensityType m_InitialRegionMean;
00379 double m_InitialRegionArea;
00380
00381 };
00382
00383 }
00384
00385 #ifndef ITK_MANUAL_INSTANTIATION
00386 #include "itkKLMRegionGrowImageFilter.txx"
00387 #endif
00388
00389
00390 #endif