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);
163 for (
typename LineMapType::iterator LineIt = MapBegin; LineIt != MapEnd; ++LineIt)
165 for (
auto cIt = LineIt->begin(); cIt != LineIt->end(); ++cIt)
188 const std::lock_guard<std::mutex> lockGuard(
m_Mutex);
213 for (
size_t i = 1; i < N; ++i)
215 const auto label = static_cast<size_t>(
m_UnionFind[i]);
218 if (consecutiveLabel == backgroundValue)
248 return (diffSum <= 1);
266 bool sameLine = sameLineOffset;
287 auto mIt = Neighbour.begin();
289 for (
auto cIt = current.begin(); cIt != current.end(); ++cIt)
298 mIt = Neighbour.begin();
301 for (
auto nIt = mIt; nIt != Neighbour.end(); ++nIt)
303 if (!labelCompare || cIt->label != nIt->label)
331 if ((ss1 >= cStart) && (ee2 <= cLast))
338 else if ((ss1 <= cStart) && (ee2 >= cLast))
345 else if ((ss1 <= cLast) && (ee2 >= cLast))
352 else if ((ss1 <= cStart) && (ee2 >= cStart))
362 callback(cIt, nIt, oStart, oLast);
363 if (sameLineOffset && oStart == cStart && oLast == cLast)
370 if (!sameLineOffset && ee1 >= cLast)
403 PretendSizeType PretendSize;
405 for (
SizeValueType i = 0; i < PretendSize.GetSizeDimension(); ++i)
407 PretendSize[i] = OutSize[i + 1];
410 LineRegion.
SetSize(PretendSize);
411 fakeImage->SetRegions(LineRegion);
412 auto kernelRadius = PretendSizeType::Filled(1);
413 LineNeighborhoodType lnit(kernelRadius, fakeImage, LineRegion);
415 if (wholeNeighborhood)
424 typename LineNeighborhoodType::IndexListType ActiveIndexes = lnit.GetActiveIndexList();
426 const PretendIndexType idx = LineRegion.GetIndex();
429 for (
auto LI = ActiveIndexes.begin(); LI != ActiveIndexes.end(); ++LI)
431 m_LineOffsets.push_back(fakeImage->ComputeOffset(idx + lnit.GetOffset(*LI)) - offset);
434 if (wholeNeighborhood)
451 const SizeValueType xsizeForThread = outputRegionForThread.GetSize()[0];
452 const SizeValueType numberOfLines = outputRegionForThread.GetNumberOfPixels() / xsizeForThread;
455 const SizeValueType lastLine = firstLine + numberOfLines - 1;
471 itkAssertInDebugAndIgnoreInReleaseMacro(lastLine >= wud.
lastLine);
482 if (neighIdx >= 0 && neighIdx < linecount && !
m_LineMap[neighIdx].empty())