Skip to content

ENH: Ingest ITKGrowCut into Modules/Segmentation/GrowCut#6274

Open
hjmjohnson wants to merge 44 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:ingest-GrowCut
Open

ENH: Ingest ITKGrowCut into Modules/Segmentation/GrowCut#6274
hjmjohnson wants to merge 44 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:ingest-GrowCut

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Ingest the ITKGrowCut remote module into Modules/Segmentation/GrowCut (group: Segmentation). Source upstream: InsightSoftwareConsortium/ITKGrowCut. Tracking issue: #6160.

Ingest stats
  • Commits: 36 (including 2 merge commits -- Mode A topology preserved per Utilities/Maintenance/RemoteModuleIngest/INGESTION_STRATEGY.md)
  • Files installed under Modules/Segmentation/GrowCut/: 26
  • Approx. content size: 50 KiB
  • Tip SHA: 8b691c57ad4cd68e2dd4d5260b84bb1ed6cea001
External-data fixtures

CID / .sha512 content-links present in this ingest:

  • Modules/Segmentation/GrowCut/test/Baseline/DzZ_L1-label.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Baseline/DzZ_T1.seg.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Baseline/MedianResult.seg.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Baseline/NoisyResult.seg.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Baseline/itkFastGrowCutTestDzZ_L1-label.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Baseline/itkFastGrowCutTestDzZ_T1-label.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Baseline/itkFastGrowCutTestMedian-label.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Baseline/itkFastGrowCutTestNoisy-label.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Input/C0004255.mha.cid
  • Modules/Segmentation/GrowCut/test/Input/DzZ_L1.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Input/DzZ_L1_seeds-label.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Input/DzZ_Seeds.seg.nrrd.cid
  • Modules/Segmentation/GrowCut/test/Input/DzZ_T1_orig.nhdr.cid
  • Modules/Segmentation/GrowCut/test/Input/DzZ_T1_orig.raw.gz.cid
  • Modules/Segmentation/GrowCut/test/Input/Seeds.seg.nrrd.cid

If any fixtures resolve via ITKTestingData, that repo must contain the matching content-link before this PR can merge cleanly.

Follow-on commits (on top of the unrelated-histories merge)
  • 8b691c5 ENH: Enable GrowCut module in CI and remove remote stub
  • 5a1cbc5 ENH: Convert from md5 to .cid tags.
  • 35d4c33 COMP: Use modern macro for name of class
  • 365cc67 COMP: Comment unused variable
  • 3e7a8fe ENH: Bump ITK and replace http with https using script

dzenanz and others added 30 commits April 21, 2021 10:20
src\HeapNode.cc(45): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
It was removed in bc6ac80.

If the seeds all lay in a single plane,
no segmentation was produced. Closes #8.
Using the same type for labels as for image intensities
does not make much sense.
* use CMake v3.21.1 in CI
* add export DLL specifications to classes in FibHeap
* update README.rst to reflect Slicer-inspired refactoring
* add a missing Reset() method
The ability to include either .h or .hxx files as
header files required recursively reading the
.h files twice.  The added complexity is
unnecessary, costly, and can confuse static
analysis tools that monitor header guardes (due
to reaching the maximum depth of recursion
limits for nested #ifdefs in checking).
warning.

The resultLabelVolumePtr variable is declared with the same value
before and within the if statement. The second declaration was removed.

This resolves the following Compiler warning:
/localscratch/Users/kjweimer/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:295:24: warning: declaration of ‘resultLabelVolumePtr’ shadows a previous local [-Wshadow]
  295 |     LabelPixelType *   resultLabelVolumePtr = resultLabelVolume->GetBufferPointer();
      |                        ^~~~~~~~~~~~~~~~~~~~
/localscratch/Users/kjweimer/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:288:30: note: shadowed declaration is here
  288 |   LabelPixelType *           resultLabelVolumePtr = resultLabelVolume->GetBufferPointer();
      |                              ^~~~~~~~~~~~~~~~~~~~
Class member variables m_DimX, m_DimY, and m_DimZ were redeclared as instance variables
in a class function. This was changed to instead use the existing member variables.

This resolvs the following compiler shadowing warning:
/localscratch/Users/kjweimer/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:99:17: warning: declaration of ‘m_DimX’ shadows a member of ‘itk::FastGrowCut<itk::Image<short int, 3>, itk::Image<unsigned char, 3> >’ [-Wshadow]
   99 |   NodeIndexType m_DimX = region.GetSize(0);
      |                 ^~~~~~
In file included from /localscratch/Users/kjweimer/ITK/Modules/Remote/GrowCut/test/itkFastGrowCutTest.cxx:19:
/localscratch/Users/kjweimer/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.h:181:17: note: shadowed declaration is here
  181 |   NodeIndexType m_DimX;
      |                 ^~~~~~

(This warning is repeated for m_DimY and m_DimZ)
These `seedImage` and `compareTolerance` variables are only used within a code
block that is currently commented out. Alternatively, these variables could be
deleted if it is decided that the commented out code is no longer wanted.

This resolves the following compiler warnings:

/localscratch/Users/kjweimer/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:376:14: warning: unused variable ‘seedImage’ [-Wunused-variable]
  376 |   auto       seedImage = this->GetSeedImage();
      |              ^~~~~~~~~
/localscratch/Users/kjweimer/ITK/Modules/Remote/GrowCut/include/itkFastGrowCut.hxx:381:16: warning: unused variable ‘compareTolerance’ [-Wunused-variable]
  381 |   const double compareTolerance = (spacing[0] + spacing[1] + spacing[2]) / 3.0 * 0.01;
      |                ^~~~~~~~~~~~~~~~
@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Enhancement Improvement of existing methods or implementation area:Python wrapping Python bindings for a class type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Segmentation Issues affecting the Segmentation module area:Remotes Issues affecting the Remote module labels May 14, 2026
@hjmjohnson
Copy link
Copy Markdown
Member Author

@greptileai review this draft before I make it official

1 similar comment
@hjmjohnson
Copy link
Copy Markdown
Member Author

@greptileai review this draft before I make it official

@greptile-apps

This comment was marked as resolved.

Comment thread Modules/Segmentation/GrowCut/include/itkFastGrowCut.hxx
Comment thread Modules/Segmentation/GrowCut/include/itkFastGrowCut.hxx Outdated
Comment thread Modules/Segmentation/GrowCut/include/itkFastGrowCut.h Outdated
Comment thread Modules/Segmentation/GrowCut/src/FibHeap.cxx Outdated
Comment thread Modules/Segmentation/GrowCut/src/FibHeap.cxx
@greptile-apps

This comment was marked as resolved.

Comment thread Modules/Segmentation/GrowCut/include/itkFastGrowCut.hxx
Comment thread Modules/Segmentation/GrowCut/include/itkFastGrowCut.hxx Outdated
Comment thread Modules/Segmentation/GrowCut/include/itkFastGrowCut.hxx Outdated
Comment thread Modules/Segmentation/GrowCut/src/FibHeap.cxx Outdated
Drop unreachable null check after operator new (throws std::bad_alloc),
the unused ExtractITKImageROI helper, the unused itkImageMaskSpatialObject.h
include, and the corresponding ITKSpatialObjects module dependency.
The defaulted destructor leaked the raw owning pointers if the filter
was destroyed after InitializationAHP() allocated them, including on
exception unwind.
Replace bare OK/NOTOK macros with constexpr ints to avoid global-namespace
collisions with platform headers, guard the parent-index check against a
null theParent so the documented default Print() does not dereference null,
and drop the interactive cin>>ch wait that hung non-interactive callers.
@hjmjohnson
Copy link
Copy Markdown
Member Author

/azp run

The if(NOT ITK_SOURCE_DIR) branch (find_package(ITK) +
include(ITKModuleExternal)) only executes when building the module
standalone outside ITK. In-tree builds always take the
itk_module_impl() else branch. Drop the dead branch following the
cleanup pattern from InsightSoftwareConsortium#6272/InsightSoftwareConsortium#6279.
Copy link
Copy Markdown
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If memory serves me well, ExtractITKImageROI is used.

Comment thread Modules/Segmentation/GrowCut/itk-module.cmake Outdated
Comment thread Modules/Segmentation/GrowCut/include/itkFastGrowCut.hxx Outdated
Comment thread Modules/Segmentation/GrowCut/include/itkFastGrowCut.hxx Outdated
Replace the placeholder "Module ingested from upstream." with text
describing what the module does (Dijkstra/Fibonacci-heap seeded region
growing with optional masking and adaptive re-segmentation), per
reviewer feedback on PR InsightSoftwareConsortium#6274.
The IPFS gateway (dweb.link / w3s.link) returned HTTP 504 for these
7 CIDs during the Populate ExternalData CI step, blocking PR InsightSoftwareConsortium#6274.
The blobs themselves are present on data.kitware.com (verified via
hashsum/sha512 lookup), so switching the content link from CID to
SHA512 restores access via the Kitware mirror.

The SHA512 digests were recovered from commit 5a1cbc5 ("Convert
from md5 to .cid tags.") which had the prior .sha512 stubs in tree
before the cid migration.

Affected files:
  test/Input/Seeds.seg.nrrd
  test/Baseline/DzZ_L1-label.nrrd
  test/Baseline/DzZ_T1.seg.nrrd
  test/Baseline/MedianResult.seg.nrrd
  test/Baseline/NoisyResult.seg.nrrd
  test/Baseline/itkFastGrowCutTestMedian-label.nrrd
  test/Baseline/itkFastGrowCutTestNoisy-label.nrrd
@hjmjohnson
Copy link
Copy Markdown
Member Author

/azp run

@github-actions github-actions Bot added the type:Data Changes to testing data label May 14, 2026
KWStyle's per-module Header check scans src/*.cxx (not just itk*.cxx),
so FibHeap.cxx must carry the ITK Apache 2.0 banner. Add the same
banner to FibHeap.h for symmetry. The original John Boyer (1996)
attribution comment is preserved immediately below the new banner.

Fixes GrowCutKWStyleTest in the Pixi-Cxx CI matrix.
@hjmjohnson
Copy link
Copy Markdown
Member Author

/azp run

@hjmjohnson hjmjohnson marked this pull request as ready for review May 14, 2026 22:56
Comment on lines +397 to +403
Superclass::GenerateInputRequestedRegion();
if (this->GetInput())
{
typename InputImageType::Pointer input = const_cast<TInputImage *>(this->GetInput());
input->SetRequestedRegionToLargestPossibleRegion();
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Seed and mask inputs never have their requested region forced to LargestPossibleRegion. ImageToImageFilter::GenerateInputRequestedRegion() only propagates the output region to input 0 (the intensity image); inputs 1 and 2 are left with whatever region the pipeline previously assigned. If a seed or mask image is connected to a streaming-capable source (reader, upstream filter), only the sub-region that was requested gets buffered, and InitializationAHP() will then access seedLabelVolumePtr[index] / maskLabelVolumePtr[index] beyond the buffered extent, producing wrong results or a crash.

Suggested change
Superclass::GenerateInputRequestedRegion();
if (this->GetInput())
{
typename InputImageType::Pointer input = const_cast<TInputImage *>(this->GetInput());
input->SetRequestedRegionToLargestPossibleRegion();
}
}
Superclass::GenerateInputRequestedRegion();
if (this->GetInput())
{
typename InputImageType::Pointer input = const_cast<TInputImage *>(this->GetInput());
input->SetRequestedRegionToLargestPossibleRegion();
}
if (this->GetSeedImage())
{
auto seedImage = const_cast<LabelImageType *>(this->GetSeedImage());
seedImage->SetRequestedRegionToLargestPossibleRegion();
}
if (this->GetMaskImage())
{
auto maskImage = const_cast<MaskImageType *>(this->GetMaskImage());
maskImage->SetRequestedRegionToLargestPossibleRegion();
}
}

@dzenanz dzenanz requested a review from lassoan May 15, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Python wrapping Python bindings for a class area:Remotes Issues affecting the Remote module area:Segmentation Issues affecting the Segmentation module type:Data Changes to testing data type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants