mirror of
https://github.com/wassname/scikit-image.git
synced 2026-10-03 12:50:25 +08:00
Use sobel for image derivatives
This commit is contained in:
1 parent
e26dc02ead
commit
4366462033
1 file changed
+3
-6
@@ -5,7 +5,7 @@ from . import peak
|
||||
|
||||
|
||||
def _compute_derivatives(image):
|
||||
"""Compute derivatives in x and y direction.
|
||||
"""Compute derivatives in x and y direction using the Sobel operator.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
@@ -19,11 +19,8 @@ def _compute_derivatives(image):
|
||||
|
||||
"""
|
||||
|
||||
gradient_weights = np.array([-1, 0, 1])
|
||||
imx = ndimage.convolve1d(image, gradient_weights, axis=0,
|
||||
mode='constant', cval=0)
|
||||
imy = ndimage.convolve1d(image, gradient_weights, axis=1,
|
||||
mode='constant', cval=0)
|
||||
imx = ndimage.sobel(image, axis=0, mode='constant', cval=0)
|
||||
imy = ndimage.sobel(image, axis=1, mode='constant', cval=0)
|
||||
|
||||
return imx, imy
|
||||
|
||||
|
||||
Reference in new issue
Block a user