mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-11 05:15:39 +08:00
Fix bug in grey erosion and dilation
This commit is contained in:
@@ -51,7 +51,7 @@ def dilate(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
rr = r + sr[s]
|
||||
cc = c + sc[s]
|
||||
if 0 <= rr < rows and 0 <= cc < cols:
|
||||
value = image_data[rr * rows + cc]
|
||||
value = image_data[rr * cols + cc]
|
||||
if value > local_max:
|
||||
local_max = value
|
||||
|
||||
@@ -85,7 +85,7 @@ def erode(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
cdef np.uint8_t* out_data = <np.uint8_t*>out.data
|
||||
cdef np.uint8_t* image_data = <np.uint8_t*>image.data
|
||||
|
||||
cdef int r, c, rr, cc, s, value, local_max
|
||||
cdef int r, c, rr, cc, s, value, local_min
|
||||
|
||||
cdef int selem_num = np.sum(selem != 0)
|
||||
cdef int* sr = <int*>malloc(selem_num * sizeof(int))
|
||||
@@ -106,7 +106,7 @@ def erode(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
rr = r + sr[s]
|
||||
cc = c + sc[s]
|
||||
if 0 <= rr < rows and 0 <= cc < cols:
|
||||
value = image_data[rr * rows + cc]
|
||||
value = image_data[rr * cols + cc]
|
||||
if value < local_min:
|
||||
local_min = value
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from numpy import testing
|
||||
|
||||
import skimage
|
||||
from skimage import data_dir
|
||||
from skimage.util import img_as_bool
|
||||
from skimage.morphology import binary, grey, selem
|
||||
|
||||
|
||||
@@ -157,28 +158,28 @@ class TestDTypes():
|
||||
def test_binary_erosion():
|
||||
strel = selem.square(3)
|
||||
binary_res = binary.binary_erosion(bw_lena, strel)
|
||||
grey_res = grey.erosion(bw_lena, strel)
|
||||
grey_res = img_as_bool(grey.erosion(bw_lena, strel))
|
||||
testing.assert_array_equal(binary_res, grey_res)
|
||||
|
||||
|
||||
def test_binary_dilation():
|
||||
strel = selem.square(3)
|
||||
binary_res = binary.binary_dilation(bw_lena, strel)
|
||||
grey_res = grey.dilation(bw_lena, strel)
|
||||
grey_res = img_as_bool(grey.dilation(bw_lena, strel))
|
||||
testing.assert_array_equal(binary_res, grey_res)
|
||||
|
||||
|
||||
def test_binary_closing():
|
||||
strel = selem.square(3)
|
||||
binary_res = binary.binary_closing(bw_lena, strel)
|
||||
grey_res = grey.closing(bw_lena, strel)
|
||||
grey_res = img_as_bool(grey.closing(bw_lena, strel))
|
||||
testing.assert_array_equal(binary_res, grey_res)
|
||||
|
||||
|
||||
def test_binary_opening():
|
||||
strel = selem.square(3)
|
||||
binary_res = binary.binary_opening(bw_lena, strel)
|
||||
grey_res = grey.opening(bw_lena, strel)
|
||||
grey_res = img_as_bool(grey.opening(bw_lena, strel))
|
||||
testing.assert_array_equal(binary_res, grey_res)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user