Orfeo Toolbox  3.16
itkRegionalMaximaImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkRegionalMaximaImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2007-01-20 20:05:58 $
7  Version: $Revision: 1.3 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkRegionalMaximaImageFilter_txx
18 #define __itkRegionalMaximaImageFilter_txx
19 
22 #include "itkProgressAccumulator.h"
23 #include "itkNumericTraits.h"
25 #include "itkProgressReporter.h"
26 #include "itkImageRegionIterator.h"
27 
28 namespace itk {
29 
30 template <class TInputImage, class TOutputImage>
33 {
34  m_FullyConnected = false;
35  m_FlatIsMaxima = true;
36  m_ForegroundValue = NumericTraits<OutputImagePixelType>::max();
37  m_BackgroundValue = NumericTraits<OutputImagePixelType>::NonpositiveMin();
38 }
39 
40 template <class TInputImage, class TOutputImage>
41 void
44 {
45  // call the superclass' implementation of this method
46  Superclass::GenerateInputRequestedRegion();
47 
48  // We need all the input.
49  InputImagePointer input = const_cast<InputImageType *>(this->GetInput());
50  if ( !input )
51  {
52  return;
53  }
54  input->SetRequestedRegion( input->GetLargestPossibleRegion() );
55 }
56 
57 
58 template <class TInputImage, class TOutputImage>
59 void
62 {
63  this->GetOutput()
64  ->SetRequestedRegion( this->GetOutput()->GetLargestPossibleRegion() );
65 }
66 
67 
68 template<class TInputImage, class TOutputImage>
69 void
72 {
73  // Create a process accumulator for tracking the progress of this minipipeline
75  progress->SetMiniPipelineFilter(this);
76 
77  // Allocate the output
78  this->AllocateOutputs();
79 
80  // Delegate to the valued filter to find the minima
83  rmax->SetInput( this->GetInput() );
84  rmax->SetFullyConnected( m_FullyConnected );
85  progress->RegisterInternalFilter( rmax, 0.67f );
86  rmax->Update();
87 
88  if( rmax->GetFlat() )
89  {
90  ProgressReporter progress2(this, 0,
91  this->GetOutput()->GetRequestedRegion().GetNumberOfPixels(),
92  33, 0.67, 0.33);
93 
95  outIt(this->GetOutput(), this->GetOutput()->GetRequestedRegion() );
96 
97  if( m_FlatIsMaxima )
98  {
99  for( outIt.Begin(); !outIt.IsAtEnd(); ++outIt )
100  {
101  outIt.Set( m_ForegroundValue );
102  progress2.CompletedPixel();
103  }
104  }
105  else
106  {
107  for( outIt.Begin(); !outIt.IsAtEnd(); ++outIt )
108  {
109  outIt.Set( m_BackgroundValue );
110  progress2.CompletedPixel();
111  }
112  }
113  }
114  else
115  {
117  ThresholdType;
118 
119  typename ThresholdType::Pointer th = ThresholdType::New();
120  th->SetInput( rmax->GetOutput() );
121  th->SetUpperThreshold( rmax->GetMarkerValue() );
122  th->SetLowerThreshold( rmax->GetMarkerValue() );
123  th->SetOutsideValue( m_ForegroundValue );
124  th->SetInsideValue( m_BackgroundValue );
125  progress->RegisterInternalFilter( th, 0.33f );
126 
127  th->GraftOutput( this->GetOutput() );
128  th->Update();
129  this->GraftOutput( th->GetOutput() );
130  }
131 
132 }
133 
134 
135 template<class TInputImage, class TOutputImage>
136 void
138 ::PrintSelf(std::ostream &os, Indent indent) const
139 {
140  Superclass::PrintSelf(os, indent);
141 
142  os << indent << "FullyConnected: " << m_FullyConnected << std::endl;
143  os << indent << "FlatIsMaxima: " << m_FlatIsMaxima << std::endl;
144  os << indent << "ForegroundValue: " << m_ForegroundValue << std::endl;
145  os << indent << "BackgroundValue: " << m_BackgroundValue << std::endl;
146 }
147 
148 }// end namespace itk
149 #endif

Generated at Sun Feb 3 2013 00:02:28 for Orfeo Toolbox with doxygen 1.8.1.1