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


Python data.checkerboard函数代码示例

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


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

示例1: test_swirl

def test_swirl():
    image = img_as_float(data.checkerboard())

    swirl_params = {'radius': 80, 'rotation': 0, 'order': 2, 'mode': 'reflect'}
    swirled = tf.swirl(image, strength=10, **swirl_params)
    unswirled = tf.swirl(swirled, strength=-10, **swirl_params)

    assert np.mean(np.abs(image - unswirled)) < 0.01
开发者ID:aeweiwi,项目名称:scikit-image,代码行数:8,代码来源:test_warps.py

示例2: test_probabilistic_hough_seed

def test_probabilistic_hough_seed():
    # Load image that is likely to give a randomly varying number of lines
    image = data.checkerboard()

    # Use constant seed to ensure a deterministic output
    lines = transform.probabilistic_hough_line(image, threshold=50,
                                               line_length=50, line_gap=1,
                                               seed=1234)
    assert len(lines) == 65
开发者ID:Cadair,项目名称:scikit-image,代码行数:9,代码来源:test_hough_transform.py

示例3: test_swirl

def test_swirl():
    image = img_as_float(data.checkerboard())

    swirl_params = {'radius': 80, 'rotation': 0, 'order': 2, 'mode': 'reflect'}

    with expected_warnings(['Bi-quadratic.*bug']):
        swirled = tf.swirl(image, strength=10, **swirl_params)
        unswirled = tf.swirl(swirled, strength=-10, **swirl_params)

    assert np.mean(np.abs(image - unswirled)) < 0.01
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:10,代码来源:test_warps.py

示例4: main

def main():
    """Load image, calculate harris scores (window functions: matrix of ones, gauss)
    and plot the results."""
    img = data.checkerboard()
    score_window = harris_ones(img, 7)
    score_gauss = harris_gauss(img)
    util.plot_images_grayscale(
        [img, score_window, score_gauss, feature.corner_harris(img)],
        ["Image", "Harris-Score (ones)", "Harris-Score (gauss)", "Harris-Score (ground truth)"]
    )
开发者ID:aleju,项目名称:computer-vision-algorithms,代码行数:10,代码来源:harris.py

示例5: main

def main():
    """Apply several gaussian filters one by one and plot the results each time."""
    img = data.checkerboard()
    shapes = [(5, 5), (7, 7), (11, 11), (17, 17), (31, 31)]
    sigmas = [0.5, 1.0, 2.0, 4.0, 8.0]
    smoothed = []
    for shape, sigma in zip(shapes, sigmas):
        smoothed = apply_gauss(img, gaussian_kernel(shape, sigma=sigma))
        ground_truth = filters.gaussian_filter(img, sigma)
        util.plot_images_grayscale(
            [img, smoothed, ground_truth],
            ["Image", "After gauss (sigma=%.1f)" % (sigma), "Ground Truth (scipy)"]
        )
开发者ID:aleju,项目名称:computer-vision-algorithms,代码行数:13,代码来源:gauss.py

示例6: 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

示例7: swirl

    \phi = \mathtt{rotation}

    s = \mathtt{strength}

    \\theta' = \phi + s \, e^{-\\rho / r + \\theta}

where ``strength`` is a parameter for the amount of swirl, ``radius`` indicates
the swirl extent in pixels, and ``rotation`` adds a rotation angle.  The
transformation of ``radius`` into :math:`r` is to ensure that the
transformation decays to :math:`\\approx 1/1000^{\mathsf{th}}` within the
specified radius.

"""
import matplotlib.pyplot as plt

from skimage import data
from skimage.transform import swirl


image = data.checkerboard()
swirled = swirl(image, rotation=0, strength=10, radius=120, order=2)

fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'})

ax0.imshow(image, cmap=plt.cm.gray, interpolation='none')
ax0.axis('off')
ax1.imshow(swirled, cmap=plt.cm.gray, interpolation='none')
ax1.axis('off')

plt.show()
开发者ID:ClinicalGraphics,项目名称:scikit-image,代码行数:30,代码来源:plot_swirl.py

示例8: test_checkerboard

def test_checkerboard():
    """ Test that "checkerboard" image can be loaded. """
    data.checkerboard()
开发者ID:Gildus,项目名称:scikit-image,代码行数:3,代码来源:test_data.py

示例9: AffineTransform

to robustly estimate the parameter set by detecting outliers.

"""
import numpy as np
from matplotlib import pyplot as plt

from skimage import data
from skimage.feature import corner_harris, corner_subpix, corner_peaks
from skimage.transform import warp, AffineTransform
from skimage.exposure import rescale_intensity
from skimage.color import rgb2gray
from skimage.measure import ransac


# generate synthetic checkerboard image and add gradient for the later matching
checkerboard = data.checkerboard()
img_orig = np.zeros(list(checkerboard.shape) + [3])
img_orig[..., 0] = checkerboard
gradient_r, gradient_c = np.mgrid[0:img_orig.shape[0], 0:img_orig.shape[1]]
img_orig[..., 1] = gradient_r
img_orig[..., 2] = gradient_c
img_orig = rescale_intensity(img_orig)
img_orig_gray = rgb2gray(img_orig)

# warp synthetic image
tform = AffineTransform(scale=(0.9, 0.9), rotation=0.2, translation=(20, -10))
img_warped = warp(img_orig, tform.inverse, output_shape=(200, 200))
img_warped_gray = rgb2gray(img_warped)

# extract corners using Harris' corner measure
coords_orig = corner_peaks(corner_harris(img_orig_gray), threshold_rel=0.001,
开发者ID:bdholt1,项目名称:scikit-image,代码行数:31,代码来源:plot_matching.py

示例10: test_checkerboard

def test_checkerboard():
    """ Test that checkerboard image can be loaded. """
    checkerboard = data.checkerboard()
开发者ID:amueller,项目名称:scikit-image,代码行数:3,代码来源:test_data.py

示例11: img_as_float

    PYWAVELET_ND_INDEXING_WARNING = None

try:
    import dask
except ImportError:
    DASK_NOT_INSTALLED_WARNING = 'The optional dask dependency is not installed'
else:
    DASK_NOT_INSTALLED_WARNING = None


np.random.seed(1234)


astro = img_as_float(data.astronaut()[:128, :128])
astro_gray = color.rgb2gray(astro)
checkerboard_gray = img_as_float(data.checkerboard())
checkerboard = color.gray2rgb(checkerboard_gray)


def test_denoise_tv_chambolle_2d():
    # astronaut image
    img = astro_gray.copy()
    # add noise to astronaut
    img += 0.5 * img.std() * np.random.rand(*img.shape)
    # clip noise so that it does not exceed allowed range for float images.
    img = np.clip(img, 0, 1)
    # denoise
    denoised_astro = restoration.denoise_tv_chambolle(img, weight=0.1)
    # which dtype?
    assert_(denoised_astro.dtype in [np.float, np.float32, np.float64])
    from scipy import ndimage as ndi
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:31,代码来源:test_denoise.py

示例12: AffineTransform

"""
Affine transform
=================

Warping and affine transforms of images.
"""

from matplotlib import pyplot as plt

from skimage import data
from skimage.feature import corner_harris, corner_subpix, corner_peaks
from skimage.transform import warp, AffineTransform


tform = AffineTransform(scale=(1.3, 1.1), rotation=1, shear=0.7,
                        translation=(210, 50))
image = warp(data.checkerboard(), tform.inverse, output_shape=(350, 350))

coords = corner_peaks(corner_harris(image), min_distance=5)
coords_subpix = corner_subpix(image, coords, window_size=13)

plt.gray()
plt.imshow(image, interpolation='nearest')
plt.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r', markersize=15, mew=5)
plt.plot(coords[:, 1], coords[:, 0], '.b', markersize=7)
plt.axis('off')
plt.show()
开发者ID:Andor-Z,项目名称:scipy-lecture-notes-zh-CN,代码行数:27,代码来源:plot_features.py

示例13: img_as_float

# -*- coding: utf-8 -*-
"""
Created on Mon Sep 21 13:10:04 2015

@author: prassanna
"""

###FILTERS AND BLURRING############

from skimage import filter,io,data,color,feature,img_as_float
from matplotlib import pyplot as plt
import numpy as np

img = img_as_float(data.checkerboard());
print img.shape
io.imshow(img)

##Gaussian
noisy = img + 0.6 * img.std() * np.random.random(img.shape)
noisy = np.clip(noisy, 0, 1)
blurred = filter.gaussian_filter(noisy, 2);
#blurred_int = np.uint8(blurred*255)
#print np.amax(blurred_int)
bla = np.vstack((img,noisy,blurred))
io.imshow(bla)


#2nd Gaussian
from math import sqrt
img_2  = data.hubble_deep_field()
img_2  = img_2 [0:500,0:500]
开发者ID:atemysemicolon,项目名称:PyBCN,代码行数:31,代码来源:tut2-filters.py

示例14: test

def test():
    import matplotlib.pyplot as plt
    from skimage import io, data, transform
    from iib.simulation import CLContext

    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)
    #sq = np.arange(256).astype(np.float32).reshape((16, 16)) / 255.0
    #sigs[:, :, 0] = np.tile(sq, (16, 16))
    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()

    entropy = get_entropy(clctx, feats, rdctn, bufi)
    print("Average entropy:", entropy)

    variance = get_variance(clctx, feats, rdctn, bufi)
    print("Variance:", variance)

    edges = get_edges(clctx, feats, rdctn, blur4, bufi, summarise=False)
    edge_counts = get_edges(clctx, feats, rdctn, blur4, bufi)
    print("Edge pixel counts:", edge_counts)

    blobs = get_blobs(clctx, feats, rdctn, blur2, bufi, summarise=False)

    features = get_features(clctx, feats, rdctn, blur2, blur4, bufi)
    print("Feature vector:")
    print(features)

    # Plot the edges and blobs
    for i in range(4):
        plt.subplot(4, 3, i*3+1)
        img = sigs.reshape((gs, gs, 4))[:, :, i]
        plt.imshow(img, cmap="gray")
        plt.xticks([])
        plt.yticks([])

        plt.subplot(4, 3, i*3+2)
        img = edges.reshape((gs, gs, 4))[:, :, i]
        plt.imshow(img, cmap="gray")
        plt.xticks([])
        plt.yticks([])

        ax = plt.subplot(4, 3, i*3+3)
        img = sigs.reshape((gs, gs, 4))[:, :, i]
        plt.imshow(img, cmap="gray")
        plt.xticks([])
        plt.yticks([])
        for j in range(len(blobs)):
            sblobs = blobs[j]
            s = 2**(j+1)
            r = np.sqrt(2.0) * s
            im = sblobs[:, :, i]
            posns = np.transpose(im.nonzero()) * 2**(j+1)
            for xy in posns:
                circ = plt.Circle((xy[1], xy[0]), r, color="green", fill=False)
                ax.add_patch(circ)
    plt.show()
开发者ID:adamgreig,项目名称:iib,代码行数:82,代码来源:features.py

示例15: int

arg1 = sys.argv[1]

if int(arg1):
    print "using autojit"

autojit = autojit if int(arg1) else lambda: (lambda x: x)
jit = jit if int(arg1) else lambda x: (lambda x: x)

print autojit

print "generating checkerboard"
t = time.time()
tform = AffineTransform(scale=(1.3, 1.1), rotation=1, shear=0.7,
                            translation=(210, 50))
image = warp(data.checkerboard(), tform.inverse, output_shape=(5000, 5000))
# rr, cc = ellipse(310, 175, 100, 100)
#
# image[rr, cc] = 1
print "took", time.time() - t

print "generating squares"

@jit('void()')
def generate_squares_niave():
    for i in range(0, 5*50, 50):
        for j in range(180 + i, 230 + i):
            for k in range(10 + i, 60 + i):
                image[j, k] = 1
        for j in range(230 + i, 280 + i):
            for k in range(60 + i, 110 + i):
开发者ID:asmeurer,项目名称:numba-test,代码行数:30,代码来源:test.py


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