Skip to content

ENH: Ingest ITKRLEImage into Modules/Filtering#6208

Merged
hjmjohnson merged 122 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:ingest-rleimage
May 5, 2026
Merged

ENH: Ingest ITKRLEImage into Modules/Filtering#6208
hjmjohnson merged 122 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:ingest-rleimage

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Ingests RLEImage from the standalone remote module KitwareMedical/ITKRLEImage into ITK at Modules/Filtering/RLEImage/. Branch is based directly on upstream/main and contains no v4-tooling files in its diff — independently mergeable.

Local validation: pre-commit run --all-files clean; RLEImageTestDriver builds; 45/45 RLEImage tests pass locally (after ExternalData fetches ~30 .cid content links).

What this provides

RLEImage is a memory-efficient run-length-encoded image type — a drop-in alternative to itk::Image for storing large label volumes (segmentation masks). The flagship template is itk::RLEImage<TPixel, VImageDimension, CounterType>, with iterator and filter specializations that operate directly on the encoded representation without decompression.

Path: Modules/Filtering/RLEImage/ — chosen because the module's library DEPENDS ITKImageGrid (a Filtering-group module), which precludes a Modules/Core/ placement.

Pipeline metrics
Metric Value
Upstream commits → rewritten 158 → 112
Upstream merges → preserved 36 → 27 (no linearization)
Blobs scanned in sanitize 504 (cxx=364, py=0, cmake=30, text=40, skip=70)
Blobs reformatted 328 (clang-format / gersemi / trailing-ws / EOF)
Commit subjects auto-prefixed 60
Subjects truncated to 78 chars 4
Blank lines inserted 54
README.rst → README.md rewrites in itk-module.cmake 2
Subtree merges visible in git log -- Modules/Filtering/RLEImage 2
Dependencies

The module library and tests depend only on ITK core modules — no remote-module dependencies:

  • DEPENDS (library): ITKImageGrid
  • TEST_DEPENDS: ITKTestKernel

EXCLUDE_FROM_DEFAULT is set on the module so it does not auto-build unless Module_RLEImage:BOOL=ON is passed (matching upstream behavior).

Companion module

Modules/Filtering/MorphologicalContourInterpolation/ (still a remote
module on upstream/main as of this writing) has an optional
TEST_DEPENDS on RLEImage. Once this PR merges and that module is
also brought in-tree, MCI's RLEImage-flavored tests will be reachable.
A follow-up MCI ingest PR will stack on this one.

Follow-up commits in this PR

After the merge commit (ENH: Ingest ITKRLEImage into Modules/Filtering):

  • STYLE: Apply gersemi 0.19.3 to RLEImage wrapping test CMakeLists. The v4 sanitize pass uses gersemi 0.24.0; ITK's pre-commit pins 0.19.3. The post-merge pre-commit run --all-files gate caught one CMake file where the two versions disagree.
  • DOC: Add Modules/Filtering/RLEImage/README.md pointing at the archived upstream.
  • COMP: Remove Modules/Remote/RLEImage.remote.cmake (now in-tree).
  • ENH: Enable Module_RLEImage:BOOL=ON in pyproject.toml configure-ci.

The v4 sanitize automatically rewrote file(READ "${...}/README.rst" DOCUMENTATION) in itk-module.cmake to read README.md instead — no manual COMP patch was needed.

Phase B (upstream archival) — deferred

Per the v4 design (PR #6204), the upstream archival step is intentionally separated. After this PR merges into ITK main, run:

~/src/ITK/Utilities/Maintenance/RemoteModuleIngest/archive-remote-module.sh \
    RLEImage --itk-pr-number <THIS-PR>

That step pushes the deletion + MIGRATION_README.md → README.md promotion to upstream and flips archived=true. This PR makes no upstream changes; the upstream ITKRLEImage repository remains live until the operator manually runs Phase B.

dzenanz and others added 30 commits July 15, 2016 11:53
Coding style more adhering to ITK style guide
Adding RLEImage specific tests
Trying to resolve build failures in the main repository
Applying uncrustify with ITK's aggressive style configuration
… built

This should prevent failures of automatic build tests on dashboards
Fixing the linking errors for tests when default modules are not built
@github-actions github-actions Bot added the type:Data Changes to testing data label May 4, 2026
@hjmjohnson hjmjohnson marked this pull request as ready for review May 5, 2026 01:07
@greptile-apps

This comment was marked as resolved.

Comment thread Modules/Filtering/RLEImage/include/itkRLEImage.h Outdated
Comment thread Modules/Filtering/RLEImage/include/itkRLEImageConstIterator.h
Comment thread Modules/Filtering/RLEImage/include/itkRLEImage.hxx
Comment thread Modules/Filtering/RLEImage/test/CMakeLists.txt
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 5, 2026
…terns

Add a 'Known artifacts at PR-review time' section to capture two
things future ingest operators need to expect but that v3/v4 do not
fix automatically:

  - The single ghostflow-check-main 'root commit not allowed' error
    that every Mode-A merge produces.  Maintainers override at merge.
    Calling it out keeps operators from chasing a non-fix.

  - A short table of code-level patterns Greptile has flagged
    post-ingest on multiple modules (IOMeshSTL InsightSoftwareConsortium#6206, RLEImage InsightSoftwareConsortium#6208):
    signed-vs-unsigned size types, missing override, dead return after
    itkExceptionMacro, stray test args, external-friend declarations,
    GetBuffer-const correctness, and allocator-init invariants.

The table is the durable channel for cross-ingest review knowledge —
extend it as new recurring patterns surface.
@hjmjohnson hjmjohnson added this to the ITK 6.0 Release Candidate 1 milestone May 5, 2026
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.

Mostly looks good. Let's give some time to our friends from ITK-SNAP project to review this, as they are the main users of this module. If we want to move faster, we could leave friend declarations in place.

Comment thread Modules/Filtering/RLEImage/include/itkRLEImageConstIterator.h Outdated
@hjmjohnson hjmjohnson requested a review from dzenanz May 5, 2026 17:29
hjmjohnson and others added 10 commits May 5, 2026 14:50
Brings RLEImage from a configure-time remote fetch into the ITK
source tree at Modules/Filtering/RLEImage/ using the v4 ingestion
pipeline (whitelist filter-repo + per-commit clang-format + black +
commit-prefix sanitization).

Upstream repo:  https://github.com/KitwareMedical/ITKRLEImage.git
Upstream tip:   03d1d9b5868d9f43bb4066637034cd667922cab9
Ingest date:    2026-05-04
Whitelist:      RLEImage.list

Per-commit transforms applied across all 112 commits:
  - filter-repo --paths-from-file (whitelist)
  - filter-repo --to-subdirectory-filter Modules/Filtering/RLEImage
  - clang-format -style=file (ITK main's .clang-format) for *.cxx/.h/.hxx/...
  - black for *.py
  - heuristic ITK prefix added to commit subjects without one

Merge topology preserved: 36 -> 26 merge(s).

Primary author: Dženan Zukić <dzenan.zukic@kitware.com>

Co-authored-by: Dzenan Zukic <dzenan.zukic@kitware.com>
Co-authored-by: Francois Budin <francois.budin@gmail.com>
Co-authored-by: Francois Budin <francois.budin@kitware.com>
Co-authored-by: Hans J. Johnson <hans-johnson@uiowa.edu>
Co-authored-by: Hans Johnson <hans-johnson@uiowa.edu>
Co-authored-by: Jon Haitz Legarreta <jhlegarreta@vicomtech.org>
Co-authored-by: Jon Haitz Legarreta Gorroño <jon.haitz.legarreta@gmail.com>
Co-authored-by: Mathew J. Seng <mathewseng@gmail.com>
Co-authored-by: Mathew Seng <mathewseng@gmail.com>
Co-authored-by: Matt McCormick <matt.mccormick@kitware.com>
Co-authored-by: Matt McCormick <matt@mmmccormick.com>
Co-authored-by: Stephen R. Aylward <stephen.aylward@kitware.com>
Co-authored-by: Tom Birdsong <tom.birdsong@kitware.com>
C++17 class-template-argument-deduction synthesizes implicit guides
only from the primary class template; the partial specializations
ImageRegionConstIterator<RLEImage<...>> and ImageRegionIterator<
RLEImage<...>> need explicit deduction guides so generic ITK code
that calls the unparameterized form

    ImageRegionConstIterator it(image, region);

can be instantiated when image is an RLEImage.  Without these guides,
the call in itkImageAlgorithm.hxx (and any other CTAD-using ITK core
code) fails to compile when downstream code instantiates the algorithm
template against an RLEImage type.  The same generic call already
works for the primary itk::Image<T,N> case because CTAD synthesizes
guides from the primary template's constructors.

Surfaced when wiring up MorphologicalContourInterpolation's
RLEImage-flavored test which uses itkImageFileWriter.h
-> itkImageAlgorithm.hxx with RLEImage instantiations.
The const overload returned a non-const SmartPointer to m_Buffer,
allowing callers holding a const RLEImage to mutate the underlying
RLE line buffer. Return BufferType::ConstPointer so the const overload
preserves const semantics.
The itk_add_test for itkRLEImageIteratorTest passed
itkRLEImageIteratorWithIndexTest as a second positional argument.
Test drivers forward argv[2..n] to the function named in argv[1]; they
do not invoke a second function. The withIndex test still runs via its
own registration so coverage is unchanged.
…mage

In-tree, ITK_SOURCE_DIR is always defined and ITK's top-level
CMakeLists pins the CMake minimum version.  The per-module
cmake_minimum_required line and if(NOT ITK_SOURCE_DIR) ... else()
itk_module_impl() endif() guard are dead code.  Pre-emptive cleanup
matching the v4 ingest-pipeline rules codified in PR InsightSoftwareConsortium#6204
(sanitize-history.py:patch_drop_cmake_minimum_required and
:patch_standalone_build_guard).
Add itkRLEImageMultiLabelMeshPipelineFriendTest, an in-tree witness
that the `friend class ::MultiLabelMeshPipeline;` grants on
itk::ImageConstIterator<itk::RLEImage<...>> and
itk::ImageRegionConstIterator<itk::RLEImage<...>> are still in place.

The test defines a stub `MultiLabelMeshPipeline` at global scope (the
same name and namespace as the friend declarations target) and reads
several of the iterator's protected scan-line bookkeeping members
(m_Index0 / m_BeginIndex0 / m_EndIndex0 / m_RealIndex /
m_SegmentRemainder).  If a future cleanup ever removes the friendship
the test fails to compile, surfacing the regression at build time.

The downstream consumer this protects is ITK-SNAP's
MultiLabelMeshPipeline, which uses direct access to those iterator
internals for its multi-label surface-extraction performance path.
Removing the friendship would silently break that build with no
warning from this module's own test suite.
@hjmjohnson hjmjohnson enabled auto-merge May 5, 2026 21:45
@hjmjohnson hjmjohnson disabled auto-merge May 5, 2026 21:46
@hjmjohnson hjmjohnson merged commit 11c2f38 into InsightSoftwareConsortium:main May 5, 2026
16 of 19 checks passed
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 6, 2026
…est-rleimage

ENH: Ingest ITKRLEImage into Modules/Filtering
hjmjohnson added a commit that referenced this pull request May 7, 2026
ENH: Ingest ITKMorphologicalContourInterpolation (stacked on #6208)
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request May 7, 2026
…terns

Add a 'Known artifacts at PR-review time' section to capture two
things future ingest operators need to expect but that v3/v4 do not
fix automatically:

  - The single ghostflow-check-main 'root commit not allowed' error
    that every Mode-A merge produces.  Maintainers override at merge.
    Calling it out keeps operators from chasing a non-fix.

  - A short table of code-level patterns Greptile has flagged
    post-ingest on multiple modules (IOMeshSTL InsightSoftwareConsortium#6206, RLEImage InsightSoftwareConsortium#6208):
    signed-vs-unsigned size types, missing override, dead return after
    itkExceptionMacro, stray test args, external-friend declarations,
    GetBuffer-const correctness, and allocator-init invariants.

The table is the durable channel for cross-ingest review knowledge —
extend it as new recurring patterns surface.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Filtering Issues affecting the Filtering module area:Python wrapping Python bindings for a class area:Remotes Issues affecting the Remote 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.

8 participants