本文整理汇总了Python中skimage._shared.testing.assert_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_equal函数的具体用法?Python assert_equal怎么用?Python assert_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_masked_registration_random_masks_non_equal_sizes
def test_masked_registration_random_masks_non_equal_sizes():
"""masked_register_translation should be able to register
translations between images that are not the same size even
with random masks."""
# See random number generator for reproducible results
np.random.seed(23)
reference_image = camera()
shift = (-7, 12)
shifted = np.real(np.fft.ifft2(fourier_shift(
np.fft.fft2(reference_image), shift)))
# Crop the shifted image
shifted = shifted[64:-64, 64:-64]
# Random masks with 75% of pixels being valid
ref_mask = np.random.choice(
[True, False], reference_image.shape, p=[3 / 4, 1 / 4])
shifted_mask = np.random.choice(
[True, False], shifted.shape, p=[3 / 4, 1 / 4])
measured_shift = masked_register_translation(
reference_image,
shifted,
np.ones_like(ref_mask),
np.ones_like(shifted_mask))
assert_equal(measured_shift, -np.array(shift))
开发者ID:TheArindham,项目名称:scikit-image,代码行数:27,代码来源:test_masked_register_translation.py
示例2: test_masked_registration_padfield_data
def test_masked_registration_padfield_data():
""" Masked translation registration should behave like in the original
publication """
# Test translated from MATLABimplementation `MaskedFFTRegistrationTest`
# file. You can find the source code here:
# http://www.dirkpadfield.com/Home/MaskedFFTRegistrationCode.zip
shifts = [(75, 75), (-130, 130), (130, 130)]
for xi, yi in shifts:
fixed_image = imread(
IMAGES_DIR / 'OriginalX{:d}Y{:d}.png'.format(xi, yi))
moving_image = imread(
IMAGES_DIR / 'TransformedX{:d}Y{:d}.png'.format(xi, yi))
# Valid pixels are 1
fixed_mask = (fixed_image != 0)
moving_mask = (moving_image != 0)
# Note that shifts in x and y and shifts in cols and rows
shift_y, shift_x = masked_register_translation(fixed_image,
moving_image,
fixed_mask,
moving_mask,
overlap_ratio = 1/10)
# Note: by looking at the test code from Padfield's
# MaskedFFTRegistrationCode repository, the
# shifts were not xi and yi, but xi and -yi
assert_equal((shift_x, shift_y), (-xi, yi))
开发者ID:TheArindham,项目名称:scikit-image,代码行数:29,代码来源:test_masked_register_translation.py
示例3: test_binary_descriptors_rotation_crosscheck_true
def test_binary_descriptors_rotation_crosscheck_true():
"""Verify matched keypoints and their corresponding masks results between
image and its rotated version with the expected keypoint pairs with
cross_check enabled."""
img = data.astronaut()
img = rgb2gray(img)
tform = tf.SimilarityTransform(scale=1, rotation=0.15, translation=(0, 0))
rotated_img = tf.warp(img, tform, clip=False)
extractor = BRIEF(descriptor_size=512)
keypoints1 = corner_peaks(corner_harris(img), min_distance=5,
threshold_abs=0, threshold_rel=0.1)
extractor.extract(img, keypoints1)
descriptors1 = extractor.descriptors
keypoints2 = corner_peaks(corner_harris(rotated_img), min_distance=5,
threshold_abs=0, threshold_rel=0.1)
extractor.extract(rotated_img, keypoints2)
descriptors2 = extractor.descriptors
matches = match_descriptors(descriptors1, descriptors2, cross_check=True)
exp_matches1 = np.array([ 0, 2, 3, 4, 5, 6, 9, 11, 12, 13, 14, 17,
18, 19, 21, 22, 23, 26, 27, 28, 29, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46])
exp_matches2 = np.array([ 0, 2, 3, 1, 4, 6, 5, 7, 13, 10, 9, 11,
15, 8, 14, 12, 16, 18, 19, 21, 20, 24, 25, 26,
28, 27, 22, 23, 29, 30, 31, 32, 35, 33, 34, 36])
assert_equal(matches[:, 0], exp_matches1)
assert_equal(matches[:, 1], exp_matches2)
开发者ID:Cadair,项目名称:scikit-image,代码行数:31,代码来源:test_match.py
示例4: test_subdivide_polygon
def test_subdivide_polygon():
new_square1 = square
new_square2 = square[:-1]
new_square3 = square[:-1]
# test iterative subdvision
for _ in range(10):
square1, square2, square3 = new_square1, new_square2, new_square3
# test different B-Spline degrees
for degree in range(1, 7):
mask_len = len(_SUBDIVISION_MASKS[degree][0])
# test circular
new_square1 = subdivide_polygon(square1, degree)
assert_array_equal(new_square1[-1], new_square1[0])
assert_equal(new_square1.shape[0],
2 * square1.shape[0] - 1)
# test non-circular
new_square2 = subdivide_polygon(square2, degree)
assert_equal(new_square2.shape[0],
2 * (square2.shape[0] - mask_len + 1))
# test non-circular, preserve_ends
new_square3 = subdivide_polygon(square3, degree, True)
assert_equal(new_square3[0], square3[0])
assert_equal(new_square3[-1], square3[-1])
assert_equal(new_square3.shape[0],
2 * (square3.shape[0] - mask_len + 2))
# not supported B-Spline degree
with testing.raises(ValueError):
subdivide_polygon(square, 0)
with testing.raises(ValueError):
subdivide_polygon(square, 8)
开发者ID:Cadair,项目名称:scikit-image,代码行数:32,代码来源:test_polygon.py
示例5: test_hdx_rgb_roundtrip
def test_hdx_rgb_roundtrip(self):
from skimage.color.colorconv import hdx_from_rgb, rgb_from_hdx
img_rgb = self.img_rgb
conv = combine_stains(separate_stains(img_rgb, hdx_from_rgb),
rgb_from_hdx)
with expected_warnings(['precision loss']):
assert_equal(img_as_ubyte(conv), img_rgb)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:7,代码来源:test_colorconv.py
示例6: test_binary_descriptors
def test_binary_descriptors():
descs1 = np.array([[True, True, False, True, True],
[False, True, False, True, True]])
descs2 = np.array([[True, False, False, True, False],
[False, False, True, True, True]])
matches = match_descriptors(descs1, descs2)
assert_equal(matches, [[0, 0], [1, 1]])
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_match.py
示例7: test_basic
def test_basic():
x = np.array([[1, 1, 3],
[0, 2, 0],
[4, 3, 1]])
path, cost = spath.shortest_path(x)
assert_array_equal(path, [0, 0, 1])
assert_equal(cost, 1)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_spath.py
示例8: test_reach
def test_reach():
x = np.array([[1, 1, 3],
[0, 2, 0],
[4, 3, 1]])
path, cost = spath.shortest_path(x, reach=2)
assert_array_equal(path, [0, 0, 2])
assert_equal(cost, 0)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_spath.py
示例9: test_imexport_imimport
def test_imexport_imimport():
shape = (2, 2)
image = np.zeros(shape)
with expected_warnings(['precision loss']):
pil_image = ndarray_to_pil(image)
out = pil_to_ndarray(pil_image)
assert_equal(out.shape, shape)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_pil.py
示例10: test_rectangle_selem
def test_rectangle_selem(self):
"""Test rectangle structuring elements"""
for i in range(0, 5):
for j in range(0, 5):
actual_mask = selem.rectangle(i, j)
expected_mask = np.ones((i, j), dtype='uint8')
assert_equal(expected_mask, actual_mask)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_selem.py
示例11: test_string_sort
def test_string_sort():
filenames = ['f9.10.png', 'f9.9.png', 'f10.10.png', 'f10.9.png',
'e9.png', 'e10.png', 'em.png']
sorted_filenames = ['e9.png', 'e10.png', 'em.png', 'f9.9.png',
'f9.10.png', 'f10.9.png', 'f10.10.png']
sorted_filenames = sorted(filenames, key=alphanumeric_key)
assert_equal(sorted_filenames, sorted_filenames)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_collection.py
示例12: test_pad_input
def test_pad_input():
"""Test `match_template` when `pad_input=True`.
This test places two full templates (one with values lower than the image
mean, the other higher) and two half templates, which are on the edges of
the image. The two full templates should score the top (positive and
negative) matches and the centers of the half templates should score 2nd.
"""
# Float prefactors ensure that image range is between 0 and 1
template = 0.5 * diamond(2)
image = 0.5 * np.ones((9, 19))
mid = slice(2, 7)
image[mid, :3] -= template[:, -3:] # half min template centered at 0
image[mid, 4:9] += template # full max template centered at 6
image[mid, -9:-4] -= template # full min template centered at 12
image[mid, -3:] += template[:, :3] # half max template centered at 18
result = match_template(image, template, pad_input=True,
constant_values=image.mean())
# get the max and min results.
sorted_result = np.argsort(result.flat)
i, j = np.unravel_index(sorted_result[:2], result.shape)
assert_equal(j, (12, 0))
i, j = np.unravel_index(sorted_result[-2:], result.shape)
assert_equal(j, (18, 6))
开发者ID:TheArindham,项目名称:scikit-image,代码行数:26,代码来源:test_template.py
示例13: test_hough_line_angles
def test_hough_line_angles():
img = np.zeros((10, 10))
img[0, 0] = 1
out, angles, d = transform.hough_line(img, np.linspace(0, 360, 10))
assert_equal(len(angles), 10)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_hough_transform.py
示例14: test_peak_float_out_of_range_dtype
def test_peak_float_out_of_range_dtype():
im = np.array([10, 100], dtype=np.float16)
nbins = 10
frequencies, bin_centers = exposure.histogram(im, nbins=nbins, source_range='dtype')
assert_almost_equal(np.min(bin_centers), -0.9, 3)
assert_almost_equal(np.max(bin_centers), 0.9, 3)
assert_equal(len(bin_centers), 10)
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:7,代码来源:test_exposure.py
示例15: test_median_default_value
def test_median_default_value(self):
a = np.zeros((3, 3), dtype=np.uint8)
a[1] = 1
full_selem = np.ones((3, 3), dtype=np.uint8)
assert_equal(rank.median(a), rank.median(a, full_selem))
assert rank.median(a)[1, 1] == 0
assert rank.median(a, disk(1))[1, 1] == 1
开发者ID:TheArindham,项目名称:scikit-image,代码行数:7,代码来源:test_rank.py
示例16: test_hough_line_peaks_zero_input
def test_hough_line_peaks_zero_input():
# Test to make sure empty input doesn't cause a failure
img = np.zeros((100, 100), dtype='uint8')
theta = np.linspace(0, np.pi, 100)
hspace, angles, dists = transform.hough_line(img, theta)
h, a, d = transform.hough_line_peaks(hspace, angles, dists)
assert_equal(a, np.array([]))
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_hough_transform.py
示例17: test_rect_tool
def test_rect_tool():
img = data.camera()
viewer = ImageViewer(img)
tool = RectangleTool(viewer, maxdist=10)
tool.extents = (100, 150, 100, 150)
assert_equal(tool.corners,
((100, 150, 150, 100), (100, 100, 150, 150)))
assert_equal(tool.extents, (100, 150, 100, 150))
assert_equal(tool.edge_centers,
((100, 125.0, 150, 125.0), (125.0, 100, 125.0, 150)))
assert_equal(tool.geometry, (100, 150, 100, 150))
# grab a corner and move it
do_event(viewer, 'mouse_press', xdata=100, ydata=100)
do_event(viewer, 'move', xdata=120, ydata=120)
do_event(viewer, 'mouse_release')
# assert_equal(tool.geometry, [120, 150, 120, 150])
# create a new line
do_event(viewer, 'mouse_press', xdata=10, ydata=10)
do_event(viewer, 'move', xdata=100, ydata=100)
do_event(viewer, 'mouse_release')
assert_equal(tool.geometry, [10, 100, 10, 100])
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:25,代码来源:test_tools.py
示例18: test_regular_grid_3d_8
def test_regular_grid_3d_8():
ar = np.zeros((3, 20, 40))
g = regular_grid(ar.shape, 8)
assert_equal(g, [slice(1.0, None, 3.0), slice(5.0, None, 10.0),
slice(5.0, None, 10.0)])
ar[g] = 1
assert_equal(ar.sum(), 8)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_regular_grid.py
示例19: test_denoise_bilateral_nan
def test_denoise_bilateral_nan():
img = np.full((50, 50), np.NaN)
# This is in fact an optional warning for our test suite.
# Python 3.5 will not trigger a warning.
with expected_warnings([r'invalid|\A\Z']):
out = restoration.denoise_bilateral(img, multichannel=False)
assert_equal(img, out)
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:7,代码来源:test_denoise.py
示例20: test_ssim_patch_range
def test_ssim_patch_range():
N = 51
X = (np.random.rand(N, N) * 255).astype(np.uint8)
Y = (np.random.rand(N, N) * 255).astype(np.uint8)
assert(ssim(X, Y, win_size=N) < 0.1)
assert_equal(ssim(X, X, win_size=N), 1)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:7,代码来源:test_structural_similarity.py
注:本文中的skimage._shared.testing.assert_equal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论