ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkKLMRegionGrowImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkKLMRegionGrowImageFilter_h
19 #define itkKLMRegionGrowImageFilter_h
20 
21 #include "itkImage.h"
24 #include "itkImageRegionIterator.h"
25 #include "itkConceptChecking.h"
26 #include <algorithm>
27 #include <functional>
28 
29 namespace itk
30 {
164 template< typename TInputImage, typename TOutputImage >
165 class ITK_TEMPLATE_EXPORT KLMRegionGrowImageFilter:public RegionGrowImageFilter< TInputImage, TOutputImage >
166 {
167 public:
173 
175  itkNewMacro(Self);
176 
179 
181  typedef TInputImage InputImageType;
182  typedef typename TInputImage::Pointer InputImagePointer;
183  typedef typename TInputImage::ConstPointer InputImageConstPointer;
184 
186  typedef typename TInputImage::PixelType InputImagePixelType;
187 
190 
192  itkStaticConstMacro(InputImageVectorDimension, unsigned int,
194 
197 
201 
203  typedef typename TInputImage::RegionType InputRegionType;
204 
207  typedef typename Superclass::GridSizeType GridSizeType;
208 
210  typedef TOutputImage OutputImageType;
211  typedef typename TOutputImage::Pointer OutputImagePointer;
212 
214  itkStaticConstMacro(InputImageDimension, unsigned int,
215  TInputImage::ImageDimension);
216 
218  itkStaticConstMacro(OutputImageDimension, unsigned int,
219  TOutputImage::ImageDimension);
220 
222  typedef typename TOutputImage::PixelType OutputImagePixelType;
223 
226 
228  itkStaticConstMacro(OutputImageVectorDimension, unsigned int,
230 
233 
236 
239 
241  itkStaticConstMacro(LabelImageDimension, RegionLabelType,
242  InputImageDimension);
243 
246 
249 
252 
255 
258 
260  typedef vnl_vector< double > MeanRegionIntensityType;
261 
264 
267 
271  itkSetMacro(MaximumLambda, double);
272  itkGetConstReferenceMacro(MaximumLambda, double);
274 
276  itkSetMacro(NumberOfRegions, unsigned int);
277  itkGetConstReferenceMacro(NumberOfRegions, unsigned int);
279 
281  LabelImagePointer GetLabelledImage();
282 
284  void PrintAlgorithmRegionStats();
285 
287  void PrintAlgorithmBorderStats();
288 
289 #ifdef ITK_USE_CONCEPT_CHECKING
290  // Begin concept checking
291  itkConceptMacro( InputHasNumericTraitsCheck,
293  itkConceptMacro( SameDimension,
294  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageDimension),
295  itkGetStaticConstMacro(OutputImageDimension) > ) );
296 #if defined(THIS_CONCEPT_FAILS_ON_GCC)
297 
298  itkConceptMacro( SameVectorDimension,
299  ( Concept::SameDimension< itkGetStaticConstMacro(InputImageVectorDimension),
300  itkGetStaticConstMacro(OutputImageVectorDimension) > ) );
301 #endif
302  // End concept checking
303 #endif
304 
305 protected:
307  ~KLMRegionGrowImageFilter() ITK_OVERRIDE;
308  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
309 
313  virtual void GenerateData() ITK_OVERRIDE;
314 
318  virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
319 
324  virtual void EnlargeOutputRequestedRegion(DataObject *) ITK_OVERRIDE;
325 
328  void ApplyRegionGrowImageFilter() ITK_OVERRIDE;
329 
333  virtual void MergeRegions() ITK_OVERRIDE;
334 
336  virtual void GenerateOutputImage();
337 
339  void ApplyKLM();
340 
342  void InitializeKLM();
343 
345  LabelImagePointer GenerateLabelledImage(LabelImageType *labelImagePtr);
346 
352  virtual void InitializeRegionParameters(InputRegionType region);
353 
357  virtual void ResolveRegions();
358 
359 private:
360  ITK_DISALLOW_COPY_AND_ASSIGN(KLMRegionGrowImageFilter);
361 
362  typedef typename TInputImage::SizeType InputImageSizeType;
365 
366  double m_MaximumLambda;
367  unsigned int m_NumberOfRegions;
368 
371  double m_InternalLambda;
372  unsigned int m_InitialNumberOfRegions;
373  double m_TotalBorderLength;
374 
375  std::vector< KLMSegmentationRegionPtr > m_RegionsPointer;
376  std::vector< KLMSegmentationBorderPtr > m_BordersPointer;
377  std::vector< KLMSegmentationBorderArrayPtr > m_BordersDynamicPointer;
378  KLMSegmentationBorderArrayPtr * m_BorderCandidate;
379 
380  MeanRegionIntensityType m_InitialRegionMean;
381  double m_InitialRegionArea;
382 }; // class KLMRegionGrowImageFilter
383 } // namespace itk
384 
385 #ifndef ITK_MANUAL_INSTANTIATION
386 #include "itkKLMRegionGrowImageFilter.hxx"
387 #endif
388 
389 #endif
ImageRegionIterator< TOutputImage > OutputImageIterator
Base class for KLMSegmentationRegion object.
SmartPointer< const Self > ConstPointer
ImageRegionIterator< LabelImageType > LabelImageIterator
Base class for all process objects that output image data.
TOutputImage::IndexType OutputImageIndexType
TOutputImage::PixelType::VectorType OutputImageVectorType
ImageRegionIterator< TInputImage > InputImageIterator
TPixel PixelType
Definition: itkImage.h:89
TInputImage::PixelType::VectorType InputImageVectorType
LabelImageType::IndexType LabelImageIndexType
ImageRegionConstIterator< TInputImage > InputImageConstIterator
A multi-dimensional iterator templated over image type that walks a region of pixels.
RegionGrowImageFilter< TInputImage, TOutputImage > Superclass
Base class for a region growing object that performs energy-based region growing for multiband images...
Base class for KLMSegmentationBorder object.
Superclass::RegionLabelType RegionLabelType
Base class for RegionGrowImageFilter object.
LabelImageType::PixelType LabelImagePixelType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Image< RegionLabelType, itkGetStaticConstMacro(LabelImageDimension) > LabelImageType
KLMSegmentationRegion::RegionLabelType RegionLabelType
Object maintaining a reference to a list of borders associated with a region.
#define itkConceptMacro(name, concept)
TInputImage::ConstPointer InputImageConstPointer
KLMDynamicBorderArray< BorderType > KLMSegmentationBorderArrayPtr
Base class for all data objects in ITK.
Templated n-dimensional image class.
Definition: itkImage.h:75
A multi-dimensional iterator templated over image type that walks a region of pixels.
TOutputImage::PixelType OutputImagePixelType