Skip to content

Add corrmap operator for windowed correlation maps#1194

Open
tbensonatl wants to merge 2 commits into
mainfrom
tbenson/add-correlation-map-operator
Open

Add corrmap operator for windowed correlation maps#1194
tbensonatl wants to merge 2 commits into
mainfrom
tbenson/add-correlation-map-operator

Conversation

@tbensonatl
Copy link
Copy Markdown
Collaborator

Add the corrmap() operator, which computes 1D or 2D correlation maps. corrmap produces a per-sample or per-pixel measure of correlation between two signals or images (or, generically, tensors) over a small window local to each output sample. The output is the same size as the input. The 1D and 2D corrmap operators are differentiated by the rank of the window lengths provided to the operator. 2D correlation maps are common in SAR. For that use case, use the MAGNITUDE normalization type and take the abs() of the output to get the real-valued correlation values in the range [0, 1].

See the MatX documentation for full details of the corrmap() operator and normalization modes.

Add the corrmap() operator, which computes 1D or 2D correlation maps. corrmap
produces a per-sample or per-pixel measure of correlation between two signals
or images (or, generically, tensors) over a small window local to each output
sample. The output is the same size as the input. The 1D and 2D corrmap operators
are differentiated by the rank of the window lengths provided to the operator.
2D correlation maps are common in SAR. For that use case, use the MAGNITUDE
normalization type and take the abs() of the output to get the real-valued
correlation values in the range [0, 1].

See the MatX documentation for full details of the corrmap() operator and
normalization modes.

Signed-off-by: Thomas Benson <tbenson@nvidia.com>
@tbensonatl tbensonatl self-assigned this Jun 1, 2026
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Jun 1, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 1, 2026

Greptile Summary

This PR adds corrmap(), a new MatX operator that computes per-element windowed correlation maps in 1-D or 2-D. The operator supports three normalization modes (NONE, MAGNITUDE, ZNCC) via a compile-time template parameter, handles both real and complex floating-point inputs, and produces output with the same shape as the inputs.

  • Core operator (corrmap.h): Uses Welford's online algorithm for numerically stable ZNCC computation; NONE/MAGNITUDE use simple accumulators. Boundary windows are correctly cropped. JIT support embeds mode-sentinel values via std::format arguments derived from the enum rather than hardcoded literals.
  • Alias detection: ALIASED_MEMORY capability correctly sets permutes_input_output = true, preventing silent in-place corruption.
  • Tests: Cover all three modes against an independent two-pass CPU reference, self-coherence identity, ZNCC affine invariance, batched inputs, mixed type combinations, and alias-detection enforcement.

Confidence Score: 5/5

Safe to merge — the operator is purely additive, the math is correct for all three modes and both real/complex types, and the test suite independently validates the implementation.

All three normalization modes are mathematically sound. The Welford online algorithm for ZNCC is correctly applied for both real and complex inputs. JIT code generation uses enum-derived format arguments. Alias detection is properly configured. No existing operators or APIs are changed.

No files require special attention.

Important Files Changed

Filename Overview
include/matx/operators/corrmap.h New CorrMapOp operator implementing NONE, MAGNITUDE, and ZNCC modes with 1-D/2-D windows; Welford online algorithm for ZNCC correctly implemented for real and complex types; JIT code generation embeds enum sentinel values via std::format arguments; alias detection sets permutes_input_output = true.
test/00_operators/corrmap_test.cu Comprehensive tests covering all three modes against an independent two-pass CPU reference, self-coherence identity, ZNCC affine invariance, batched inputs, mixed types, and boundary/degenerate window cases.
test/00_operators/aliased_memory_test.cu Adds CorrMapAliasing test verifying that in-place assignment throws matxException, exercising the ALIASED_MEMORY capability path.
docs_input/api/stats/corr/corrmap.rst New RST documentation with doxygen directives, normalization mode descriptions, input type requirements, output type rules, window indexing convention, and three literate-include examples.
include/matx/operators/operators.h Single include added for corrmap.h, inserted alphabetically between corr.h and cov.h.

Reviews (2): Last reviewed commit: "Update JIT generation to pass CorrMapNor..." | Re-trigger Greptile

Comment thread include/matx/operators/corrmap.h Outdated
Comment thread include/matx/operators/corrmap.h
Signed-off-by: Thomas Benson <tbenson@nvidia.com>
@tbensonatl
Copy link
Copy Markdown
Collaborator Author

/build

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage is 93.635%tbenson/add-correlation-map-operator into main. No base build found for main.

@tbensonatl tbensonatl requested a review from cliffburdick June 1, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants