1 #ifndef __itkParabolicUtils_h
2 #define __itkParabolicUtils_h
6 #include "itkProgressReporter.h"
8 template <
class LineBufferType,
class RealType,
bool doDilate>
9 void DoLine(LineBufferType &LineBuf, LineBufferType &tmpLineBuf,
10 const RealType magnitude,
const RealType m_Extreme)
13 long koffset = 0, newcontact=0;
15 const long LineLength = LineBuf.size();
17 for (
long pos = 0; pos < LineLength; pos++)
19 RealType BaseVal = (RealType)m_Extreme;
21 for (
long krange = koffset; krange <= 0; krange++)
24 RealType T = LineBuf[pos + krange] - magnitude * krange * krange;
26 if (doDilate ? (T >= BaseVal) : (T <= BaseVal) )
32 tmpLineBuf[pos] = BaseVal;
33 koffset = newcontact - 1;
36 koffset = newcontact = 0;
37 for (
long pos = LineLength - 1; pos >= 0; pos--)
39 RealType BaseVal = (RealType)m_Extreme;
40 for (
long krange = koffset; krange >= 0; krange--)
42 RealType T = tmpLineBuf[pos + krange] - magnitude * krange * krange;
43 if (doDilate ? (T >= BaseVal) : (T <= BaseVal))
49 LineBuf[pos] = BaseVal;
50 koffset = newcontact + 1;
54 template <
class TInIter,
class TOutIter,
class RealType,
55 class OutputPixelType,
bool doDilate>
57 ProgressReporter &progress,
58 const long LineLength,
59 const unsigned direction,
60 const int m_MagnitudeSign,
61 const bool m_UseImageSpacing,
62 const RealType m_Extreme,
63 const RealType image_scale,
70 typedef typename itk::Array<RealType> LineBufferType;
71 RealType iscale = 1.0;
72 if (m_UseImageSpacing)
76 const RealType magnitude = m_MagnitudeSign * 1.0/(2.0 * Sigma/(iscale*iscale));
77 LineBufferType LineBuf(LineLength);
78 LineBufferType tmpLineBuf(LineLength);
79 inputIterator.SetDirection(direction);
80 outputIterator.SetDirection(direction);
81 inputIterator.GoToBegin();
82 outputIterator.GoToBegin();
84 while( !inputIterator.IsAtEnd() && !outputIterator.IsAtEnd() )
90 while( !inputIterator.IsAtEndOfLine() )
92 LineBuf[i++] =
static_cast<RealType
>(inputIterator.Get());
96 DoLine<LineBufferType, RealType, doDilate>(LineBuf, tmpLineBuf, magnitude, m_Extreme);
99 while( !outputIterator.IsAtEndOfLine() )
101 outputIterator.Set( static_cast<OutputPixelType>( LineBuf[j++] ) );
106 inputIterator.NextLine();
107 outputIterator.NextLine();
108 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)