Skip to content

Commit

Permalink
Fix Laplacian filter wrong sign #7357
Browse files Browse the repository at this point in the history
  • Loading branch information
pitkajuh authored and pitkajuh committed Apr 13, 2024
1 parent 7ae4fd8 commit d2ae37c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions skimage/filters/tests/test_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,11 @@ def test_laplace_zeros():
[
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0],
[0.0, 0.0, -1.0, 2.0, 1.0, 2.0, -1.0, 0.0, 0.0],
[0.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, 0.0],
[0.0, 0.0, -1.0, 2.0, 1.0, 2.0, -1.0, 0.0, 0.0],
[0.0, 0.0, 0.0, -1.0, -1.0, -1.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 1.0, -2.0, -1.0, -2.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, -1.0, 0.0, -1.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, -2.0, -1.0, -2.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
]
Expand Down
6 changes: 3 additions & 3 deletions skimage/restoration/uft.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def laplacian(ndim, shape, is_real=True):
Examples
--------
>>> tf, ir = laplacian(2, (32, 32))
>>> np.all(ir == np.array([[0, -1, 0], [-1, 4, -1], [0, -1, 0]]))
>>> np.all(ir == np.array([[0, 1, 0], [1, -4, 1], [0, 1, 0]]))
True
>>> np.all(tf == ir2tf(ir, (32, 32)))
True
Expand All @@ -444,8 +444,8 @@ def laplacian(ndim, shape, is_real=True):
idx = tuple(
[slice(1, 2)] * dim + [slice(None)] + [slice(1, 2)] * (ndim - dim - 1)
)
impr[idx] = np.array([-1.0, 0.0, -1.0]).reshape(
impr[idx] = np.array([1.0, 0.0, 1.0]).reshape(
[-1 if i == dim else 1 for i in range(ndim)]
)
impr[(slice(1, 2),) * ndim] = 2.0 * ndim
impr[(slice(1, 2),) * ndim] = -2.0 * ndim
return ir2tf(impr, shape, is_real=is_real), impr

0 comments on commit d2ae37c

Please sign in to comment.