def percentile_filter(input, percentile, size=None, footprint=None, mode='reflect', cval=0.0, origin=0): footprint = _utils._get_footprint(input.ndim, size, footprint) origin = _utils._get_origin(footprint.shape, origin) depth = _utils._get_depth(footprint.shape, origin) depth, boundary = _utils._get_depth_boundary(footprint.ndim, depth, "none") result = input.map_overlap( scipy.ndimage.filters.percentile_filter, depth=depth, boundary=boundary, dtype=input.dtype, percentile=percentile, footprint=footprint, mode=mode, cval=cval, origin=origin ) return result
def _wrapped_ordering_filter(input, size=None, footprint=None, mode='reflect', cval=0.0, origin=0): footprint = _utils._get_footprint(input.ndim, size, footprint) origin = _utils._get_origin(footprint.shape, origin) depth = _utils._get_depth(footprint.shape, origin) depth, boundary = _utils._get_depth_boundary(footprint.ndim, depth, "none") result = input.map_overlap( func, depth=depth, boundary=boundary, dtype=input.dtype, footprint=footprint, mode=mode, cval=cval, origin=origin ) return result
def entropy(image, selem, out=None, mask=None, shift_x=False, shift_y=False): selem = np.ones(2 * [entropy_filter_size]) depth = 5 depth, boundary = _utils._get_depth_boundary(image.ndim, depth, "none") if (image.ndim == 2): result = image.map_overlap( skimage.filters.rank.generic.entropy, depth = depth, boundary = boundary, dtype = image.dtype, selem = selem, out = out, mask = mask, shift_x = shift_x, shift_y = shift_y ) else: lst = [] for i in range(np.size(stack, axis = 0)): lst.append(entropy(stack[i], selem)) result = np.stack(lst, axis =0) return result
def uniform_filter(input, size=3, mode='reflect', cval=0.0, origin=0): size = _utils._get_size(input.ndim, size) depth = _utils._get_depth(size, origin) depth, boundary = _utils._get_depth_boundary(input.ndim, depth, "none") result = input.map_overlap(scipy.ndimage.filters.uniform_filter, depth=depth, boundary=boundary, dtype=input.dtype, size=size, mode=mode, cval=cval, origin=origin) return result
def convolve(input, weights, mode='reflect', cval=0.0, origin=0): origin = _utils._get_origin(weights.shape, origin) depth = _utils._get_depth(weights.shape, origin) depth, boundary = _utils._get_depth_boundary(input.ndim, depth, "none") result = input.map_overlap( scipy.ndimage.filters.convolve, depth=depth, boundary=boundary, dtype=input.dtype, weights=weights, mode=mode, cval=cval, origin=origin ) return result
def gaussian_laplace(input, sigma, mode='reflect', cval=0.0, truncate=4.0, **kwargs): sigma = _get_sigmas(input, sigma) depth = _get_border(input, sigma, truncate) depth, boundary = _utils._get_depth_boundary(input.ndim, depth, "none") result = input.map_overlap(scipy.ndimage.filters.gaussian_laplace, depth=depth, boundary=boundary, dtype=input.dtype, sigma=sigma, mode=mode, cval=cval, truncate=truncate, **kwargs) return result
def test_errs__get_depth_boundary(err_type, ndim, depth, boundary): with pytest.raises(err_type): _utils._get_depth_boundary(ndim, depth, boundary)
def test__get_depth_boundary(expected, ndim, depth, boundary): assert expected == _utils._get_depth_boundary(ndim, depth, boundary)