18#ifndef itkParabolicUtils_h
19#define itkParabolicUtils_h
23#include "itkProgressReporter.h"
26template <
class LineBufferType,
class RealType,
bool doDilate>
28DoLine(LineBufferType & LineBuf, LineBufferType & tmpLineBuf,
const RealType magnitude,
const RealType m_Extreme)
31 long koffset = 0, newcontact = 0;
33 const long LineLength = LineBuf.size();
35 for (
long pos = 0; pos < LineLength; ++pos)
37 RealType BaseVal = (RealType)m_Extreme;
39 for (
long krange = koffset; krange <= 0; ++krange)
42 RealType T = LineBuf[pos + krange] - magnitude * krange * krange;
44 if (doDilate ? (T >= BaseVal) : (T <= BaseVal))
50 tmpLineBuf[pos] = BaseVal;
51 koffset = newcontact - 1;
54 koffset = newcontact = 0;
55 for (
long pos = LineLength - 1; pos >= 0; pos--)
57 RealType BaseVal = (RealType)m_Extreme;
58 for (
long krange = koffset; krange >= 0; krange--)
60 RealType T = tmpLineBuf[pos + krange] - magnitude * krange * krange;
61 if (doDilate ? (T >= BaseVal) : (T <= BaseVal))
67 LineBuf[pos] = BaseVal;
68 koffset = newcontact + 1;
73template <
class TInIter,
class TOutIter,
class RealType,
class OutputPixelType,
bool doDilate>
76 TOutIter & outputIterator,
77 ProgressReporter & progress,
78 const long LineLength,
79 const unsigned direction,
80 const int m_MagnitudeSign,
81 const bool m_UseImageSpacing,
82 const RealType m_Extreme,
83 const RealType image_scale,
90 using LineBufferType =
typename itk::Array<RealType>;
91 RealType iscale = 1.0;
92 if (m_UseImageSpacing)
96 const RealType magnitude = m_MagnitudeSign * 1.0 / (2.0 * Sigma / (iscale * iscale));
97 LineBufferType LineBuf(LineLength);
98 LineBufferType tmpLineBuf(LineLength);
99 inputIterator.SetDirection(direction);
100 outputIterator.SetDirection(direction);
101 inputIterator.GoToBegin();
102 outputIterator.GoToBegin();
104 while (!inputIterator.IsAtEnd() && !outputIterator.IsAtEnd())
110 while (!inputIterator.IsAtEndOfLine())
112 LineBuf[i++] =
static_cast<RealType
>(inputIterator.Get());
116 DoLine<LineBufferType, RealType, doDilate>(LineBuf, tmpLineBuf, magnitude, m_Extreme);
119 while (!outputIterator.IsAtEndOfLine())
121 outputIterator.Set(
static_cast<OutputPixelType
>(LineBuf[j++]));
126 inputIterator.NextLine();
127 outputIterator.NextLine();
128 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)