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


Python data.coins函数代码示例

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


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

示例1: test_plot_plugin

def test_plot_plugin():
    viewer = ImageViewer(data.moon())
    plugin = PlotPlugin(image_filter=lambda x: x)
    viewer += plugin

    assert_equal(viewer.image, data.moon())
    plugin._update_original_image(data.coins())
    assert_equal(viewer.image, data.coins())
    viewer.close()
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:9,代码来源:test_plugins.py

示例2: coins

 def coins(self):
     """Prepare some example frames using images from the skimage
     library."""
     coins = np.array([data.coins() for i in range(0, 3*61)])
     coins = coins.reshape(3, 61, *data.coins().shape)
     # Adjust each frame to mimic an X-ray edge with a sigmoid
     S = 1/(1+np.exp(-(self.K_Es-8353))) + 0.1*np.sin(4*self.K_Es-4*8353)
     coins = (coins * S.reshape(3, 61,1,1))
     # Add some noise otherwise some functions div by zero.
     coins = coins * (0.975 + np.random.rand(*coins.shape)/20)
     coins = coins.astype(np.int32)
     return coins
开发者ID:m3wolf,项目名称:xanespy,代码行数:12,代码来源:test_math.py

示例3: scikit_example_plot_label

def scikit_example_plot_label():
    image = data.coins()[50:-50, 50:-50]
    
    # apply threshold
    thresh = threshold_otsu(image)
    bw = closing(image > thresh, square(3))
    
    # remove artifacts connected to image border
    cleared = bw.copy()
    clear_border(cleared)
    
    # label image regions
    label_image = label(cleared)
    borders = np.logical_xor(bw, cleared)
    label_image[borders] = -1
    
    fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(6, 6))
    ax.imshow(label_image, cmap='jet')
    
    for region in regionprops(label_image, ['Area', 'BoundingBox']):
    
        # skip small images
        if region['Area'] < 100:
            continue
    
        # draw rectangle around segmented coins
        minr, minc, maxr, maxc = region['BoundingBox']
        rect = mpatches.Rectangle((minc, minr), maxc - minc, maxr - minr,
                                  fill=False, edgecolor='red', linewidth=2)
        ax.add_patch(rect)
    
    plt.show()
开发者ID:bchoatejr,项目名称:math,代码行数:32,代码来源:image_label.py

示例4: test_uniform_mode

def test_uniform_mode():
    """Verify the computed BRIEF descriptors with expected for uniform mode."""
    img = data.coins()

    keypoints = corner_peaks(corner_harris(img), min_distance=5, threshold_abs=0, threshold_rel=0.1)

    extractor = BRIEF(descriptor_size=8, sigma=2, mode="uniform")

    extractor.extract(img, keypoints[:8])

    expected = np.array(
        [
            [False, False, False, True, True, True, False, False],
            [True, True, True, False, True, False, False, True],
            [True, True, True, False, True, True, False, True],
            [True, True, True, True, False, True, False, True],
            [True, True, True, True, True, True, False, False],
            [True, True, True, True, True, True, True, True],
            [False, False, False, True, True, True, True, True],
            [False, True, False, True, False, True, True, True],
        ],
        dtype=bool,
    )

    assert_array_equal(extractor.descriptors, expected)
开发者ID:soupault,项目名称:scikit-image,代码行数:25,代码来源:test_brief.py

示例5: test_isodata_coins_image

def test_isodata_coins_image():
    coins = skimage.img_as_ubyte(data.coins())

    threshold = threshold_isodata(coins)
    assert np.floor((coins[coins <= threshold].mean() + coins[coins > threshold].mean()) / 2.0) == threshold
    assert threshold == 107

    assert threshold_isodata(coins, return_all=True) == [107]
开发者ID:Britefury,项目名称:scikit-image,代码行数:8,代码来源:test_thresholding.py

示例6: main

def main():
    """Load image, calculate optimal threshold, binarize, plot."""
    # load image
    img = data.coins()
    height, width = img.shape
    nb_pixels = height * width

    # precalculate some values for speedup
    # average pixel value
    g_avg = np.average(img)
    # P(pixel-value), i.e. #pixels-with-value / #all-pixels
    p_g = [0] * 256
    for g in range(0, 256):
        p_g[g] = np.sum(img == g) / nb_pixels

    # Otsu method
    # calculations are based on standard formulas
    q_best = None
    threshold_best = None
    img_bin_best = None
    # iterate over all possible thresholds
    for t in range(1, 255):
        img_bin = np.zeros(img.shape)
        img_bin[img >= t] = 1

        p1 = np.sum(img_bin) / nb_pixels
        p0 = 1 - p1

        g0 = np.average(img[img_bin == 0]) if np.sum(img[img_bin == 0]) > 0 else 0
        g1 = np.average(img[img_bin == 1]) if np.sum(img[img_bin == 1]) > 0 else 0

        var0 = sum([(g-g0)**2 * p_g[g] for g in range(0, t+1)])
        var1 = sum([(g-g1)**2 * p_g[g] for g in range(t+1, 256)])

        var_between = p0 * (g0 - g_avg)**2 + p1 * (g1 - g_avg)**2
        var_inner = p0 * var0**2 + p1 * var1**2

        # q is the relation of variance between classes and variance within classes
        q = var_between / var_inner if var_inner > 0 else 0

        print(t, p0, p1, g0, g1, g_avg, var_between, var_inner, q)
        if q_best is None or q_best < q:
            q_best = q
            threshold_best = t
            img_bin_best = img <= t

    # ground truth, based on scikit-image
    gt_tresh = skifilters.threshold_otsu(img)
    ground_truth = img <= gt_tresh

    # plot
    util.plot_images_grayscale(
        [img, img_bin_best, ground_truth],
        ["Image", "Otsu", "Otsu (Ground Truth)"]
    )
开发者ID:aleju,项目名称:computer-vision-algorithms,代码行数:55,代码来源:otsu.py

示例7: only_phase

def only_phase():
    im=data.coins()
    
    imf=np.fft.fft2(im)
    amp=np.abs(imf)
    phase=np.angle(imf)
    
    onlyample=np.uint8(np.abs(np.fft.ifft2(amp)))
    io.imsave('onlyample.png',onlyample)
    onlyphase=np.uint8(np.mean(amp)*np.abs(np.fft.ifft2(np.exp(1j*phase))))
    io.imsave('onlyphase.png',onlyphase)
开发者ID:xingnix,项目名称:learning,代码行数:11,代码来源:frequency.py

示例8: test_li_coins_image

def test_li_coins_image():
    image = skimage.img_as_ubyte(data.coins())
    threshold = threshold_li(image)
    ce_actual = _cross_entropy(image, threshold)
    assert 94 < threshold_li(image) < 95
    assert ce_actual < _cross_entropy(image, threshold + 1)
    # in the case of the coins image, the minimum cross-entropy is achieved one
    # threshold below that found by the iterative method. Not sure why that is
    # but `threshold_li` does find the stationary point of the function (ie the
    # tolerance can be reduced arbitrarily but the exact same threshold is
    # found), so my guess some kind of histogram binning effect.
    assert ce_actual < _cross_entropy(image, threshold - 2)
开发者ID:jmetz,项目名称:scikit-image,代码行数:12,代码来源:test_thresholding.py

示例9: test_mosiac_reference

 def test_mosiac_reference(self):
     """Check that a repeated mosaic of images is converted to optical
     depth.
     
     """
     # Prepare data
     coins = data.coins()
     mosaic = np.tile(coins, (4, 4))
     ref = np.random.rand(*coins.shape) + 1
     od = -np.log(coins/ref)
     expected = np.tile(od, (4, 4))
     # Call the reference correction function
     result = apply_mosaic_reference(mosaic, ref)
     np.testing.assert_almost_equal(result, expected)
开发者ID:m3wolf,项目名称:xanespy,代码行数:14,代码来源:test_math.py

示例10: _cv_main

def _cv_main():
    from skimage.data import camera
    from skimage.data import coins
    #U0 = plt.imread("rgb_tile_014_i01_j05 - crop.png")[:,:,0].astype('float')-0.5
    U0 = coins().astype('float')/255.
    print np.max(U0)
    cv = chan_vese(U0,mu=0.8,lambda1=1,lambda2=1,tol=1,maxiter=15,dt=100)
    print ("Chan-Vese algorithm finished after "+str(len(cv[1]))+" iterations.")
    print cv[1]
    plt.imshow(cv[0])
    plt.colorbar()
    plt.show()
    plt.plot(cv[1])
    plt.show()
    return
开发者ID:GGoussar,项目名称:scikit-image,代码行数:15,代码来源:chanvese.py

示例11: test_minsize

def test_minsize():
    # single-channel:
    img = data.coins()[20:168, 0:128]
    for min_size in np.arange(10, 100, 10):
        segments = felzenszwalb(img, min_size=min_size, sigma=3)
        counts = np.bincount(segments.ravel())
        # actually want to test greater or equal.
        assert_greater(counts.min() + 1, min_size)
    # multi-channel:
    coffee = data.coffee()[::4, ::4]
    for min_size in np.arange(10, 100, 10):
        segments = felzenszwalb(coffee, min_size=min_size, sigma=3)
        counts = np.bincount(segments.ravel())
        # actually want to test greater or equal.
        assert_greater(counts.min() + 1, min_size)
开发者ID:Cadair,项目名称:scikit-image,代码行数:15,代码来源:test_felzenszwalb.py

示例12: test_minsize

def test_minsize():
    # single-channel:
    img = data.coins()[20:168,0:128]
    for min_size in np.arange(10, 100, 10):
        segments = felzenszwalb(img, min_size=min_size, sigma=3)
        counts = np.bincount(segments.ravel())
        # actually want to test greater or equal.
        assert_greater(counts.min() + 1, min_size)
    # multi-channel:
    coffee = data.coffee()[::4, ::4]
    for min_size in np.arange(10, 100, 10):
        segments = felzenszwalb(coffee, min_size=min_size, sigma=3)
        counts = np.bincount(segments.ravel())
        # actually want to test greater or equal.
        # the construction doesn't guarantee min_size is respected
        # after intersecting the sementations for the colors
        assert_greater(np.mean(counts) + 1, min_size)
开发者ID:AceHao,项目名称:scikit-image,代码行数:17,代码来源:test_felzenszwalb.py

示例13: wiener_filter

def wiener_filter():
    im=data.coins()
    imf=np.fft.fft2(im)

    kernel=np.ones((1,20))
    kernel=kernel/np.sum(kernel)
    kf=np.fft.fft2(kernel,(im.shape[0],im.shape[1]))
    
    g=imf*kf
    im_g=np.uint8(np.abs(np.fft.ifft2(g)))
    h=np.fft.fft2(im_g)*np.conj(kf)/(0.001+np.abs(kf)**2)
    
    io.imsave('coins-wiener.png',np.uint8(np.abs(np.fft.ifft2(h))))
    
    im_gn=np.uint8(util.noise.random_noise(im_g,var=0.00001)*255)
    h=np.fft.fft2(im_gn)*np.conj(kf)/(0.001+np.abs(kf)**2)
    
    io.imsave('coins-wiener-noise.png',np.uint8(np.abs(np.fft.ifft2(h))))
开发者ID:xingnix,项目名称:learning,代码行数:18,代码来源:restore.py

示例14: test_viewer

def test_viewer():
    astro = data.astronaut()
    coins = data.coins()

    view = ImageViewer(astro)
    import tempfile
    _, filename = tempfile.mkstemp(suffix='.png')

    view.show(False)
    view.close()
    view.save_to_file(filename)
    view.open_file(filename)
    assert_equal(view.image, astro)
    view.image = coins
    assert_equal(view.image, coins),
    view.save_to_file(filename),
    view.open_file(filename),
    view.reset_image(),
    assert_equal(view.image, coins)
开发者ID:haohao200609,项目名称:Hybrid,代码行数:19,代码来源:test_viewer.py

示例15: test_viewer_with_overlay

def test_viewer_with_overlay():
    img = data.coins()
    ov = OverlayPlugin(image_filter=sobel)
    viewer = ImageViewer(img)
    viewer += ov

    import tempfile
    _, filename = tempfile.mkstemp(suffix='.png')

    ov.color = 3
    assert_equal(ov.color, 'yellow')
    viewer.save_to_file(filename)
    ov.display_filtered_image(img)
    assert_equal(ov.overlay, img)
    ov.overlay = None
    assert_equal(ov.overlay, None)
    ov.overlay = img
    assert_equal(ov.overlay, img)
    assert_equal(ov.filtered_image, img)
开发者ID:ramosapf,项目名称:scikit-image,代码行数:19,代码来源:test_viewer.py


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