From a3844181dc2b40ef3e8aa7ef10bce0d480e50afd Mon Sep 17 00:00:00 2001 From: pitkajuh Date: Wed, 3 Apr 2024 17:33:57 +0300 Subject: [PATCH] Fix Laplacian filter wrong sign #7357 --- skimage/filters/tests/test_edges.py | 10 +++++----- skimage/restoration/uft.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/skimage/filters/tests/test_edges.py b/skimage/filters/tests/test_edges.py index 85ccfd002e9..9b605fc51e5 100644 --- a/skimage/filters/tests/test_edges.py +++ b/skimage/filters/tests/test_edges.py @@ -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], ] diff --git a/skimage/restoration/uft.py b/skimage/restoration/uft.py index db4bc16ad15..c599eb3bac4 100644 --- a/skimage/restoration/uft.py +++ b/skimage/restoration/uft.py @@ -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