本文整理汇总了Python中skimage._shared.testing.assert_array_almost_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_array_almost_equal函数的具体用法?Python assert_array_almost_equal怎么用?Python assert_array_almost_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_array_almost_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_yuv_roundtrip
def test_yuv_roundtrip(self):
img_rgb = img_as_float(self.img_rgb)[::16, ::16]
assert_array_almost_equal(yuv2rgb(rgb2yuv(img_rgb)), img_rgb)
assert_array_almost_equal(yiq2rgb(rgb2yiq(img_rgb)), img_rgb)
assert_array_almost_equal(ypbpr2rgb(rgb2ypbpr(img_rgb)), img_rgb)
assert_array_almost_equal(ycbcr2rgb(rgb2ycbcr(img_rgb)), img_rgb)
assert_array_almost_equal(ydbdr2rgb(rgb2ydbdr(img_rgb)), img_rgb)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:7,代码来源:test_colorconv.py
示例2: test_apply_parallel_lazy
def test_apply_parallel_lazy():
import dask.array as da
# data
a = np.arange(144).reshape(12, 12).astype(float)
d = da.from_array(a, chunks=(6, 6))
# apply the filter
expected1 = threshold_local(a, 3)
result1 = apply_parallel(threshold_local, a, chunks=(6, 6), depth=5,
extra_arguments=(3,),
extra_keywords={'mode': 'reflect'},
compute=False)
# apply the filter on a Dask Array
result2 = apply_parallel(threshold_local, d, depth=5,
extra_arguments=(3,),
extra_keywords={'mode': 'reflect'},
compute=False)
assert isinstance(result1, da.Array)
assert_array_almost_equal(result1.compute(), expected1)
assert isinstance(result2, da.Array)
assert_array_almost_equal(result2.compute(), expected1)
开发者ID:Cadair,项目名称:scikit-image,代码行数:27,代码来源:test_apply_parallel.py
示例3: test_absolute_threshold
def test_absolute_threshold(self):
image = np.zeros((5, 5), dtype=np.uint8)
image[1, 1] = 10
image[3, 3] = 20
peaks = peak.peak_local_max(image, min_distance=1, threshold_abs=10)
assert len(peaks) == 1
assert_array_almost_equal(peaks, [(3, 3)])
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_peak.py
示例4: test_rgb_lch_roundtrip
def test_rgb_lch_roundtrip(self):
rgb = img_as_float(self.img_rgb)
lab = rgb2lab(rgb)
lch = lab2lch(lab)
lab2 = lch2lab(lch)
rgb2 = lab2rgb(lab2)
assert_array_almost_equal(rgb, rgb2)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:7,代码来源:test_colorconv.py
示例5: test_cross_correlate_masked_over_axes
def test_cross_correlate_masked_over_axes():
"""Masked normalized cross-correlation over axes should be
equivalent to a loop over non-transform axes."""
# See random number generator for reproducible results
np.random.seed(23)
arr1 = np.random.random((8, 8, 5))
arr2 = np.random.random((8, 8, 5))
m1 = np.random.choice([True, False], arr1.shape)
m2 = np.random.choice([True, False], arr2.shape)
# Loop over last axis
with_loop = np.empty_like(arr1, dtype=np.complex)
for index in range(arr1.shape[-1]):
with_loop[:, :, index] = cross_correlate_masked(arr1[:, :, index],
arr2[:, :, index],
m1[:, :, index],
m2[:, :, index],
axes=(0, 1),
mode='same')
over_axes = cross_correlate_masked(
arr1, arr2, m1, m2, axes=(0, 1), mode='same')
testing.assert_array_almost_equal(with_loop, over_axes)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:26,代码来源:test_masked_register_translation.py
示例6: roundtrip
def roundtrip(self, x, scaling=1):
f = NamedTemporaryFile(suffix='.png')
fname = f.name
f.close()
imsave(fname, x)
y = imread(fname)
assert_array_almost_equal((x * scaling).astype(np.int32), y)
开发者ID:jmetz,项目名称:scikit-image,代码行数:8,代码来源:test_imageio.py
示例7: test_apply_parallel_wrap
def test_apply_parallel_wrap():
def wrapped(arr):
return gaussian(arr, 1, mode='wrap')
a = np.arange(144).reshape(12, 12).astype(float)
expected = gaussian(a, 1, mode='wrap')
result = apply_parallel(wrapped, a, chunks=(6, 6), depth=5, mode='wrap')
assert_array_almost_equal(result, expected)
开发者ID:Cadair,项目名称:scikit-image,代码行数:8,代码来源:test_apply_parallel.py
示例8: test_roberts_diagonal2
def test_roberts_diagonal2():
"""Roberts' filter on a diagonal edge should be a diagonal line."""
image = np.rot90(np.tri(10, 10, 0), 3)
expected = ~np.rot90(np.tri(10, 10, -1).astype(bool) |
np.tri(10, 10, -2).astype(bool).transpose())
expected = _mask_filter_result(expected, None)
result = filters.roberts(image).astype(bool)
assert_array_almost_equal(result, expected)
开发者ID:Cadair,项目名称:scikit-image,代码行数:8,代码来源:test_edges.py
示例9: test_offset_not_none
def test_offset_not_none():
"""Test reconstruction with valid offset parameter"""
seed = np.array([0, 3, 6, 2, 1, 1, 1, 4, 2, 0])
mask = np.array([0, 8, 6, 8, 8, 8, 8, 4, 4, 0])
expected = np.array([0, 3, 6, 6, 6, 6, 6, 4, 4, 0])
assert_array_almost_equal(
reconstruction(seed, mask, method='dilation',
selem=np.ones(3), offset=np.array([0])), expected)
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:9,代码来源:test_reconstruction.py
示例10: test_no_chunks
def test_no_chunks():
a = np.ones(1 * 4 * 8 * 9).reshape(1, 4, 8, 9)
def add_42(arr):
return arr + 42
expected = add_42(a)
result = apply_parallel(add_42, a)
assert_array_almost_equal(result, expected)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_apply_parallel.py
示例11: test_weighted_moments_normalized
def test_weighted_moments_normalized():
wnu = regionprops(SAMPLE, intensity_image=INTENSITY_SAMPLE
)[0].weighted_moments_normalized.T # test used x/y coord
ref = np.array(
[[ np.nan, np.nan, 0.0873590903, -0.0161217406],
[ np.nan, -0.0160405109, -0.0031421072, -0.0031376984],
[ 0.230146783, 0.0457932622, 0.0165315478, 0.0043903193],
[-0.0162529732, -0.0104598869, -0.0028544152, -0.0011057191]]
)
assert_array_almost_equal(wnu, ref)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:10,代码来源:test_regionprops.py
示例12: test_moments_hu
def test_moments_hu():
hu = regionprops(SAMPLE)[0].moments_hu
ref = np.array([
3.27117627e-01,
2.63869194e-02,
2.35390060e-02,
1.23151193e-03,
1.38882330e-06,
-2.72586158e-05,
-6.48350653e-06
])
# bug in OpenCV caused in Central Moments calculation?
assert_array_almost_equal(hu, ref)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:13,代码来源:test_regionprops.py
示例13: test_weighted_moments_hu
def test_weighted_moments_hu():
whu = regionprops(SAMPLE, intensity_image=INTENSITY_SAMPLE
)[0].weighted_moments_hu
ref = np.array([
3.1750587329e-01,
2.1417517159e-02,
2.3609322038e-02,
1.2565683360e-03,
8.3014209421e-07,
-3.5073773473e-05,
-6.7936409056e-06
])
assert_array_almost_equal(whu, ref)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:13,代码来源:test_regionprops.py
示例14: test_weighted_moments
def test_weighted_moments():
wm = regionprops(SAMPLE, intensity_image=INTENSITY_SAMPLE
)[0].weighted_moments.T # test used x/y coords
ref = np.array(
[[ 7.4000000000e+01, 4.1000000000e+02, 2.7500000000e+03,
1.9778000000e+04],
[ 6.9900000000e+02, 3.7850000000e+03, 2.4855000000e+04,
1.7500100000e+05],
[ 7.8630000000e+03, 4.4063000000e+04, 2.9347700000e+05,
2.0810510000e+06],
[ 9.7317000000e+04, 5.7256700000e+05, 3.9007170000e+06,
2.8078871000e+07]]
)
assert_array_almost_equal(wm, ref)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:14,代码来源:test_regionprops.py
示例15: test_weighted_moments_central
def test_weighted_moments_central():
wmu = regionprops(SAMPLE, intensity_image=INTENSITY_SAMPLE
)[0].weighted_moments_central.T # test used x/y coords
ref = np.array(
[[ 7.4000000000e+01, -2.1316282073e-13, 4.7837837838e+02,
-7.5943608473e+02],
[ 3.7303493627e-14, -8.7837837838e+01, -1.4801314828e+02,
-1.2714707125e+03],
[ 1.2602837838e+03, 2.1571526662e+03, 6.6989799420e+03,
1.5304076361e+04],
[ -7.6561796932e+02, -4.2385971907e+03, -9.9501164076e+03,
-3.3156729271e+04]]
)
np.set_printoptions(precision=10)
assert_array_almost_equal(wmu, ref)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:15,代码来源:test_regionprops.py
示例16: test_gaussian_mssim_and_gradient_vs_Matlab
def test_gaussian_mssim_and_gradient_vs_Matlab():
# comparison to Matlab implementation of N. Avanaki:
# https://ece.uwaterloo.ca/~nnikvand/Coderep/SHINE%20TOOLBOX/SHINEtoolbox/
# Note: final line of ssim_sens.m was modified to discard image borders
ref = np.load(os.path.join(data_dir, 'mssim_matlab_output.npz'))
grad_matlab = ref['grad_matlab']
mssim_matlab = float(ref['mssim_matlab'])
mssim, grad = ssim(cam, cam_noisy, gaussian_weights=True, gradient=True,
use_sample_covariance=False)
assert_almost_equal(mssim, mssim_matlab, decimal=3)
# check almost equal aside from object borders
assert_array_almost_equal(grad_matlab[5:-5], grad[5:-5])
开发者ID:TheArindham,项目名称:scikit-image,代码行数:16,代码来源:test_structural_similarity.py
示例17: test_rgb2lab_brucelindbloom
def test_rgb2lab_brucelindbloom(self):
"""
Test the RGB->Lab conversion by comparing to the calculator on the
authoritative Bruce Lindbloom
[website](http://brucelindbloom.com/index.html?ColorCalculator.html).
"""
# Obtained with D65 white point, sRGB model and gamma
gt_for_colbars = np.array([
[100,0,0],
[97.1393, -21.5537, 94.4780],
[91.1132, -48.0875, -14.1312],
[87.7347, -86.1827, 83.1793],
[60.3242, 98.2343, -60.8249],
[53.2408, 80.0925, 67.2032],
[32.2970, 79.1875, -107.8602],
[0,0,0]]).T
gt_array = np.swapaxes(gt_for_colbars.reshape(3, 4, 2), 0, 2)
assert_array_almost_equal(rgb2lab(self.colbars_array), gt_array, decimal=2)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:18,代码来源:test_colorconv.py
示例18: test_apply_parallel
def test_apply_parallel():
# data
a = np.arange(144).reshape(12, 12).astype(float)
# apply the filter
expected1 = threshold_local(a, 3)
result1 = apply_parallel(threshold_local, a, chunks=(6, 6), depth=5,
extra_arguments=(3,),
extra_keywords={'mode': 'reflect'})
assert_array_almost_equal(result1, expected1)
def wrapped_gauss(arr):
return gaussian(arr, 1, mode='reflect')
expected2 = gaussian(a, 1, mode='reflect')
result2 = apply_parallel(wrapped_gauss, a, chunks=(6, 6), depth=5)
assert_array_almost_equal(result2, expected2)
开发者ID:Cadair,项目名称:scikit-image,代码行数:19,代码来源:test_apply_parallel.py
示例19: test_rgb2luv_brucelindbloom
def test_rgb2luv_brucelindbloom(self):
"""
Test the RGB->Lab conversion by comparing to the calculator on the
authoritative Bruce Lindbloom
[website](http://brucelindbloom.com/index.html?ColorCalculator.html).
"""
# Obtained with D65 white point, sRGB model and gamma
gt_for_colbars = np.array([
[100, 0, 0],
[97.1393, 7.7056, 106.7866],
[91.1132, -70.4773, -15.2042],
[87.7347, -83.0776, 107.3985],
[60.3242, 84.0714, -108.6834],
[53.2408, 175.0151, 37.7564],
[32.2970, -9.4054, -130.3423],
[0, 0, 0]]).T
gt_array = np.swapaxes(gt_for_colbars.reshape(3, 4, 2), 0, 2)
assert_array_almost_equal(rgb2luv(self.colbars_array),
gt_array, decimal=2)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:19,代码来源:test_colorconv.py
示例20: test_lab2xyz
def test_lab2xyz(self):
assert_array_almost_equal(lab2xyz(self.lab_array),
self.xyz_array, decimal=3)
# Test the conversion with the rest of the illuminants.
for I in ["d50", "d55", "d65", "d75"]:
for obs in ["2", "10"]:
fname = "lab_array_{0}_{1}.npy".format(I, obs)
lab_array_I_obs = np.load(
os.path.join(os.path.dirname(__file__), 'data', fname))
assert_array_almost_equal(lab2xyz(lab_array_I_obs, I, obs),
self.xyz_array, decimal=3)
for I in ["a", "e"]:
fname = "lab_array_{0}_2.npy".format(I, obs)
lab_array_I_obs = np.load(
os.path.join(os.path.dirname(__file__), 'data', fname))
assert_array_almost_equal(lab2xyz(lab_array_I_obs, I, "2"),
self.xyz_array, decimal=3)
# And we include a call to test the exception handling in the code.
try:
xs = lab2xyz(lab_array_I_obs, "NaI", "2") # Not an illuminant
except ValueError:
pass
try:
xs = lab2xyz(lab_array_I_obs, "d50", "42") # Not a degree
except ValueError:
pass
开发者ID:TheArindham,项目名称:scikit-image,代码行数:29,代码来源:test_colorconv.py
注:本文中的skimage._shared.testing.assert_array_almost_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论