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
00241 typedef typename KLMSegmentationRegion::RegionLabelType RegionLabelType;
00242
00244 itkStaticConstMacro(LabelImageDimension, RegionLabelType,
00245 InputImageDimension);
00246
00248 typedef Image< RegionLabelType, itkGetStaticConstMacro(LabelImageDimension) > LabelImageType;
00249
00251 typedef typename LabelImageType::Pointer LabelImagePointer;
00252
00254 typedef typename LabelImageType::PixelType LabelImagePixelType;
00255
00257 typedef typename LabelImageType::IndexType LabelImageIndexType;
00258
00260 typedef ImageRegionIterator< LabelImageType > LabelImageIterator;
00261
00263 typedef vnl_vector< double > MeanRegionIntensityType;
00264
00266 typedef KLMSegmentationBorder BorderType;
00267
00269 typedef KLMDynamicBorderArray< BorderType > KLMSegmentationBorderArrayPtr;
00270
00274 itkSetMacro(MaximumLambda, double);
00275 itkGetConstReferenceMacro(MaximumLambda, double);
00277
00279 itkSetMacro(NumberOfRegions, unsigned int);
00280 itkGetConstReferenceMacro(NumberOfRegions, unsigned int);
00282
00284 LabelImagePointer GetLabelledImage(void);
00285
00287 void PrintAlgorithmRegionStats(void);
00288
00290 void PrintAlgorithmBorderStats(void);
00291
00292 #ifdef ITK_USE_CONCEPT_CHECKING
00293
00294 itkConceptMacro(InputHasNumericTraitsCheck,
00295 (Concept::HasNumericTraits<typename InputImagePixelType::ValueType>));
00296 itkConceptMacro(SameDimension,
00297 (Concept::SameDimension<itkGetStaticConstMacro(InputImageDimension),
00298 itkGetStaticConstMacro(OutputImageDimension)>));
00299 #if THIS_CONCEPT_FAILS_ON_GCC
00300
00302 itkConceptMacro(SameVectorDimension,
00303 (Concept::SameDimension<itkGetStaticConstMacro(InputImageVectorDimension),
00304 itkGetStaticConstMacro(OutputImageVectorDimension)>));
00305 #endif
00306
00308 #endif
00309
00310 protected:
00311 KLMRegionGrowImageFilter();
00312 ~KLMRegionGrowImageFilter();
00313 void PrintSelf(std::ostream& os, Indent indent) const;
00314
00318 virtual void GenerateData();
00319
00323 virtual void GenerateInputRequestedRegion();
00324
00329 virtual void EnlargeOutputRequestedRegion( DataObject * );
00330
00333 void ApplyRegionGrowImageFilter();
00334
00338 virtual void MergeRegions();
00339
00341 virtual void GenerateOutputImage();
00342
00344 void ApplyKLM();
00345
00347 void InitializeKLM();
00348
00350 LabelImagePointer GenerateLabelledImage( LabelImageType *labelImagePtr );
00351
00357 virtual void InitializeRegionParameters( InputRegionType region );
00358
00362 virtual void ResolveRegions();
00363
00364 private:
00365 KLMRegionGrowImageFilter(const Self&);
00366 void operator=(const Self&);
00367
00368 typedef typename TInputImage::SizeType InputImageSizeType;
00369 typedef typename KLMSegmentationRegion::Pointer KLMSegmentationRegionPtr;
00370 typedef typename KLMSegmentationBorder::Pointer KLMSegmentationBorderPtr;
00371
00372 double m_MaximumLambda;
00373 unsigned int m_NumberOfRegions;
00374
00377 double m_InternalLambda;
00378 unsigned int m_InitialNumberOfRegions;
00379 double m_TotalBorderLength;
00380
00381 std::vector< KLMSegmentationRegionPtr > m_RegionsPointer;
00382 std::vector< KLMSegmentationBorderPtr > m_BordersPointer;
00383 std::vector< KLMSegmentationBorderArrayPtr > m_BordersDynamicPointer;
00384 KLMSegmentationBorderArrayPtr *m_BorderCandidate;
00385
00386 MeanRegionIntensityType m_InitialRegionMean;
00387 double m_InitialRegionArea;
00388
00389 };
00390
00391 }
00392
00393 #ifndef ITK_MANUAL_INSTANTIATION
00394 #include "itkKLMRegionGrowImageFilter.txx"
00395 #endif
00396
00397
00398 #endif
00399