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

Python data.camera函数代码示例

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

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



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

示例1: main

def main():
    """Load image, apply sobel (to get x/y gradients), plot the results."""
    img = data.camera()

    sobel_y = np.array([[-1, -2, -1], [0, 0, 0], [1, 2, 1]])
    sobel_x = np.rot90(sobel_y)  # rotates counter-clockwise

    # apply x/y sobel filter to get x/y gradients
    img_sx = signal.correlate(img, sobel_x, mode="same")
    img_sy = signal.correlate(img, sobel_y, mode="same")

    # combine x/y gradients to gradient magnitude
    # scikit-image's implementation divides by sqrt(2), not sure why
    img_s = np.sqrt(img_sx ** 2 + img_sy ** 2) / np.sqrt(2)

    # create binarized image
    threshold = np.average(img_s)
    img_s_bin = np.zeros(img_s.shape)
    img_s_bin[img_s > threshold] = 1

    # generate ground truth (scikit-image method)
    ground_truth = skifilters.sobel(data.camera())

    # plot
    util.plot_images_grayscale(
        [img, img_sx, img_sy, img_s, img_s_bin, ground_truth],
        [
            "Image",
            "Sobel (x)",
            "Sobel (y)",
            "Sobel (magnitude)",
            "Sobel (magnitude, binarized)",
            "Sobel (Ground Truth)",
        ],
    )
开发者ID:aleju,项目名称:computer-vision-algorithms,代码行数:35,代码来源:sobel.py


示例2: test_rect_tool

def test_rect_tool():
    img = data.camera()
    viewer = ImageViewer(img)

    tool = RectangleTool(viewer.ax, maxdist=10)
    tool.extents = (100, 150, 100, 150)

    assert_equal(tool.corners,
                 ((100, 150, 150, 100), (100, 100, 150, 150)))
    assert_equal(tool.extents, (100, 150, 100, 150))
    assert_equal(tool.edge_centers,
                 ((100, 125.0, 150, 125.0), (125.0, 100, 125.0, 150)))
    assert_equal(tool.geometry, (100, 150, 100, 150))

    # grab a corner and move it
    grab = create_mouse_event(viewer.ax, xdata=100, ydata=100)
    tool.press(grab)
    move = create_mouse_event(viewer.ax, xdata=120, ydata=120)
    tool.onmove(move)
    tool.release(move)
    assert_equal(tool.geometry, [120, 150, 120, 150])

    # create a new line
    new = create_mouse_event(viewer.ax, xdata=10, ydata=10)
    tool.press(new)
    move = create_mouse_event(viewer.ax, xdata=100, ydata=100)
    tool.onmove(move)
    tool.release(move)
    assert_equal(tool.geometry, [10, 100,  10, 100])
开发者ID:SiggyF,项目名称:scikit-image,代码行数:29,代码来源:test_tools.py


示例3: test_image_stack_correlation

def test_image_stack_correlation():
    num_levels = 1
    num_bufs = 2  # must be even
    coins = data.camera()
    coins_stack = []

    for i in range(4):
        coins_stack.append(coins)

    coins_mesh = np.zeros_like(coins)
    coins_mesh[coins < 30] = 1
    coins_mesh[coins > 50] = 2

    g2, lag_steps = corr.multi_tau_auto_corr(num_levels, num_bufs, coins_mesh, coins_stack)

    assert np.all(g2[:, 0], axis=0)
    assert np.all(g2[:, 1], axis=0)

    num_buf = 5

    # check the number of buffers are even
    assert_raises(ValueError, lambda: corr.multi_tau_auto_corr(num_levels, num_buf, coins_mesh, coins_stack))
    # check image shape and labels shape are equal
    # assert_raises(ValueError,
    #            lambda : corr.multi_tau_auto_corr(num_levels, num_bufs,
    #                                                indices, coins_stack))

    # check the number of pixels is zero
    mesh = np.zeros_like(coins)
    assert_raises(ValueError, lambda: corr.multi_tau_auto_corr(num_levels, num_bufs, mesh, coins_stack))
开发者ID:pavoljuhas,项目名称:scikit-beam,代码行数:30,代码来源:test_correlation.py


示例4: test_li_camera_image

def test_li_camera_image():
    image = skimage.img_as_ubyte(data.camera())
    threshold = threshold_li(image)
    ce_actual = _cross_entropy(image, threshold)
    assert 62 < threshold_li(image) < 63
    assert ce_actual < _cross_entropy(image, threshold + 1)
    assert ce_actual < _cross_entropy(image, threshold - 1)
开发者ID:jmetz,项目名称:scikit-image,代码行数:7,代码来源:test_thresholding.py


示例5: test_masked_registration_random_masks_non_equal_sizes

def test_masked_registration_random_masks_non_equal_sizes():
    """masked_register_translation should be able to register
    translations between images that are not the same size even
    with random masks."""
    # See random number generator for reproducible results
    np.random.seed(23)

    reference_image = camera()
    shift = (-7, 12)
    shifted = np.real(np.fft.ifft2(fourier_shift(
        np.fft.fft2(reference_image), shift)))

    # Crop the shifted image
    shifted = shifted[64:-64, 64:-64]

    # Random masks with 75% of pixels being valid
    ref_mask = np.random.choice(
        [True, False], reference_image.shape, p=[3 / 4, 1 / 4])
    shifted_mask = np.random.choice(
        [True, False], shifted.shape, p=[3 / 4, 1 / 4])

    measured_shift = masked_register_translation(
        reference_image,
        shifted,
        np.ones_like(ref_mask),
        np.ones_like(shifted_mask))
    assert_equal(measured_shift, -np.array(shift))
开发者ID:TheArindham,项目名称:scikit-image,代码行数:27,代码来源:test_masked_register_translation.py


示例6: main

def main():
    """Load template image (needle) and the large example image (haystack),
    generate matching score per pixel, plot the results."""
    img_haystack = skiutil.img_as_float(data.camera()) # the image in which to search
    img_needle = img_haystack[140:190, 220:270] # the template to search for
    img_sad = np.zeros(img_haystack.shape) # score image

    height_h, width_h = img_haystack.shape
    height_n, width_n = img_needle.shape

    # calculate score for each pixel
    # stop iterating over pixels when the whole template cannot any more (i.e. stop
    # at bottom and right border)
    for y in range(height_h - height_n):
        for x in range(width_h - width_n):
            patch = img_haystack[y:y+height_n, x:x+width_n]
            img_sad[y, x] = sad(img_needle, patch)
    img_sad = img_sad / np.max(img_sad)

    # add highest score to bottom and right borders
    img_sad[height_h-height_n:, :] = np.max(img_sad[0:height_h, 0:width_h])
    img_sad[:, width_h-width_n:] = np.max(img_sad[0:height_h, 0:width_h])

    # plot results
    util.plot_images_grayscale(
        [img_haystack, img_needle, img_sad],
        ["Image", "Image (Search Template)", "Matching (darkest = best match)"]
    )
开发者ID:aleju,项目名称:computer-vision-algorithms,代码行数:28,代码来源:template_matching.py


示例7: setUp

    def setUp(self):
        self.seed = 1234

        self.BATCH_SIZE = 10
        self.num_batches = 1000

        np.random.seed(self.seed)

        ### 2D initialiazations

        cam = data.camera()
        self.cam = cam[np.newaxis, np.newaxis, :, :]

        self.cam_left = self.cam[:,:,:,::-1]
        self.cam_updown = self.cam[:,:,::-1,:]
        self.cam_updown_left = self.cam[:,:,::-1,::-1]

        self.x_2D = self.cam
        self.y_2D = self.cam

        ### 3D initialiazations

        self.cam_3D = np.random.rand(20,20,20)[np.newaxis, np.newaxis, :, :, :]

        self.cam_3D_left = self.cam_3D[:,:,:,::-1,:]
        self.cam_3D_updown = self.cam_3D[:,:,::-1,:,:]
        self.cam_3D_updown_left = self.cam_3D[:,:,::-1,::-1,:]

        self.cam_3D_left_z = self.cam_3D_left[:,:,:,:,::-1]
        self.cam_3D_updown_z = self.cam_3D_updown[:,:,:,:,::-1]
        self.cam_3D_updown_left_z = self.cam_3D_updown_left[:,:,:,:,::-1]
        self.cam_3D_z = self.cam_3D[:,:,:,:,::-1]

        self.x_3D = self.cam_3D
        self.y_3D = self.cam_3D
开发者ID:doctoryfx,项目名称:batchgenerators,代码行数:35,代码来源:test_axis_mirroring.py


示例8: run

def run():
#  img = np.ones((8,8))
  img = data.camera()
#  sp.misc.imsave('woop_orig.png', img)
#  img_f = np.fft.fft2(img)
#  print img.shape
#  print img_f.shape
#  sigma = 4
#  img_f = fft2_deriv(img_f, sigma, 3, 3)
#  img = np.fft.ifft2(img_f).real
#  print np.max(img), np.min(img)
#  sp.misc.imsave('woop.png', img)
#  img = data.camera()
#  img = gaussian_filter(img, sigma)
#  sp.misc.imsave('woop_gaussian_filter.png', img)
#  return
#  y,x = np.mgrid[-50:51,-50:51]
#  img = exp(- (x**2 + y**2)/(2.*1**2))
#  print img
#  print img_f
#  sp.misc.imsave('img_s.png', img)
#  sp.misc.imsave('img_f.png', img_f.real)
#  sp.misc.imsave('img_f_.png', img_f.imag)
#  img = sp.misc.imread('img.png',flatten=True)
  jets = jet(img)
开发者ID:andersbll,项目名称:meat_tracing,代码行数:25,代码来源:jet.py


示例9: test_compare_8bit_vs_16bit

def test_compare_8bit_vs_16bit():
    # filters applied on 8-bit image ore 16-bit image (having only real 8-bit
    # of dynamic) should be identical

    image8 = util.img_as_ubyte(data.camera())
    image16 = image8.astype(np.uint16)
    assert_equal(image8, image16)

    methods = [
        "autolevel",
        "bottomhat",
        "equalize",
        "gradient",
        "maximum",
        "mean",
        "subtract_mean",
        "median",
        "minimum",
        "modal",
        "enhance_contrast",
        "pop",
        "threshold",
        "tophat",
    ]

    for method in methods:
        func = getattr(rank, method)
        f8 = func(image8, disk(3))
        f16 = func(image16, disk(3))
        assert_equal(f8, f16)
开发者ID:YangChuan80,项目名称:scikit-image,代码行数:30,代码来源:test_rank.py


示例10: test_rect_tool

def test_rect_tool():
    img = data.camera()
    viewer = ImageViewer(img)

    tool = RectangleTool(viewer, maxdist=10)
    tool.extents = (100, 150, 100, 150)

    assert_equal(tool.corners,
                 ((100, 150, 150, 100), (100, 100, 150, 150)))
    assert_equal(tool.extents, (100, 150, 100, 150))
    assert_equal(tool.edge_centers,
                 ((100, 125.0, 150, 125.0), (125.0, 100, 125.0, 150)))
    assert_equal(tool.geometry, (100, 150, 100, 150))

    # grab a corner and move it
    do_event(viewer, 'mouse_press', xdata=100, ydata=100)
    do_event(viewer, 'move', xdata=120, ydata=120)
    do_event(viewer, 'mouse_release')
    # assert_equal(tool.geometry, [120, 150, 120, 150])

    # create a new line
    do_event(viewer, 'mouse_press', xdata=10, ydata=10)
    do_event(viewer, 'move', xdata=100, ydata=100)
    do_event(viewer, 'mouse_release')
    assert_equal(tool.geometry, [10, 100,  10, 100])
开发者ID:jarrodmillman,项目名称:scikit-image,代码行数:25,代码来源:test_tools.py


示例11: test_crop

def test_crop():
    image = data.camera()
    viewer = ImageViewer(image)
    c = Crop()
    viewer += c

    c.crop((0, 100, 0, 100))
    assert_equal(viewer.image.shape, (101, 101))
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:8,代码来源:test_plugins.py


示例12: test_isodata_camera_image

def test_isodata_camera_image():
    camera = skimage.img_as_ubyte(data.camera())

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

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


示例13: test_threshold_minimum

def test_threshold_minimum():
    camera = skimage.img_as_ubyte(data.camera())

    threshold = threshold_minimum(camera)
    assert_equal(threshold, 76)

    astronaut = skimage.img_as_ubyte(data.astronaut())
    threshold = threshold_minimum(astronaut)
    assert_equal(threshold, 114)
开发者ID:andreydung,项目名称:scikit-image,代码行数:9,代码来源:test_thresholding.py


示例14: test_is_rgb

def test_is_rgb():
    color = data.lena()
    gray = data.camera()

    assert is_rgb(color)
    assert not is_gray(color)

    assert is_gray(gray)
    assert not is_gray(color)
开发者ID:seberg,项目名称:scikit-image,代码行数:9,代码来源:test_colorconv.py


示例15: test_measure

def test_measure():
    image = data.camera()
    viewer = ImageViewer(image)
    m = Measure()
    viewer += m

    m.line_changed([(0, 0), (10, 10)])
    assert_equal(str(m._length.text), '14.1')
    assert_equal(str(m._angle.text[:5]), '135.0')
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:9,代码来源:test_plugins.py


示例16: 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:andreydung,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py


示例17: 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:andreydung,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py


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


示例19: test_canny

def test_canny():
    image = data.camera()
    viewer = ImageViewer(image)
    c = CannyPlugin()
    viewer += c

    canny_edges = viewer.show(False)
    viewer.close()
    edges = canny_edges[0][0]
    assert edges.sum() == 2852
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:10,代码来源:test_plugins.py


示例20: 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:andreydung,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python data.checkerboard函数代码示例发布时间:2022-05-27
下一篇:
Python data.astronaut函数代码示例发布时间: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