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


Python testing.assert_array_almost_equal函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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