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


Python data.camera函数代码示例

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


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


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