Extend the native Gaussian blur kernel to per-channel (H,W,C) blurs - #27
Merged
Merged
Conversation
The earlier Gaussian blur kernel only covered a scalar sigma on a 2-D plane, so this codebase's sigma=(s, s, 0) call sites -- blur each channel independently, never across channels -- stayed on scipy. Two of them are real: denoising.py::reduce_stars (a default Phase 4 step, --no-star-reduce to disable) and exposure_fusion.py's Laplacian-pyramid blur (--hdr-blend-mode fusion). New gaussian_blur_spatial loops the existing native kernel per channel -- same per-channel-native-call pattern postprocess.py's _median_filter_per_channel already uses, no new Rust code needed. Measured ~2.8x at a real full-resolution (2033,3041,3) shape, sigma=1.5 (495.6ms -> 177.7ms) -- lower than the 2-D kernel's own ~4x at that sigma since each channel still pays native-call overhead separately. Left originvision_infer.py's resize prefilter alone: same tuple-sigma pattern, but it has its own tight numeric tolerances already validated against a reference implementation (cv2), and swapping its blur would add unvalidated drift for no clear benefit. 4 new tests (gaussian_blur_spatial parity vs scipy, 2-D passthrough, non-3-axis fallback, and an end-to-end pin of reduce_stars's real output against the original raw scipy call -- it had no existing test). Full suite (1655 tests) passes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #22's Gaussian blur kernel, which only covered a scalar sigma on a 2-D plane. This codebase's
sigma=(s, s, 0)call sites (blur each channel independently, never across channels) stayed on scipy — two of them real:denoising.py::reduce_stars(a default Phase 4 step) andexposure_fusion.py's Laplacian pyramid (--hdr-blend-mode fusion).gaussian_blur_spatialloops the existing native kernel per channel — no new Rust code, same patternpostprocess.py's_median_filter_per_channelalready uses.originvision_infer.py's resize prefilter alone — same tuple-sigma pattern, but it has its own tight numeric tolerances already validated against cv2, and swapping its blur would add unvalidated drift for no clear benefit.Test plan
ruff check .cleangaussian_blur_spatialparity vs scipy, 2-D passthrough, non-3-axis fallback, and an end-to-end pin ofreduce_stars's real output (it had no existing test at all)🤖 Generated with Claude Code