mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-09 03:45:47 +08:00
Merge pull request #1 from ahojnnes/thouis-master
Add test case for rank filter fix
This commit is contained in:
@@ -36,7 +36,7 @@ __all__ = ['bilateral_mean', 'bilateral_pop']
|
||||
|
||||
|
||||
def _apply(func8, func16, image, selem, out, mask, shift_x, shift_y, s0, s1):
|
||||
selem = img_as_ubyte(selem)
|
||||
selem = img_as_ubyte(selem > 0)
|
||||
image = np.ascontiguousarray(image)
|
||||
|
||||
if mask is None:
|
||||
|
||||
@@ -35,7 +35,7 @@ __all__ = ['percentile_autolevel', 'percentile_gradient',
|
||||
|
||||
|
||||
def _apply(func8, func16, image, selem, out, mask, shift_x, shift_y, p0, p1):
|
||||
selem = img_as_ubyte(selem)
|
||||
selem = img_as_ubyte(selem > 0)
|
||||
image = np.ascontiguousarray(image)
|
||||
|
||||
if mask is None:
|
||||
|
||||
@@ -28,7 +28,7 @@ __all__ = ['autolevel', 'bottomhat', 'equalize', 'gradient', 'maximum', 'mean',
|
||||
|
||||
|
||||
def _apply(func8, func16, image, selem, out, mask, shift_x, shift_y):
|
||||
selem = img_as_ubyte(selem)
|
||||
selem = img_as_ubyte(selem > 0)
|
||||
image = np.ascontiguousarray(image)
|
||||
|
||||
if mask is None:
|
||||
|
||||
@@ -376,5 +376,25 @@ def test_entropy():
|
||||
assert(np.max(rank.entropy(data, selem)) == 12000)
|
||||
|
||||
|
||||
def test_selem_dtypes():
|
||||
|
||||
image = np.zeros((5, 5), dtype=np.uint8)
|
||||
out = np.zeros_like(image)
|
||||
mask = np.ones_like(image, dtype=np.uint8)
|
||||
image[2, 2] = 255
|
||||
image[2, 3] = 128
|
||||
image[1, 2] = 16
|
||||
|
||||
for dtype in (np.uint8, np.uint16, np.int32, np.int64,
|
||||
np.float32, np.float64):
|
||||
elem = np.array([[0, 0, 0], [0, 1, 0], [0, 0, 0]], dtype=dtype)
|
||||
rank.mean(image=image, selem=elem, out=out, mask=mask,
|
||||
shift_x=0, shift_y=0)
|
||||
assert_array_equal(image, out)
|
||||
rank.percentile_mean(image=image, selem=elem, out=out, mask=mask,
|
||||
shift_x=0, shift_y=0)
|
||||
assert_array_equal(image, out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user