1 #ifndef __itkParabolicUtils_h
2 #define __itkParabolicUtils_h
6 #include "itkProgressReporter.h"
9 template<
class LineBufferType,
class RealType,
bool doDilate >
11 DoLine( LineBufferType & LineBuf, LineBufferType & tmpLineBuf,
12 const RealType magnitude,
const RealType m_Extreme )
15 long koffset = 0, newcontact = 0;
17 const long LineLength = LineBuf.size();
19 for(
long pos = 0; pos < LineLength; pos++ )
21 RealType BaseVal = (RealType)m_Extreme;
23 for(
long krange = koffset; krange <= 0; krange++ )
26 RealType T = LineBuf[ pos + krange ] - magnitude * krange * krange;
28 if( doDilate ? ( T >= BaseVal ) : ( T <= BaseVal ) )
34 tmpLineBuf[ pos ] = BaseVal;
35 koffset = newcontact - 1;
38 koffset = newcontact = 0;
39 for(
long pos = LineLength - 1; pos >= 0; pos-- )
41 RealType BaseVal = (RealType)m_Extreme;
42 for(
long krange = koffset; krange >= 0; krange-- )
44 RealType T = tmpLineBuf[ pos + krange ] - magnitude * krange * krange;
45 if( doDilate ? ( T >= BaseVal ) : ( T <= BaseVal ) )
51 LineBuf[ pos ] = BaseVal;
52 koffset = newcontact + 1;
57 template<
class TInIter,
class TOutIter,
class RealType,
58 class OutputPixelType,
bool doDilate >
61 ProgressReporter & progress,
62 const long LineLength,
63 const unsigned direction,
64 const int m_MagnitudeSign,
65 const bool m_UseImageSpacing,
66 const RealType m_Extreme,
67 const RealType image_scale,
68 const RealType Sigma )
74 typedef typename itk::Array< RealType > LineBufferType;
75 RealType iscale = 1.0;
76 if( m_UseImageSpacing )
80 const RealType magnitude = m_MagnitudeSign * 1.0 / ( 2.0 * Sigma / ( iscale * iscale ) );
81 LineBufferType LineBuf( LineLength );
82 LineBufferType tmpLineBuf( LineLength );
83 inputIterator.SetDirection( direction );
84 outputIterator.SetDirection( direction );
85 inputIterator.GoToBegin();
86 outputIterator.GoToBegin();
88 while( !inputIterator.IsAtEnd() && !outputIterator.IsAtEnd() )
94 while( !inputIterator.IsAtEndOfLine() )
96 LineBuf[ i++ ] =
static_cast< RealType
>( inputIterator.Get() );
100 DoLine< LineBufferType, RealType, doDilate >( LineBuf, tmpLineBuf, magnitude, m_Extreme );
103 while( !outputIterator.IsAtEndOfLine() )
105 outputIterator.Set( static_cast< OutputPixelType >( LineBuf[ j++ ] ) );
110 inputIterator.NextLine();
111 outputIterator.NextLine();
112 progress.CompletedPixel();
void DoLine(LineBufferType &LineBuf, LineBufferType &tmpLineBuf, const RealType magnitude, const RealType m_Extreme)
void doOneDimension(TInIter &inputIterator, TOutIter &outputIterator, ProgressReporter &progress, const long LineLength, const unsigned direction, const int m_MagnitudeSign, const bool m_UseImageSpacing, const RealType m_Extreme, const RealType image_scale, const RealType Sigma)