30DoLineCP(LineBufferType & LineBuf, LineBufferType & tmpLineBuf,
const RealType magnitude)
36 long koffset = 0, newcontact = 0;
38 const long LineLength = LineBuf.size();
41 for (
long pos = 0; pos < LineLength; pos++)
43 auto BaseVal = extreme;
44 for (
long krange = koffset; krange <= 0; krange++)
47 RealType T = LineBuf[pos + krange] - magnitude * krange * krange;
49 if (doDilate ? (T >= BaseVal) : (T <= BaseVal))
55 tmpLineBuf[pos] = BaseVal;
56 koffset = newcontact - 1;
59 koffset = newcontact = 0;
60 for (
long pos = LineLength - 1; pos >= 0; pos--)
62 auto BaseVal = extreme;
63 for (
long krange = koffset; krange >= 0; krange--)
65 RealType T = tmpLineBuf[pos + krange] - magnitude * krange * krange;
66 if (doDilate ? (T >= BaseVal) : (T <= BaseVal))
72 LineBuf[pos] = BaseVal;
73 koffset = newcontact + 1;
110 F[0] = LineBuf[0] / magnitude;
111 const size_t N(LineBuf.size());
113 for (
size_t q = 1; q < N; q++)
118 F[q] = (LineBuf[q] / magnitude) - (
static_cast<RealType>(q) *
static_cast<RealType>(q));
125 s = (F[q] - F[v[k]]) / (2.0 * (v[k] -
static_cast<RealType>(q)));
133 F[q] = (LineBuf[q] / magnitude) + (
static_cast<RealType>(q) *
static_cast<RealType>(q));
140 s = (F[q] - F[v[k]]) / (2.0 * (
static_cast<RealType>(q) - v[k]));
147 itkAssertInDebugAndIgnoreInReleaseMacro((
size_t)(k + 1) <= N);
154 for (
size_t q = 0; q < N; q++)
156 while (z[k + 1] <
static_cast<typename IndexBufferType::ValueType
>(q))
160 itkAssertInDebugAndIgnoreInReleaseMacro(
static_cast<size_t>(v[k]) < N);
161 itkAssertInDebugAndIgnoreInReleaseMacro(
static_cast<size_t>(v[k]) >= 0);
163 (F[v[k]] - (
static_cast<RealType>(q) * (
static_cast<RealType>(q) - 2 * v[k]))) * magnitude);
169 for (
size_t q = 0; q < N; q++)
171 while (z[k + 1] <
static_cast<typename IndexBufferType::ValueType
>(q))
175 itkAssertInDebugAndIgnoreInReleaseMacro(
static_cast<size_t>(v[k]) < N);
176 itkAssertInDebugAndIgnoreInReleaseMacro(
static_cast<size_t>(v[k]) >= 0);
177 LineBuf[q] = ((
static_cast<RealType>(q) * (
static_cast<RealType>(q) - 2 * v[k]) + F[v[k]]) * magnitude);
190 TOutIter & outputIterator,
192 const long LineLength,
193 const unsigned direction,
194 const bool m_UseImageSpacing,
197 int ParabolicAlgorithmChoice)
199 enum ParabolicAlgorithm
212 if (m_UseImageSpacing)
214 iscale = image_scale;
216 if (ParabolicAlgorithmChoice == NOCHOICE)
219 if ((2.0 * Sigma) < 0.2)
221 ParabolicAlgorithmChoice = CONTACTPOINT;
225 ParabolicAlgorithmChoice = INTERSECTION;
229 if (ParabolicAlgorithmChoice == CONTACTPOINT)
236 constexpr int magnitudeSign = doDilate ? 1 : -1;
237 const RealType magnitudeCP = (magnitudeSign * iscale * iscale) / (2.0 * Sigma);
239 LineBufferType LineBuf(LineLength);
240 LineBufferType tmpLineBuf(LineLength);
241 inputIterator.SetDirection(direction);
242 outputIterator.SetDirection(direction);
243 inputIterator.GoToBegin();
244 outputIterator.GoToBegin();
246 while (!inputIterator.IsAtEnd() && !outputIterator.IsAtEnd())
253 while (!inputIterator.IsAtEndOfLine())
255 LineBuf[i++] =
static_cast<RealType>(inputIterator.Get());
262 while (!outputIterator.IsAtEndOfLine())
264 outputIterator.Set(
static_cast<OutputPixelType
>(LineBuf[j++]));
269 inputIterator.NextLine();
270 outputIterator.NextLine();
279 const RealType magnitudeInt = (iscale * iscale) / (2.0 * Sigma);
280 LineBufferType LineBuf(LineLength);
281 LineBufferType Fbuf(LineLength);
282 IndexBufferType Vbuf(LineLength);
283 LineBufferType Zbuf(LineLength + 1);
285 inputIterator.SetDirection(direction);
286 outputIterator.SetDirection(direction);
287 inputIterator.GoToBegin();
288 outputIterator.GoToBegin();
290 while (!inputIterator.IsAtEnd() && !outputIterator.IsAtEnd())
297 while (!inputIterator.IsAtEndOfLine())
299 LineBuf[i++] =
static_cast<RealType>(inputIterator.Get());
303 LineBuf, Fbuf, Vbuf, Zbuf, magnitudeInt);
306 while (!outputIterator.IsAtEndOfLine())
308 outputIterator.Set(
static_cast<OutputPixelType
>(LineBuf[j++]));
313 inputIterator.NextLine();
314 outputIterator.NextLine();
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, int ParabolicAlgorithmChoice)