Skip to content

Fix edge-detection review findings (thresholding, physical gradients, UI)#13

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

Fix edge-detection review findings (thresholding, physical gradients, UI)#13
jacobson30-bot merged 1 commit into
mainfrom
edge-detection-fixes

Conversation

@jacobson30-bot
Copy link
Copy Markdown
Contributor

Follow-up to #12 addressing review findings.

Fixes

  • High — whole-image edge mask. Sobel/Scharr thresholding used magnitude >= cut; a zero percentile cutoff on flat/sparse-step images marked the zero-gradient background as edge. Now (magnitude >= cut) & (magnitude > 0).
  • High — pixel-space gradients. gradient_filter now takes pixel_size_x_nm/pixel_size_y_nm and scales gx/=dx, gy/=dy before hypot/arctan2; the viewer passes both spacings (was x-only), so anisotropic pixels give correct magnitude/orientation.
  • Medium — edge→ROI treated boundaries as areas. Added "Fill enclosed regions first" (default on) so thin boundary masks become solid area ROIs.
  • Medium — masks lost source context. Created masks record source_path / source_channel / data_basis (serialized to the sidecar).
  • Medium-low — replayable Sobel/Scharr not wired. The in-panel "Edge:" dropdown now offers Sobel/Scharr, connecting GUI → ProcessingState → replay end to end.
  • UI — dialog combos no longer truncate (AdjustToContents + min width on field and popup); spin-box arrows enlarged.

Verification

  • 1967 passed, 207 skipped, ruff check clean.
  • New regression tests: zero-cutoff thresholding (flat → 0 edges, sparse step → <50%), physical-gradient scaling (anisotropic rotates orientation; isotropic is a no-op), and the replayable Sobel/Scharr chain through the GUI adapter.

🤖 Generated with Claude Code

Addresses review findings on the merged Advanced Edge Detection feature:

- High: Sobel/Scharr mask thresholding no longer marks the whole image as an
  edge. A zero percentile cutoff used `magnitude >= cut`, so zero-gradient
  background became True on flat/sparse-step images. Now requires a strictly
  positive gradient: `(magnitude >= cut) & (magnitude > 0)`.
- High: gradient magnitude/orientation are now physical-space. gradient_filter
  accepts pixel_size_x_nm/pixel_size_y_nm and scales gx/=dx, gy/=dy before
  hypot/arctan2; the viewer passes both spacings (was x-only), so anisotropic
  pixels yield correct values.
- Medium: edge->ROI conversion adds a "Fill enclosed regions first" option
  (default on) so thin boundary masks become solid area ROIs.
- Medium: created masks record source_path/source_channel/data_basis so a
  processed-channel mask is not mistaken for raw-derived later (serialized).
- Medium-low: the in-panel "Edge:" dropdown now offers Sobel/Scharr, wiring the
  history-replayable path end to end (GUI -> ProcessingState -> replay).
- UI: edge-detection dialog combos no longer truncate (AdjustToContents + min
  width on field and popup) and spin-box arrows are enlarged.

Adds regression tests for the thresholding fix, physical-gradient scaling, and
the replayable Sobel/Scharr chain. Full suite green, ruff clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jacobson30-bot jacobson30-bot merged commit 9ec7352 into main Jun 5, 2026
3 checks passed
@jacobson30-bot jacobson30-bot deleted the edge-detection-fixes branch June 5, 2026 14:43
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