28DoLine(LineBufferType & LineBuf, LineBufferType & tmpLineBuf,
const RealType magnitude)
30 static constexpr RealType extreme =
31 doDilate ? NumericTraits<TInputPixel>::NonpositiveMin() : NumericTraits<TInputPixel>::max();
34 long koffset = 0, newcontact = 0;
36 const long LineLength = LineBuf.size();
38 for (
long pos = 0; pos < LineLength; ++pos)
40 RealType BaseVal = extreme;
41 for (
long krange = koffset; krange <= 0; ++krange)
44 RealType T = LineBuf[pos + krange] - magnitude * krange * krange;
46 if (doDilate ? (T >= BaseVal) : (T <= BaseVal))
52 tmpLineBuf[pos] = BaseVal;
53 koffset = newcontact - 1;
56 koffset = newcontact = 0;
57 for (
long pos = LineLength - 1; pos >= 0; pos--)
59 RealType BaseVal = extreme;
60 for (
long krange = koffset; krange >= 0; krange--)
62 RealType T = tmpLineBuf[pos + krange] - magnitude * krange * krange;
63 if (doDilate ? (T >= BaseVal) : (T <= BaseVal))
69 LineBuf[pos] = BaseVal;
70 koffset = newcontact + 1;
78 TOutIter & outputIterator,
79 ProgressReporter & progress,
80 const long LineLength,
81 const unsigned direction,
82 const bool m_UseImageSpacing,
83 const RealType image_scale,
90 using LineBufferType =
typename itk::Array<RealType>;
91 RealType iscale = 1.0;
92 if (m_UseImageSpacing)
96 constexpr int magnitudeSign = doDilate ? 1 : -1;
97 const RealType magnitude = 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());
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 bool m_UseImageSpacing, const RealType image_scale, const RealType Sigma)