18#ifndef __itkParabolicUtils_h
19#define __itkParabolicUtils_h
23#include "itkProgressReporter.h"
26template<
class LineBufferType,
class RealType,
bool doDilate >
28DoLine( LineBufferType & LineBuf, LineBufferType & tmpLineBuf,
29 const RealType magnitude,
const RealType m_Extreme )
32 long koffset = 0, newcontact = 0;
34 const long LineLength = LineBuf.size();
36 for(
long pos = 0; pos < LineLength; pos++ )
38 RealType BaseVal = (RealType)m_Extreme;
40 for(
long krange = koffset; krange <= 0; krange++ )
43 RealType T = LineBuf[ pos + krange ] - magnitude * krange * krange;
45 if( doDilate ? ( T >= BaseVal ) : ( T <= BaseVal ) )
51 tmpLineBuf[ pos ] = BaseVal;
52 koffset = newcontact - 1;
55 koffset = newcontact = 0;
56 for(
long pos = LineLength - 1; pos >= 0; pos-- )
58 RealType BaseVal = (RealType)m_Extreme;
59 for(
long krange = koffset; krange >= 0; krange-- )
61 RealType T = tmpLineBuf[ pos + krange ] - magnitude * krange * krange;
62 if( doDilate ? ( T >= BaseVal ) : ( T <= BaseVal ) )
68 LineBuf[ pos ] = BaseVal;
69 koffset = newcontact + 1;
74template<
class TInIter,
class TOutIter,
class RealType,
75class OutputPixelType,
bool doDilate >
78 ProgressReporter & progress,
79 const long LineLength,
80 const unsigned direction,
81 const int m_MagnitudeSign,
82 const bool m_UseImageSpacing,
83 const RealType m_Extreme,
84 const RealType image_scale,
85 const RealType Sigma )
91 typedef typename itk::Array< RealType > LineBufferType;
92 RealType iscale = 1.0;
93 if( m_UseImageSpacing )
97 const RealType magnitude = m_MagnitudeSign * 1.0 / ( 2.0 * Sigma / ( iscale * iscale ) );
98 LineBufferType LineBuf( LineLength );
99 LineBufferType tmpLineBuf( LineLength );
100 inputIterator.SetDirection( direction );
101 outputIterator.SetDirection( direction );
102 inputIterator.GoToBegin();
103 outputIterator.GoToBegin();
105 while( !inputIterator.IsAtEnd() && !outputIterator.IsAtEnd() )
111 while( !inputIterator.IsAtEndOfLine() )
113 LineBuf[ i++ ] =
static_cast< RealType
>( inputIterator.Get() );
117 DoLine< LineBufferType, RealType, doDilate >( LineBuf, tmpLineBuf, magnitude, m_Extreme );
120 while( !outputIterator.IsAtEndOfLine() )
122 outputIterator.Set(
static_cast< OutputPixelType
>( LineBuf[ j++ ] ) );
127 inputIterator.NextLine();
128 outputIterator.NextLine();
129 progress.CompletedPixel();
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)
void DoLine(LineBufferType &LineBuf, LineBufferType &tmpLineBuf, const RealType magnitude, const RealType m_Extreme)