Orfeo Toolbox  3.16
itkMinimumMaximumImageCalculator.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkMinimumMaximumImageCalculator.txx,v $
5  Language: C++
6  Date: $Date: 2008-10-16 23:24:23 $
7  Version: $Revision: 1.23 $
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 __itkMinimumMaximumImageCalculator_txx
18 #define __itkMinimumMaximumImageCalculator_txx
19 
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
26 
30 template<class TInputImage>
33 {
34  m_Image = TInputImage::New();
35  m_Maximum = NumericTraits<PixelType>::NonpositiveMin();
36  m_Minimum = NumericTraits<PixelType>::max();
37  m_IndexOfMinimum.Fill(0);
38  m_IndexOfMaximum.Fill(0);
39  m_RegionSetByUser = false;
40 }
41 
42 
46 template<class TInputImage>
47 void
49 ::Compute(void)
50 {
51  if( !m_RegionSetByUser )
52  {
53  m_Region = m_Image->GetRequestedRegion();
54  }
55 
57  m_Maximum = NumericTraits<PixelType>::NonpositiveMin();
58  m_Minimum = NumericTraits<PixelType>::max();
59 
60 
61  while( !it.IsAtEnd() )
62  {
63  const PixelType value = it.Get();
64  if (value > m_Maximum)
65  {
66  m_Maximum = value;
67  m_IndexOfMaximum = it.GetIndex();
68  }
69  if (value < m_Minimum)
70  {
71  m_Minimum = value;
72  m_IndexOfMinimum = it.GetIndex();
73  }
74  ++it;
75  }
76 
77 }
78 
82 template<class TInputImage>
83 void
86 {
87  if( !m_RegionSetByUser )
88  {
89  m_Region = m_Image->GetRequestedRegion();
90  }
92  m_Minimum = NumericTraits<PixelType>::max();
93 
94  while( !it.IsAtEnd() )
95  {
96  const PixelType value = it.Get();
97  if (value < m_Minimum)
98  {
99  m_Minimum = value;
100  m_IndexOfMinimum = it.GetIndex();
101  }
102  ++it;
103  }
104 
105 }
106 
110 template<class TInputImage>
111 void
114 {
115  if( !m_RegionSetByUser )
116  {
117  m_Region = m_Image->GetRequestedRegion();
118  }
119  ImageRegionConstIteratorWithIndex< TInputImage > it( m_Image, m_Region );
120  m_Maximum = NumericTraits<PixelType>::NonpositiveMin();
121 
122  while( !it.IsAtEnd() )
123  {
124  const PixelType value = it.Get();
125  if (value > m_Maximum)
126  {
127  m_Maximum = value;
128  m_IndexOfMaximum = it.GetIndex();
129  }
130  ++it;
131  }
132 
133 }
134 
135 template<class TInputImage>
136 void
138 ::SetRegion( const RegionType & region )
139 {
140  m_Region = region;
141  m_RegionSetByUser = true;
142 }
143 
144 
145 
146 template<class TInputImage>
147 void
149 ::PrintSelf( std::ostream& os, Indent indent ) const
150 {
151  Superclass::PrintSelf(os,indent);
152 
153  os << indent << "Minimum: "
154  << static_cast<typename NumericTraits<PixelType>::PrintType>(m_Minimum)
155  << std::endl;
156  os << indent << "Maximum: "
157  << static_cast<typename NumericTraits<PixelType>::PrintType>(m_Maximum)
158  << std::endl;
159  os << indent << "Index of Minimum: " << m_IndexOfMinimum << std::endl;
160  os << indent << "Index of Maximum: " << m_IndexOfMaximum << std::endl;
161  os << indent << "Image: " << std::endl;
162  m_Image->Print(os, indent.GetNextIndent());
163  os << indent << "Region: " << std::endl;
164  m_Region.Print(os,indent.GetNextIndent());
165  os << indent << "Region set by User: " << m_RegionSetByUser << std::endl;
166 }
167 
168 } // end namespace itk
169 
170 #endif

Generated at Sat Feb 2 2013 23:52:49 for Orfeo Toolbox with doxygen 1.8.1.1