Skip to content

Address inverse-FFT / edge-detection review findings#15

Merged
jacobson30-bot merged 1 commit into
mainfrom
edge-fft-review-fixes
Jun 5, 2026
Merged

Address inverse-FFT / edge-detection review findings#15
jacobson30-bot merged 1 commit into
mainfrom
edge-fft-review-fixes

Conversation

@jacobson30-bot
Copy link
Copy Markdown
Contributor

Fresh review pass over the inverse-FFT and edge-detection modules.

inverse_fft.py (minor)

  • Moved from dataclasses import replace out of the per-region loop in fourier_region_mask to module scope.
  • Typed FourierStrokes.stamps as tuple[tuple[float, float], ...].

(Even-N Nyquist conjugate limitation and the O(stamps × pixels) stroke cost were reviewed and left as-is — the former is documented and surfaced via imag_residual_norm, the latter is fine for typical brush counts.)

edge_detection.py — gradient_filter

  • Medium — no more fabricated edges at NaN borders. Mean-filling non-finite pixels steps the hole rim, so every pixel whose 3×3 operator footprint touches a NaN had a spurious gradient (~15× baseline) while only the NaN pixels themselves were excluded. Now the NaN mask is dilated by the 3×3 footprint and that band is nulled (magnitude→0, orientation→NaN, display→NaN) before normalisation/thresholding, and excluded from the edge mask.
  • Low — orientation sentinel. ROI/invalid regions now use NaN for orientation instead of 0.0 (a valid +x direction that conflated "no data" with "horizontal").
  • Low — convention documented. gradient_orientation is in image coordinates (row axis points down), noted on both the function and EdgeDetectionResult.

Verification

  • 1971 passed, 207 skipped, ruff check clean.
  • New regression tests: NaN-border exclusion, clean-image no-op, NaN orientation sentinel outside ROI.

🤖 Generated with Claude Code

inverse_fft.py:
- Move `from dataclasses import replace` to module scope (was imported inside
  the per-region loop in fourier_region_mask).
- Type FourierStrokes.stamps as tuple[tuple[float, float], ...].

edge_detection.py (gradient_filter):
- Medium: stop fabricating edges at NaN-region borders. Mean-filling non-finite
  pixels steps the hole rim, so every pixel whose 3x3 operator footprint touches
  a NaN had a spurious gradient (~15x baseline) while only the NaN pixels
  themselves were excluded. Now dilate the NaN mask by the 3x3 footprint and
  null that band (magnitude->0, orientation->NaN, display->NaN) before
  normalisation/thresholding, and drop it from the edge mask.
- Low: ROI/invalid regions use a NaN orientation sentinel instead of 0.0
  (which is a valid +x direction and conflated "no data" with "horizontal").
- Low: document that gradient_orientation is in image coordinates (row axis
  points down), not the math/physical y-up convention.

Adds regression tests: NaN-border exclusion, clean-image no-op, NaN orientation
sentinel outside ROI. Full suite green, ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jacobson30-bot jacobson30-bot merged commit eb872bc into main Jun 5, 2026
3 checks passed
@jacobson30-bot jacobson30-bot deleted the edge-fft-review-fixes branch June 5, 2026 15:04
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