本文整理汇总了Python中scipy.ndimage.uniform_filter方法的典型用法代码示例。如果您正苦于以下问题:Python ndimage.uniform_filter方法的具体用法?Python ndimage.uniform_filter怎么用?Python ndimage.uniform_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.ndimage
的用法示例。
在下文中一共展示了ndimage.uniform_filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def filter(self, signal):
"""Filter a given signal with a choice of filter type (self.lres_filter).
"""
signal = signal.copy()
filter_size = [1, self.downsamp_t*2-1, self.downsamp_xz*2-1, self.downsamp_xz*2-1]
if self.lres_filter == 'none' or (not self.lres_filter):
output = signal
elif self.lres_filter == 'gaussian':
sigma = [0, int(self.downsamp_t/2), int(self.downsamp_xz/2), int(self.downsamp_xz/2)]
output = ndimage.gaussian_filter(signal, sigma=sigma)
elif self.lres_filter == 'uniform':
output = ndimage.uniform_filter(signal, size=filter_size)
elif self.lres_filter == 'median':
output = ndimage.median_filter(signal, size=filter_size)
elif self.lres_filter == 'maximum':
output = ndimage.maximum_filter(signal, size=filter_size)
else:
raise NotImplementedError(
"lres_filter must be one of none/gaussian/uniform/median/maximum")
return output
示例2: find_paws
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def find_paws(data, smooth_radius = 5, threshold = 0.0001):
# http://stackoverflow.com/questions/4087919/how-can-i-improve-my-paw-detection
"""Detects and isolates contiguous regions in the input array"""
# Blur the input data a bit so the paws have a continous footprint
data = ndimage.uniform_filter(data, smooth_radius)
# Threshold the blurred data (this needs to be a bit > 0 due to the blur)
thresh = data > threshold
# Fill any interior holes in the paws to get cleaner regions...
filled = ndimage.morphology.binary_fill_holes(thresh)
# Label each contiguous paw
coded_paws, num_paws = ndimage.label(filled)
# Isolate the extent of each paw
# find_objects returns a list of 2-tuples: (slice(...), slice(...))
# which represents a rectangular box around the object
data_slices = ndimage.find_objects(coded_paws)
return data_slices
示例3: rase
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def rase(GT,P,ws=8):
"""calculates relative average spectral error (rase).
:param GT: first (original) input image.
:param P: second (deformed) input image.
:param ws: sliding window size (default = 8).
:returns: float -- rase value.
"""
GT,P = _initial_check(GT,P)
_,rmse_map = rmse_sw(GT,P,ws)
GT_means = uniform_filter(GT, ws)/ws**2
N = GT.shape[2]
M = np.sum(GT_means,axis=2)/N
rase_map = (100./M) * np.sqrt( np.sum(rmse_map**2,axis=2) / N )
s = int(np.round(ws/2))
return np.mean(rase_map[s:-s,s:-s])
示例4: test_uniform02
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_uniform02(self):
array = numpy.array([1, 2, 3])
filter_shape = [0]
output = ndimage.uniform_filter(array, filter_shape)
assert_array_almost_equal(array, output)
示例5: test_uniform03
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_uniform03(self):
array = numpy.array([1, 2, 3])
filter_shape = [1]
output = ndimage.uniform_filter(array, filter_shape)
assert_array_almost_equal(array, output)
示例6: test_uniform04
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_uniform04(self):
array = numpy.array([2, 4, 6])
filter_shape = [2]
output = ndimage.uniform_filter(array, filter_shape)
assert_array_almost_equal([2, 3, 5], output)
示例7: test_uniform05
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_uniform05(self):
array = []
filter_shape = [1]
output = ndimage.uniform_filter(array, filter_shape)
assert_array_almost_equal([], output)
示例8: test_uniform06
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_uniform06(self):
filter_shape = [2, 2]
for type1 in self.types:
array = numpy.array([[4, 8, 12],
[16, 20, 24]], type1)
for type2 in self.types:
output = ndimage.uniform_filter(array,
filter_shape, output=type2)
assert_array_almost_equal([[4, 6, 10], [10, 12, 16]], output)
assert_equal(output.dtype.type, type2)
示例9: moving_mean_filter_2
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def moving_mean_filter_2(data, window):
''' window is a 2 element tuple with the moving window dimensions (rows, columns)'''
data = uniform_filter(data, size=window, mode='mirror')
return data
示例10: test_uniform06
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_uniform06(self):
filter_shape = [2, 2]
for type1 in self.types:
array = numpy.array([[4, 8, 12],
[16, 20, 24]], type1)
for type2 in self.types:
output = ndimage.uniform_filter(
array, filter_shape, output=type2)
assert_array_almost_equal([[4, 6, 10], [10, 12, 16]], output)
assert_equal(output.dtype.type, type2)
示例11: test_multiple_modes
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_multiple_modes():
# Test that the filters with multiple mode cababilities for different
# dimensions give the same result as applying a single mode.
arr = np.array([[1., 0., 0.],
[1., 1., 0.],
[0., 0., 0.]])
mode1 = 'reflect'
mode2 = ['reflect', 'reflect']
assert_equal(sndi.gaussian_filter(arr, 1, mode=mode1),
sndi.gaussian_filter(arr, 1, mode=mode2))
assert_equal(sndi.prewitt(arr, mode=mode1),
sndi.prewitt(arr, mode=mode2))
assert_equal(sndi.sobel(arr, mode=mode1),
sndi.sobel(arr, mode=mode2))
assert_equal(sndi.laplace(arr, mode=mode1),
sndi.laplace(arr, mode=mode2))
assert_equal(sndi.gaussian_laplace(arr, 1, mode=mode1),
sndi.gaussian_laplace(arr, 1, mode=mode2))
assert_equal(sndi.maximum_filter(arr, size=5, mode=mode1),
sndi.maximum_filter(arr, size=5, mode=mode2))
assert_equal(sndi.minimum_filter(arr, size=5, mode=mode1),
sndi.minimum_filter(arr, size=5, mode=mode2))
assert_equal(sndi.gaussian_gradient_magnitude(arr, 1, mode=mode1),
sndi.gaussian_gradient_magnitude(arr, 1, mode=mode2))
assert_equal(sndi.uniform_filter(arr, 5, mode=mode1),
sndi.uniform_filter(arr, 5, mode=mode2))
示例12: test_multiple_modes_sequentially
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_multiple_modes_sequentially():
# Test that the filters with multiple mode cababilities for different
# dimensions give the same result as applying the filters with
# different modes sequentially
arr = np.array([[1., 0., 0.],
[1., 1., 0.],
[0., 0., 0.]])
modes = ['reflect', 'wrap']
expected = sndi.gaussian_filter1d(arr, 1, axis=0, mode=modes[0])
expected = sndi.gaussian_filter1d(expected, 1, axis=1, mode=modes[1])
assert_equal(expected,
sndi.gaussian_filter(arr, 1, mode=modes))
expected = sndi.uniform_filter1d(arr, 5, axis=0, mode=modes[0])
expected = sndi.uniform_filter1d(expected, 5, axis=1, mode=modes[1])
assert_equal(expected,
sndi.uniform_filter(arr, 5, mode=modes))
expected = sndi.maximum_filter1d(arr, size=5, axis=0, mode=modes[0])
expected = sndi.maximum_filter1d(expected, size=5, axis=1, mode=modes[1])
assert_equal(expected,
sndi.maximum_filter(arr, size=5, mode=modes))
expected = sndi.minimum_filter1d(arr, size=5, axis=0, mode=modes[0])
expected = sndi.minimum_filter1d(expected, size=5, axis=1, mode=modes[1])
assert_equal(expected,
sndi.minimum_filter(arr, size=5, mode=modes))
示例13: test_multiple_modes_uniform
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def test_multiple_modes_uniform():
# Test uniform filter for multiple extrapolation modes
arr = np.array([[1., 0., 0.],
[1., 1., 0.],
[0., 0., 0.]])
expected = np.array([[0.32, 0.40, 0.48],
[0.20, 0.28, 0.32],
[0.28, 0.32, 0.40]])
modes = ['reflect', 'wrap']
assert_almost_equal(expected,
sndi.uniform_filter(arr, 5, mode=modes))
示例14: execute
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def execute(self, image_array: ndarray):
return ndimage.uniform_filter(image_array, size=(11, 11, 1))
示例15: _rmse_sw_single
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import uniform_filter [as 别名]
def _rmse_sw_single (GT,P,ws):
errors = (GT-P)**2
errors = uniform_filter(errors.astype(np.float64),ws)
rmse_map = np.sqrt(errors)
s = int(np.round((ws/2)))
return np.mean(rmse_map[s:-s,s:-s]),rmse_map