18 #ifndef itkScanlineFilterCommon_h
19 #define itkScanlineFilterCommon_h
40 template <
typename TInputImage,
typename TOutputImage>
65 if (smartPtr ==
nullptr)
67 smartPtr =
new Self(
nullptr);
69 smartPtr->UnRegister();
97 #ifdef ITK_USE_CONCEPT_CHECKING
148 itkAssertOrThrowMacro(requestedRegion.GetIndex(dim) <= index[dim],
"Index must be within the requested region!");
149 linearIndex += (index[dim] - requestedRegion.GetIndex(dim)) * stride;
150 stride *= requestedRegion.GetSize(dim);
160 typename LineMapType::iterator MapBegin, MapEnd, LineIt;
165 for (LineIt = MapBegin; LineIt != MapEnd; ++LineIt)
168 for (cIt = LineIt->begin(); cIt != LineIt->end(); ++cIt)
191 const std::lock_guard<std::mutex> lockGuard(
m_Mutex);
216 for (
size_t i = 1; i < N; ++i)
218 const auto label = static_cast<size_t>(
m_UnionFind[i]);
221 if (consecutiveLabel == backgroundValue)
251 return (diffSum <= 1);
269 bool sameLine = sameLineOffset;
292 mIt = Neighbour.begin();
294 for (cIt = current.begin(); cIt != current.end(); ++cIt)
303 mIt = Neighbour.begin();
306 for (nIt = mIt; nIt != Neighbour.end(); ++nIt)
308 if (!labelCompare || cIt->label != nIt->label)
336 if ((ss1 >= cStart) && (ee2 <= cLast))
343 else if ((ss1 <= cStart) && (ee2 >= cLast))
350 else if ((ss1 <= cLast) && (ee2 >= cLast))
357 else if ((ss1 <= cStart) && (ee2 >= cStart))
367 callback(cIt, nIt, oStart, oLast);
368 if (sameLineOffset && oStart == cStart && oLast == cLast)
375 if (!sameLineOffset && ee1 >= cLast)
408 PretendSizeType PretendSize;
410 for (
SizeValueType i = 0; i < PretendSize.GetSizeDimension(); ++i)
412 PretendSize[i] = OutSize[i + 1];
415 LineRegion.
SetSize(PretendSize);
416 fakeImage->SetRegions(LineRegion);
417 auto kernelRadius = PretendSizeType::Filled(1);
418 LineNeighborhoodType lnit(kernelRadius, fakeImage, LineRegion);
420 if (wholeNeighborhood)
429 typename LineNeighborhoodType::IndexListType ActiveIndexes;
430 ActiveIndexes = lnit.GetActiveIndexList();
432 typename LineNeighborhoodType::IndexListType::const_iterator LI;
434 PretendIndexType idx = LineRegion.GetIndex();
437 for (LI = ActiveIndexes.begin(); LI != ActiveIndexes.end(); ++LI)
439 m_LineOffsets.push_back(fakeImage->ComputeOffset(idx + lnit.GetOffset(*LI)) - offset);
442 if (wholeNeighborhood)
459 const SizeValueType xsizeForThread = outputRegionForThread.GetSize()[0];
460 const SizeValueType numberOfLines = outputRegionForThread.GetNumberOfPixels() / xsizeForThread;
463 const SizeValueType lastLine = firstLine + numberOfLines - 1;
479 itkAssertInDebugAndIgnoreInReleaseMacro(lastLine >= wud.
lastLine);
490 if (neighIdx >= 0 && neighIdx < linecount && !
m_LineMap[neighIdx].empty())