Skip to content

Commit 9a38f2d

Browse files
authored
Add edge detection filters (Sobel, Laplacian, Prewitt) (#1042)
* Add edge detection filters: Sobel, Laplacian, Prewitt (#1038) 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. * Add tests for edge detection filters (#1038) 72 tests covering correctness, NaN handling, edge cases, boundary modes, and cross-backend (NumPy, Dask, CuPy) equivalence. * Add edge detection filters to focal docs (#1038) * Add edge detection user guide notebook (#1038) 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. * Add edge detection filters to README feature matrix (#1038) * Add edge detection methods to .xrs accessor (#1038) Registers sobel_x, sobel_y, laplacian, prewitt_x, prewitt_y on both the DataArray and Dataset xrs accessors.
1 parent 35d8253 commit 9a38f2d

File tree

8 files changed

+978
-0
lines changed

8 files changed

+978
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,11 @@ write_vrt('mosaic.vrt', ['tile1.tif', 'tile2.tif']) # generate VRT
347347
| [Focal Statistics](xrspatial/focal.py) | Computes summary statistics over a sliding neighborhood window | Standard | ✅️ | ✅️ | ✅️ | ✅️ |
348348
| [Bilateral](xrspatial/bilateral.py) | Feature-preserving smoothing via bilateral filtering | Tomasi & Manduchi 1998 | ✅️ | ✅️ | ✅️ | ✅️ |
349349
| [GLCM Texture](xrspatial/glcm.py) | Computes Haralick GLCM texture features over a sliding window | Haralick et al. 1973 | ✅️ | ✅️ | 🔄 | 🔄 |
350+
| [Sobel X](xrspatial/edge_detection.py) | Horizontal gradient via Sobel operator (detects vertical edges) | Sobel & Feldman 1968 | ✅️ | ✅️ | ✅️ | ✅️ |
351+
| [Sobel Y](xrspatial/edge_detection.py) | Vertical gradient via Sobel operator (detects horizontal edges) | Sobel & Feldman 1968 | ✅️ | ✅️ | ✅️ | ✅️ |
352+
| [Laplacian](xrspatial/edge_detection.py) | Omnidirectional second-derivative edge detector | Standard | ✅️ | ✅️ | ✅️ | ✅️ |
353+
| [Prewitt X](xrspatial/edge_detection.py) | Horizontal gradient via Prewitt operator (detects vertical edges) | Prewitt 1970 | ✅️ | ✅️ | ✅️ | ✅️ |
354+
| [Prewitt Y](xrspatial/edge_detection.py) | Vertical gradient via Prewitt operator (detects horizontal edges) | Prewitt 1970 | ✅️ | ✅️ | ✅️ | ✅️ |
350355

351356
-------
352357

docs/source/reference/focal.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ GLCM Texture
4141
xrspatial.glcm.glcm_texture
4242

4343

44+
Edge Detection
45+
==============
46+
.. autosummary::
47+
:toctree: _autosummary
48+
49+
xrspatial.edge_detection.sobel_x
50+
xrspatial.edge_detection.sobel_y
51+
xrspatial.edge_detection.laplacian
52+
xrspatial.edge_detection.prewitt_x
53+
xrspatial.edge_detection.prewitt_y
54+
55+
4456
Focal Statistics
4557
================
4658
.. autosummary::

0 commit comments

Comments
 (0)