当前位置: 首页>>代码示例>>Python>>正文


Python testing.assert_allclose函数代码示例

本文整理汇总了Python中skimage._shared.testing.assert_allclose函数的典型用法代码示例。如果您正苦于以下问题:Python assert_allclose函数的具体用法?Python assert_allclose怎么用?Python assert_allclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert_allclose函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_picture_slice

def test_picture_slice():
    array = _array_2d_to_RGBA(np.arange(0, 10)[np.newaxis, :])
    pic = novice.Picture(array=array)

    x_slice = slice(3, 8)
    subpic = pic[:, x_slice]
    assert_allclose(subpic.array, array[x_slice, :])
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_novice.py

示例2: test_multi_page_gif

def test_multi_page_gif():
    img = imread(os.path.join(data_dir, 'no_time_for_that_tiny.gif'))
    assert img.shape == (24, 25, 14, 3), img.shape
    img2 = imread(os.path.join(data_dir, 'no_time_for_that_tiny.gif'),
                  img_num=5)
    assert img2.shape == (25, 14, 3)
    assert_allclose(img[5], img2)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_pil.py

示例3: check

 def check():
     expected = self.refs[filter]
     result = getattr(rank, filter)(self.image, self.selem)
     if filter == "entropy":
         # There may be some arch dependent rounding errors
         # See the discussions in
         # https://github.com/scikit-image/scikit-image/issues/3091
         # https://github.com/scikit-image/scikit-image/issues/2528
         assert_allclose(expected, result, atol=0, rtol=1E-15)
     elif filter == "otsu":
         # OTSU May also have some optimization dependent failures
         # See the discussions in
         # https://github.com/scikit-image/scikit-image/issues/3091
         # Pixel 3, 5 was found to be problematic. It can take either
         # a value of 41 or 81 depending on the specific optimizations
         # used.
         assert result[3, 5] in [41, 81]
         result[3, 5] = 81
         # Pixel [19, 18] is also found to be problematic for the same
         # reason.
         assert result[19, 18] in [141, 172]
         result[19, 18] = 172
         assert_array_equal(expected, result)
     else:
         assert_array_equal(expected, result)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:25,代码来源:test_rank.py

示例4: test_prewitt_vertical

def test_prewitt_vertical():
    """Prewitt on a vertical edge should be a vertical line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = filters.prewitt(image) * np.sqrt(2)
    j[np.abs(i) == 5] = 10000
    assert_allclose(result[j == 0], 1)
    assert_allclose(result[np.abs(j) > 1], 0, atol=1e-10)
开发者ID:Cadair,项目名称:scikit-image,代码行数:8,代码来源:test_edges.py

示例5: test_scharr_vertical

def test_scharr_vertical():
    """Scharr on a vertical edge should be a vertical line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = filters.scharr(image) * np.sqrt(2)
    j[np.abs(i) == 5] = 10000
    assert_allclose(result[j == 0], 1)
    assert (np.all(result[np.abs(j) > 1] == 0))
开发者ID:Cadair,项目名称:scikit-image,代码行数:8,代码来源:test_edges.py

示例6: test_prewitt_v_vertical

def test_prewitt_v_vertical():
    """Vertical prewitt on an edge should be a vertical line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = filters.prewitt_v(image)
    # Fudge the eroded points
    j[np.abs(i) == 5] = 10000
    assert (np.all(result[j == 0] == 1))
    assert_allclose(result[np.abs(j) > 1], 0, atol=1e-10)
开发者ID:Cadair,项目名称:scikit-image,代码行数:9,代码来源:test_edges.py

示例7: test_4d_input_pixel

def test_4d_input_pixel():
    phantom = img_as_float(binary_blobs(length=32, n_dim=4))
    reference_image = np.fft.fftn(phantom)
    shift = (-2., 1., 5., -3)
    shifted_image = fourier_shift(reference_image, shift)
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image,
                                                    space="fourier")
    assert_allclose(result, -np.array(shift), atol=0.05)
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:9,代码来源:test_register_translation.py

示例8: test_prewitt_h_horizontal

def test_prewitt_h_horizontal():
    """Horizontal prewitt on an edge should be a horizontal line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (i >= 0).astype(float)
    result = filters.prewitt_h(image)
    # Fudge the eroded points
    i[np.abs(j) == 5] = 10000
    assert (np.all(result[i == 0] == 1))
    assert_allclose(result[np.abs(i) > 1], 0, atol=1e-10)
开发者ID:Cadair,项目名称:scikit-image,代码行数:9,代码来源:test_edges.py

示例9: test_sobel_horizontal

def test_sobel_horizontal():
    """Sobel on a horizontal edge should be a horizontal line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (i >= 0).astype(float)
    result = filters.sobel(image) * np.sqrt(2)
    # Fudge the eroded points
    i[np.abs(j) == 5] = 10000
    assert_allclose(result[i == 0], 1)
    assert (np.all(result[np.abs(i) > 1] == 0))
开发者ID:Cadair,项目名称:scikit-image,代码行数:9,代码来源:test_edges.py

示例10: test_subpixel_precision

def test_subpixel_precision():
    reference_image = np.fft.fftn(camera())
    subpixel_shift = (-2.4, 1.32)
    shifted_image = fourier_shift(reference_image, subpixel_shift)

    # subpixel precision
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image, 100,
                                                    space="fourier")
    assert_allclose(result[:2], -np.array(subpixel_shift), atol=0.05)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py

示例11: test_correlation

def test_correlation():
    reference_image = np.fft.fftn(camera())
    shift = (-7, 12)
    shifted_image = fourier_shift(reference_image, shift)

    # pixel precision
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image,
                                                    space="fourier")
    assert_allclose(result[:2], -np.array(shift))
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py

示例12: test_speckle

def test_speckle():
    seed = 42
    data = np.zeros((128, 128)) + 0.1
    np.random.seed(seed=seed)
    noise = np.random.normal(0.1, 0.02 ** 0.5, (128, 128))
    expected = np.clip(data + data * noise, 0, 1)

    data_speckle = random_noise(data, mode='speckle', seed=seed, mean=0.1,
                                var=0.02)
    assert_allclose(expected, data_speckle)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_random_noise.py

示例13: test_poisson

def test_poisson():
    seed = 42
    data = camera()  # 512x512 grayscale uint8
    cam_noisy = random_noise(data, mode='poisson', seed=seed)
    cam_noisy2 = random_noise(data, mode='poisson', seed=seed, clip=False)

    np.random.seed(seed=seed)
    expected = np.random.poisson(img_as_float(data) * 256) / 256.
    assert_allclose(cam_noisy, np.clip(expected, 0., 1.))
    assert_allclose(cam_noisy2, expected)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_random_noise.py

示例14: test_real_input

def test_real_input():
    reference_image = camera()
    subpixel_shift = (-2.4, 1.32)
    shifted_image = fourier_shift(np.fft.fftn(reference_image), subpixel_shift)
    shifted_image = np.fft.ifftn(shifted_image)

    # subpixel precision
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image, 100)
    assert_allclose(result[:2], -np.array(subpixel_shift), atol=0.05)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py

示例15: test_size_one_dimension_input

def test_size_one_dimension_input():
    # take a strip of the input image
    reference_image = np.fft.fftn(camera()[:, 15]).reshape((-1, 1))
    subpixel_shift = (-2.4, 4)
    shifted_image = fourier_shift(reference_image, subpixel_shift)

    # subpixel precision
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image, 100,
                                                    space="fourier")
    assert_allclose(result[:2], -np.array((-2.4, 0)), atol=0.05)
开发者ID:Cadair,项目名称:scikit-image,代码行数:11,代码来源:test_register_translation.py


注:本文中的skimage._shared.testing.assert_allclose函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。