18 #ifndef itkScanlineFilterCommon_h
19 #define itkScanlineFilterCommon_h
40 template <
typename TInputImage,
typename TOutputImage>
65 if (smartPtr ==
nullptr)
67 smartPtr =
new Self(
nullptr);
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 std::lock_guard<std::mutex> mutexHolder(
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)
402 typename PretendImageType::Pointer fakeImage;
403 fakeImage = PretendImageType::New();
409 PretendSizeType PretendSize;
411 for (
SizeValueType i = 0; i < PretendSize.GetSizeDimension(); i++)
413 PretendSize[i] = OutSize[i + 1];
416 LineRegion.
SetSize(PretendSize);
417 fakeImage->SetRegions(LineRegion);
418 PretendSizeType kernelRadius;
419 kernelRadius.Fill(1);
420 LineNeighborhoodType lnit(kernelRadius, fakeImage, LineRegion);
422 if (wholeNeighborhood)
431 typename LineNeighborhoodType::IndexListType ActiveIndexes;
432 ActiveIndexes = lnit.GetActiveIndexList();
434 typename LineNeighborhoodType::IndexListType::const_iterator LI;
436 PretendIndexType idx = LineRegion.GetIndex();
439 for (LI = ActiveIndexes.begin(); LI != ActiveIndexes.end(); ++LI)
441 m_LineOffsets.push_back(fakeImage->ComputeOffset(idx + lnit.GetOffset(*LI)) - offset);
444 if (wholeNeighborhood)
461 const SizeValueType xsizeForThread = outputRegionForThread.GetSize()[0];
462 const SizeValueType numberOfLines = outputRegionForThread.GetNumberOfPixels() / xsizeForThread;
465 const SizeValueType lastLine = firstLine + numberOfLines - 1;
481 itkAssertInDebugAndIgnoreInReleaseMacro(lastLine >= wud.
lastLine);
492 if (neighIdx >= 0 && neighIdx < linecount && !
m_LineMap[neighIdx].empty())