Skip to content

Extend the native Gaussian blur kernel to per-channel (H,W,C) blurs - #27

Merged
hd152 merged 1 commit into
mainfrom
gaussian-blur-per-channel
Sep 22, 2026
Merged

hd152 merged 1 commit into
mainfrom
gaussian-blur-per-channel

Conversation

@hd152

@hd152 hd152 commented Sep 22, 2026

Copy link
Copy Markdown
Owner

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) and exposure_fusion.py's Laplacian pyramid (--hdr-blend-mode fusion).

  • New gaussian_blur_spatial loops the existing native kernel per channel — no new Rust code, same pattern postprocess.py's _median_filter_per_channel already uses.
  • Measured ~2.8x at a real full-resolution shape (495.6ms → 177.7ms, sigma=1.5).
  • Left 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

  • Full suite passes (1655 tests)
  • ruff check . clean
  • 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 (it had no existing test at all)

🤖 Generated with Claude Code

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>
@hd152
hd152 merged commit 267c39c into main Sep 22, 2026
7 checks passed
@hd152
hd152 deleted the gaussian-blur-per-channel branch September 22, 2026 21:25
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.

1 participant