ITK  5.0.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:
168  ITK_DISALLOW_COPY_AND_ASSIGN(KLMRegionGrowImageFilter);
169 
175 
177  itkNewMacro(Self);
178 
181 
183  using InputImageType = TInputImage;
184  using InputImagePointer = typename TInputImage::Pointer;
185  using InputImageConstPointer = typename TInputImage::ConstPointer;
186 
188  using InputImagePixelType = typename TInputImage::PixelType;
189 
192 
194  static constexpr unsigned int InputImageVectorDimension = InputImagePixelType::Dimension;
195 
198 
202 
205 
208  using GridSizeType = typename Superclass::GridSizeType;
209 
211  using OutputImageType = TOutputImage;
212  using OutputImagePointer = typename TOutputImage::Pointer;
213 
215  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
216 
218  static constexpr unsigned int OutputImageDimension = TOutputImage::ImageDimension;
219 
221  using OutputImagePixelType = typename TOutputImage::PixelType;
222 
225 
227  static constexpr unsigned int OutputImageVectorDimension = OutputImagePixelType::Dimension;
228 
231 
234 
237 
239  static constexpr RegionLabelType LabelImageDimension = InputImageDimension;
240 
243 
246 
249 
252 
255 
257  using MeanRegionIntensityType = vnl_vector< double >;
258 
261 
264 
268  itkSetMacro(MaximumLambda, double);
269  itkGetConstReferenceMacro(MaximumLambda, double);
271 
273  itkSetMacro(NumberOfRegions, unsigned int);
274  itkGetConstReferenceMacro(NumberOfRegions, unsigned int);
276 
278  LabelImagePointer GetLabelledImage();
279 
281  void PrintAlgorithmRegionStats();
282 
284  void PrintAlgorithmBorderStats();
285 
286 #ifdef ITK_USE_CONCEPT_CHECKING
287  // Begin concept checking
288  itkConceptMacro( InputHasNumericTraitsCheck,
290  itkConceptMacro( SameDimension,
291  ( Concept::SameDimension< Self::InputImageDimension,
292  Self::OutputImageDimension > ) );
293 #if defined(THIS_CONCEPT_FAILS_ON_GCC)
294 
295  itkConceptMacro( SameVectorDimension,
296  ( Concept::SameDimension< Self::InputImageVectorDimension,
297  Self::OutputImageVectorDimension > ) );
298 #endif
299  // End concept checking
300 #endif
301 
302 protected:
304  ~KLMRegionGrowImageFilter() override = default;
305  void PrintSelf(std::ostream & os, Indent indent) const override;
306 
310  void GenerateData() override;
311 
315  void GenerateInputRequestedRegion() override;
316 
321  void EnlargeOutputRequestedRegion(DataObject *) override;
322 
325  void ApplyRegionGrowImageFilter() override;
326 
330  void MergeRegions() override;
331 
333  virtual void GenerateOutputImage();
334 
336  void ApplyKLM();
337 
339  void InitializeKLM();
340 
342  LabelImagePointer GenerateLabelledImage(LabelImageType *labelImagePtr);
343 
349  virtual void InitializeRegionParameters(InputRegionType region);
350 
354  virtual void ResolveRegions();
355 
356 private:
360 
361  double m_MaximumLambda{1000};
362  unsigned int m_NumberOfRegions{0};
363 
366  double m_InternalLambda{0};
367  unsigned int m_InitialNumberOfRegions{0};
368  double m_TotalBorderLength{0.0};
369 
370  std::vector< KLMSegmentationRegionPtr > m_RegionsPointer;
371  std::vector< KLMSegmentationBorderPtr > m_BordersPointer;
372  std::vector< KLMSegmentationBorderArrayPtr > m_BordersDynamicPointer;
373  KLMSegmentationBorderArrayPtr * m_BorderCandidate{nullptr};
374 
376  double m_InitialRegionArea{0};
377 }; // class KLMRegionGrowImageFilter
378 } // namespace itk
379 
380 #ifndef ITK_MANUAL_INSTANTIATION
381 #include "itkKLMRegionGrowImageFilter.hxx"
382 #endif
383 
384 #endif
TPixel PixelType
Definition: itkImage.h:95
typename OutputImageType::Pointer OutputImagePointer
typename TInputImage::SizeType InputImageSizeType
typename TInputImage::PixelType::VectorType InputImageVectorType
typename LabelImageType::IndexType LabelImageIndexType
typename LabelImageType::Pointer LabelImagePointer
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Base class for all process objects that output image data.
typename TInputImage::RegionType InputRegionType
typename OutputImageType::PixelType OutputImagePixelType
typename InputImageType::PixelType InputImagePixelType
typename InputImageType::Pointer InputImagePointer
typename TOutputImage::PixelType::VectorType OutputImageVectorType
A multi-dimensional iterator templated over image type that walks a region of pixels.
TOutputImage OutputImageType
typename TOutputImage::IndexType OutputImageIndexType
typename KLMSegmentationBorder::Pointer KLMSegmentationBorderPtr
Base class for a region growing object that performs energy-based region growing for multiband images...
typename KLMSegmentationRegion::RegionLabelType RegionLabelType
Base class for KLMSegmentationBorder object.
std::vector< KLMSegmentationBorderPtr > m_BordersPointer
Base class for RegionGrowImageFilter object.
std::vector< KLMSegmentationBorderArrayPtr > m_BordersDynamicPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename TInputImage::IndexType InputImageIndexType
typename Superclass::GridSizeType GridSizeType
std::vector< KLMSegmentationRegionPtr > m_RegionsPointer
Object maintaining a reference to a list of borders associated with a region.
Superclass::RegionLabelType RegionLabelType
class ITK_FORWARD_EXPORT KLMSegmentationBorder
#define itkConceptMacro(name, concept)
typename LabelImageType::PixelType LabelImagePixelType
typename InputImageType::ConstPointer InputImageConstPointer
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.
typename KLMSegmentationRegion::Pointer KLMSegmentationRegionPtr