• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python data.coins函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_normal_mode

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

    keypoints = corner_peaks(corner_harris(img), min_distance=5)

    extractor = BRIEF(descriptor_size=8, sigma=2)

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

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

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


示例17: geometry_transform

def geometry_transform():
    im=data.coins()
    imtf=np.zeros(im.shape,dtype=np.uint8)
    x,y=im.shape
    s=y/2
    for i in range(x):
        for j in range(y):
            newj=s+np.sign(j-s)*(np.abs(j-s)/s)**2*s
            if newj>=0 and newj<y:
                imtf[i,j]=im[i,np.int(newj)]
    io.imsave('coins-tf.png',imtf)
    
    iminv=np.zeros(im.shape,dtype=np.uint8)
    for i in range(x):
        for j in range(y):
            newj=s+np.sign(j-s)*np.sqrt(np.abs(j-s)/s)*s
            if newj>=0 and newj<y:
                iminv[i,j]=imtf[i,np.int(newj)]
    io.imsave('coins-inverse-tf.png',iminv)
    
    
开发者ID:xingnix,项目名称:learning,代码行数:19,代码来源:restore.py


示例18: inverse_filter

def inverse_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)/(0.01+kf)
    
    io.imsave('coins.png',im)
    io.imsave('coins-blur.png',im_g)
    io.imsave('coins-deblur.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)/(0.01+kf)
    
    io.imsave('coins-blur-noise.png',im_gn)
    io.imsave('coins-deblur-noise.png',np.uint8(np.abs(np.fft.ifft2(h))))
开发者ID:xingnix,项目名称:learning,代码行数:21,代码来源:restore.py


示例19: draw

    def draw(self):
        if not hasattr(self, 'ax'):
            self.axOriginal = self.figure.add_subplot(221)
            self.axGreyScale = self.figure.add_subplot(222)
            self.axFiltered = self.figure.add_subplot(223)
            self.axSegments = self.figure.add_subplot(224)
            self.image = data.coins()
#            self.image = imread(self.image_file)

        self.axOriginal.set_title("Original Image", fontsize=12)
        self.axOriginal.imshow(self.image)
        
        self.axGreyScale.set_title("Greyscale Image", fontsize=12)
        self.grey_image = color.rgb2grey(self.image)
        self.axGreyScale.imshow(self.grey_image, cmap = cm.Greys_r)

        self.filter_image()
#        thresh = threshold_otsu(self.grey_image)
#        self.bw_image = closing(self.grey_image > thresh, square(1))
#        self.axThreshold.imshow(self.bw_image)
        
        self.axSegments.set_title("Segmented Image", fontsize=12)
        
        self.label_image = label(self.filtered)
#        borders = np.logical_xor(self.bw_image, self.cleared)
#        self.label_image[borders] = -1
        
#        fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(6, 6))
        self.axSegments.imshow(self.label_image, cmap='jet')
        
        for region in regionprops(self.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)
            self.axSegments.add_patch(rect)
开发者ID:bchoatejr,项目名称:math,代码行数:40,代码来源:ImageSegmentAdjust.py


示例20: profile

def profile():
    import time
    from iib.simulation import CLContext
    from skimage import io, data, transform
    gs, wgs = 256, 16

    # Load some test data
    r = transform.resize
    sigs = np.empty((gs, gs, 4), np.float32)
    sigs[:, :, 0] = r(data.coins().astype(np.float32) / 255.0, (gs, gs))
    sigs[:, :, 1] = r(data.camera().astype(np.float32) / 255.0, (gs, gs))
    sigs[:, :, 2] = r(data.text().astype(np.float32) / 255.0, (gs, gs))
    sigs[:, :, 3] = r(data.checkerboard().astype(np.float32) / 255.0, (gs, gs))
    sigs[:, :, 2] = r(io.imread("../scoring/corpus/rds/turing_001.png",
                                as_grey=True), (gs, gs))
    sigs[:, :, 3] = io.imread("../scoring/corpus/synthetic/blobs.png",
                              as_grey=True)
    sigs = sigs.reshape(gs*gs*4)

    # Set up OpenCL
    ctx = cl.create_some_context(interactive=False)
    queue = cl.CommandQueue(ctx)
    mf = cl.mem_flags
    ifmt_f = cl.ImageFormat(cl.channel_order.RGBA, cl.channel_type.FLOAT)
    bufi = cl.Image(ctx, mf.READ_ONLY, ifmt_f, (gs, gs))
    cl.enqueue_copy(queue, bufi, sigs, origin=(0, 0), region=(gs, gs))
    clctx = CLContext(ctx, queue, ifmt_f, gs, wgs)

    # Compile the kernels
    feats = cl.Program(ctx, features_cl()).build()
    rdctn = cl.Program(ctx, reduction.reduction_sum_cl()).build()
    blur2 = cl.Program(ctx, convolution.gaussian_cl([np.sqrt(2.0)]*4)).build()
    blur4 = cl.Program(ctx, convolution.gaussian_cl([np.sqrt(4.0)]*4)).build()

    iters = 500
    t0 = time.time()
    for i in range(iters):
        get_features(clctx, feats, rdctn, blur2, blur4, bufi)
    print((time.time() - t0)/iters)
开发者ID:adamgreig,项目名称:iib,代码行数:39,代码来源:features.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python data.imread函数代码示例发布时间:2022-05-27
下一篇:
Python data.coffee函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap