Skip to content

Add edge detection filters (Sobel, Laplacian, Prewitt)#1042

Merged
brendancol merged 6 commits intomasterfrom
issue-1038
Mar 21, 2026
Merged

Add edge detection filters (Sobel, Laplacian, Prewitt)#1042
brendancol merged 6 commits intomasterfrom
issue-1038

Conversation

@brendancol
Copy link
Contributor

Summary

  • New xrspatial/edge_detection.py module with five functions: sobel_x, sobel_y, laplacian, prewitt_x, prewitt_y
  • Each wraps convolve_2d with a fixed 3x3 kernel, so all four backends (NumPy, CuPy, Dask+NumPy, Dask+CuPy) come for free
  • 72 tests for correctness, NaN handling, edge cases, boundary modes, and cross-backend equivalence
  • User guide notebook (35_Edge_Detection.ipynb) with terrain demos, Sobel vs Prewitt comparison, edge magnitude, and boundary mode visualization
  • API docs in docs/source/reference/focal.rst and README feature matrix updated

Closes #1038

Test plan

  • pytest xrspatial/tests/test_edge_detection.py passes (72 tests)
  • Verify notebook renders correctly in JupyterLab
  • Spot-check GPU backends if CUDA hardware is available

@github-actions github-actions bot added the performance PR touches performance-sensitive code label Mar 20, 2026
Five new functions (sobel_x, sobel_y, laplacian, prewitt_x, prewitt_y)
that wrap convolution_2d with fixed 3x3 kernels. All four backends
(NumPy, CuPy, Dask+NumPy, Dask+CuPy) are inherited from the existing
convolution infrastructure.
72 tests covering correctness, NaN handling, edge cases, boundary modes,
and cross-backend (NumPy, Dask, CuPy) equivalence.
Covers sobel_x, sobel_y, laplacian, prewitt_x, prewitt_y with
synthetic terrain, directional gradients, edge magnitude, Sobel
vs Prewitt comparison, and boundary mode visualization.
Registers sobel_x, sobel_y, laplacian, prewitt_x, prewitt_y on both
the DataArray and Dataset xrs accessors.
@brendancol brendancol merged commit 9a38f2d into master Mar 21, 2026
11 checks passed
@brendancol brendancol deleted the issue-1038 branch March 25, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add edge detection filters (Sobel, Laplacian, Prewitt)

1 participant