MCPcopy Create free account
hub / github.com/MITK/MITK / FillRegion

Method FillRegion

Modules/Segmentation/src/Algorithms/mitkCorrectorAlgorithm.cpp:394–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

392}
393
394int mitk::CorrectorAlgorithm::FillRegion(
395 const std::vector<itk::Index<2>> &seedPoints,
396 itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer pic)
397{
398 int numberOfPixel = 0;
399 int mode = (pic->GetPixel(seedPoints[0]) == m_FillColor);
400 int drawColor = m_FillColor;
401 if (mode)
402 {
403 drawColor = m_EraseColor;
404 }
405
406 std::vector<itk::Index<2>> workPoints;
407 workPoints = seedPoints;
408 // workPoints.push_back(seedPoints[0]);
409 while (workPoints.size() > 0)
410 {
411 itk::Index<2> currentIndex = workPoints.back();
412 workPoints.pop_back();
413 if ((pic->GetPixel(currentIndex) == m_FillColor) == mode)
414 ++numberOfPixel;
415 pic->SetPixel(currentIndex, drawColor);
416
417 currentIndex = ensureIndexInImage(currentIndex[0] - 1, currentIndex[1]);
418 if (pic->GetLargestPossibleRegion().IsInside(currentIndex) && (pic->GetPixel(currentIndex) == m_FillColor) == mode)
419 workPoints.push_back(currentIndex);
420
421 currentIndex = ensureIndexInImage(currentIndex[0] + 2, currentIndex[1]);
422 if (pic->GetLargestPossibleRegion().IsInside(currentIndex) && (pic->GetPixel(currentIndex) == m_FillColor) == mode)
423 workPoints.push_back(currentIndex);
424
425 currentIndex = ensureIndexInImage(currentIndex[0] - 1, currentIndex[1] - 1);
426
427 if (pic->GetLargestPossibleRegion().IsInside(currentIndex) && (pic->GetPixel(currentIndex) == m_FillColor) == mode)
428 workPoints.push_back(currentIndex);
429
430 currentIndex = ensureIndexInImage(currentIndex[0], currentIndex[1] + 2);
431 if (pic->GetLargestPossibleRegion().IsInside(currentIndex) && (pic->GetPixel(currentIndex) == m_FillColor) == mode)
432 workPoints.push_back(currentIndex);
433 }
434
435 return numberOfPixel;
436}
437
438void mitk::CorrectorAlgorithm::OverwriteImage(
439 itk::Image<mitk::CorrectorAlgorithm::DefaultSegmentationDataType, 2>::Pointer source,

Callers

nothing calls this directly

Calls 4

backMethod · 0.80
pop_backMethod · 0.80
sizeMethod · 0.45
IsInsideMethod · 0.45

Tested by

no test coverage detected