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

Python data.lena函数代码示例

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

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



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

示例1: test_tv_denoise_2d

 def test_tv_denoise_2d(self):
     """
     Apply the TV denoising algorithm on the lena image provided
     by scipy
     """
     # lena image
     lena = color.rgb2gray(data.lena())[:256, :256]
     # add noise to lena
     lena += 0.5 * lena.std() * np.random.randn(*lena.shape)
     # clip noise so that it does not exceed allowed range for float images.
     lena = np.clip(lena, 0, 1)
     # denoise
     denoised_lena = filter.tv_denoise(lena, weight=60.0)
     # which dtype?
     assert denoised_lena.dtype in [np.float, np.float32, np.float64]
     from scipy import ndimage
     grad = ndimage.morphological_gradient(lena, size=((3, 3)))
     grad_denoised = ndimage.morphological_gradient(
         denoised_lena, size=((3, 3)))
     # test if the total variation has decreased
     assert np.sqrt(
         (grad_denoised ** 2).sum()) < np.sqrt((grad ** 2).sum()) / 2
     denoised_lena_int = filter.tv_denoise(img_as_uint(lena),
                                           weight=60.0, keep_type=True)
     assert denoised_lena_int.dtype is np.dtype('uint16')
开发者ID:amueller,项目名称:scikit-image,代码行数:25,代码来源:test_tv_denoise.py


示例2: test_daisy_normalization

def test_daisy_normalization():
    img = img_as_float(data.lena()[:64, :64].mean(axis=2))

    descs = daisy(img, normalization='l1')
    for i in range(descs.shape[0]):
        for j in range(descs.shape[1]):
            assert_almost_equal(np.sum(descs[i, j, :]), 1)
    descs_ = daisy(img)
    assert_almost_equal(descs, descs_)

    descs = daisy(img, normalization='l2')
    for i in range(descs.shape[0]):
        for j in range(descs.shape[1]):
            assert_almost_equal(sqrt(np.sum(descs[i, j, :] ** 2)), 1)

    orientations = 8
    descs = daisy(img, orientations=orientations, normalization='daisy')
    desc_dims = descs.shape[2]
    for i in range(descs.shape[0]):
        for j in range(descs.shape[1]):
            for k in range(0, desc_dims, orientations):
                assert_almost_equal(sqrt(np.sum(
                    descs[i, j, k:k + orientations] ** 2)), 1)

    img = np.zeros((50, 50))
    descs = daisy(img, normalization='off')
    for i in range(descs.shape[0]):
        for j in range(descs.shape[1]):
            assert_almost_equal(np.sum(descs[i, j, :]), 0)

    assert_raises(ValueError, daisy, img, normalization='does_not_exist')
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:31,代码来源:test_daisy.py


示例3: test_rotated_lena

def test_rotated_lena():
    """
    The harris filter should yield the same results with an image and it's
    rotation.
    """
    im = img_as_float(data.lena().mean(axis=2))
    im_rotated = im.T

    # Moravec
    results = peak_local_max(corner_moravec(im))
    results_rotated = peak_local_max(corner_moravec(im_rotated))
    assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
    assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()

    # Harris
    results = peak_local_max(corner_harris(im))
    results_rotated = peak_local_max(corner_harris(im_rotated))
    assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
    assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()

    # Shi-Tomasi
    results = peak_local_max(corner_shi_tomasi(im))
    results_rotated = peak_local_max(corner_shi_tomasi(im_rotated))
    assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
    assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
开发者ID:almarklein,项目名称:scikit-image,代码行数:25,代码来源:test_corner.py


示例4: test_fast_homography

def test_fast_homography():
    img = rgb2gray(data.lena()).astype(np.uint8)
    img = img[:, :100]

    theta = np.deg2rad(30)
    scale = 0.5
    tx, ty = 50, 50

    H = np.eye(3)
    S = scale * np.sin(theta)
    C = scale * np.cos(theta)

    H[:2, :2] = [[C, -S], [S, C]]
    H[:2, 2] = [tx, ty]

    tform = ProjectiveTransform(H)
    coords = warp_coords(tform.inverse, (img.shape[0], img.shape[1]))

    for order in range(4):
        for mode in ('constant', 'reflect', 'wrap', 'nearest'):
            p0 = map_coordinates(img, coords, mode=mode, order=order)
            p1 = warp(img, tform, mode=mode, order=order)

            # import matplotlib.pyplot as plt
            # f, (ax0, ax1, ax2, ax3) = plt.subplots(1, 4)
            # ax0.imshow(img)
            # ax1.imshow(p0, cmap=plt.cm.gray)
            # ax2.imshow(p1, cmap=plt.cm.gray)
            # ax3.imshow(np.abs(p0 - p1), cmap=plt.cm.gray)
            # plt.show()

            d = np.mean(np.abs(p0 - p1))
            assert d < 0.001
开发者ID:aeweiwi,项目名称:scikit-image,代码行数:33,代码来源:test_warps.py


示例5: test_theano_overfeat_against_binary

def test_theano_overfeat_against_binary():
    layer_correspondence = dict(
        normal=dict(
            large=[(0, 0, None), (1, 2, None), (2, 3, None), (3, 5, None),
                   (4, 6, None), (5, 9, None), (6, 12, None), (7, 15, None),
                   (8, 18, None), (9, 19, None), (10, 21, None),
                   (11, 23, None), (12, 24, None)],
            small=[(0, 0, None), (1, 2, None), (2, 3, None), (3, 5, None),
                   (4, 6, None), (5, 9, None), (6, 12, None), (7, 15, None),
                   (8, 16, None), (9, 18, None), (10, 20, None), 
                   (11, 21, None)]),
        detailed=dict(
            large=[(i, i, None) for i in range(25)],
            small=[(i, i, None) for i in range(22)]
            )
        )

    rng = np.random.RandomState(42)
    image = (rng.rand(320, 320, 3) * 255).astype(np.uint8)
    from skimage.data import lena
    image = lena()

    for detailed, correspondences in layer_correspondence.items():
        for net_size, correspondence in correspondences.items():
            for theano_layer, binary_layer, cropping in correspondence:
                _check_overfeat_layer(image, theano_layer, binary_layer,
                                      net_size == 'large',
                                      detailed == 'detailed',
                                      cropping=cropping)
开发者ID:Faruk-Ahmed,项目名称:sklearn-theano,代码行数:29,代码来源:test_overfeat.py


示例6: test_lena

def test_lena():

    from skimage import data
    from skimage import color
    from skimage.transform import resize

    in_shape = (200, 200)
    n_imgs = 1

    lena = resize(color.rgb2gray(data.lena()), in_shape).astype(np.float32)
    lena -= lena.min()
    lena /= lena.max()

    imgs = lena.reshape((n_imgs,) + in_shape)

    model = cnnr.models.fg11_ht_l3_1_description
    extractor = cnnr.BatchExtractor(in_shape, model)

    feat_set, _ = extractor.extract(imgs)

    assert feat_set.shape == (n_imgs, 10, 10, 256)

    feat_set.shape = n_imgs, -1
    test_chunk_computed = feat_set[0, 12798:12802]

    test_chunk_expected = np.array([0.03845372, 0.02469639, 0.01009409, 0.02500059], dtype=np.float32)

    assert_allclose(test_chunk_computed, test_chunk_expected, rtol=RTOL, atol=ATOL)
开发者ID:luca-bondi,项目名称:convnet-rfw,代码行数:28,代码来源:test_extractor.py


示例7: test_corner_orientations_lena

def test_corner_orientations_lena():
    img = rgb2gray(data.lena())
    corners = corner_peaks(corner_fast(img, 11, 0.35))
    expected = np.array([-1.9195897 , -3.03159624, -1.05991162, -2.89573739,
                         -2.61607644, 2.98660159])
    actual = corner_orientations(img, corners, octagon(3, 2))
    assert_almost_equal(actual, expected)
开发者ID:AlexG31,项目名称:scikit-image,代码行数:7,代码来源:test_corner.py


示例8: test_fast_homography

def test_fast_homography():
    img = rgb2gray(data.lena()).astype(np.uint8)
    img = img[:, :100]

    theta = np.deg2rad(30)
    scale = 0.5
    tx, ty = 50, 50

    H = np.eye(3)
    S = scale * np.sin(theta)
    C = scale * np.cos(theta)

    H[:2, :2] = [[C, -S], [S, C]]
    H[:2, 2] = [tx, ty]

    for mode in ('constant', 'mirror', 'wrap'):
        p0 = homography(img, H, mode=mode, order=1)
        p1 = fast_homography(img, H, mode=mode)
        p1 = np.round(p1)

        ## import matplotlib.pyplot as plt
        ## f, (ax0, ax1, ax2, ax3) = plt.subplots(1, 4)
        ## ax0.imshow(img)
        ## ax1.imshow(p0, cmap=plt.cm.gray)
        ## ax2.imshow(p1, cmap=plt.cm.gray)
        ## ax3.imshow(np.abs(p0 - p1), cmap=plt.cm.gray)
        ## plt.show()

        d = np.mean(np.abs(p0 - p1))
        assert d < 0.2
开发者ID:NeilYager,项目名称:scikits-image,代码行数:30,代码来源:test_warps.py


示例9: main

def main():
    """Plot example augmentations for Lena and an image loaded from a file."""

    # try on a lena image
    image = data.lena()
    augmenter = ImageAugmenter(image.shape[0], image.shape[1],
                               hflip=True, vflip=True,
                               scale_to_percent=1.3, scale_axis_equally=False,
                               rotation_deg=25, shear_deg=10,
                               translation_x_px=5, translation_y_px=5)

    augmenter.plot_image(image, 100)

    # check loading of images from file and augmenting them
    image = misc.imread("chameleon.png")
    augmenter = ImageAugmenter(image.shape[1], image.shape[0],
                               hflip=True, vflip=True,
                               scale_to_percent=1.3, scale_axis_equally=False,
                               rotation_deg=25, shear_deg=10,
                               translation_x_px=5, translation_y_px=5)

    augmenter.plot_image(image, 50)

    # move the channel from index 2 (3rd position) to index 0 (1st position)
    # so (y, x, rgb) becomes (rgb, y, x)
    # try if it still works
    image = np.rollaxis(image, 2, 0)
    augmenter = ImageAugmenter(image.shape[2], image.shape[1],
                               hflip=True, vflip=True,
                               scale_to_percent=1.3, scale_axis_equally=False,
                               rotation_deg=25, shear_deg=10,
                               translation_x_px=5, translation_y_px=5,
                               channel_is_first_axis=True)
    augmenter.plot_image(image, 50)
开发者ID:aleju,项目名称:ImageAugmenter,代码行数:34,代码来源:CheckPlotImages.py


示例10: test_binary_descriptors_lena_rotation_crosscheck_true

def test_binary_descriptors_lena_rotation_crosscheck_true():
    """Verify matched keypoints and their corresponding masks results between
    lena image and its rotated version with the expected keypoint pairs with
    cross_check enabled."""
    img = data.lena()
    img = rgb2gray(img)
    tform = tf.SimilarityTransform(scale=1, rotation=0.15, translation=(0, 0))
    rotated_img = tf.warp(img, tform)

    extractor = BRIEF(descriptor_size=512)

    keypoints1 = corner_peaks(corner_harris(img), min_distance=5)
    extractor.extract(img, keypoints1)
    descriptors1 = extractor.descriptors

    keypoints2 = corner_peaks(corner_harris(rotated_img), min_distance=5)
    extractor.extract(rotated_img, keypoints2)
    descriptors2 = extractor.descriptors

    matches = match_descriptors(descriptors1, descriptors2, cross_check=True)

    exp_matches1 = np.array([ 0,  1,  2,  4,  6,  7,  9, 10, 11, 12, 13, 15,
                               16, 17, 19, 20, 21, 24, 26, 27, 28, 29, 30, 35,
                               36, 38, 39, 40, 42, 44, 45])
    exp_matches2 = np.array([33,  0, 35,  1,  3,  2,  6,  4,  9, 11, 10,  7,
                                8,  5, 14, 13, 15, 16, 17, 18, 19, 21, 22, 24,
                                23, 26, 27, 25, 28, 29, 30])
    assert_equal(matches[:, 0], exp_matches1)
    assert_equal(matches[:, 1], exp_matches2)
开发者ID:A-0-,项目名称:scikit-image,代码行数:29,代码来源:test_match.py


示例11: lena

def lena(gray=True, small=True):
    im = data.lena()
    if small:
        im = imresize(im, size=(im.shape[0] / 4, im.shape[1] / 4))
    if gray:
        im = im.mean(axis=2)
    return im
开发者ID:NelleV,项目名称:IMANU,代码行数:7,代码来源:data.py


示例12: plot_lena_overlay

def plot_lena_overlay():
    plt.figure()
    logo = ScipyLogo((300, 300), 180)
    logo.plot_snake_curve()
    logo.plot_circle()
    img = data.lena()
    plt.imshow(img)
开发者ID:Rapternmn,项目名称:scikit-image,代码行数:7,代码来源:scipy_logo.py


示例13: test_histogram_of_oriented_gradients

def test_histogram_of_oriented_gradients():
    img = img_as_float(data.lena()[:256, :].mean(axis=2))

    fd = feature.hog(img, orientations=9, pixels_per_cell=(8, 8),
                     cells_per_block=(1, 1))

    assert len(fd) == 9 * (256 // 8) * (512 // 8)
开发者ID:A-0-,项目名称:scikit-image,代码行数:7,代码来源:test_hog.py


示例14: test_keypoints_orb_less_than_desired_no_of_keypoints

def test_keypoints_orb_less_than_desired_no_of_keypoints():
    img = rgb2gray(lena())
    detector_extractor = ORB(n_keypoints=15, fast_n=12,
                             fast_threshold=0.33, downscale=2, n_scales=2)
    detector_extractor.detect(img)

    exp_rows = np.array([  67.,  247.,  269.,  413.,  435.,  230.,  264.,
                          330.,  372.])
    exp_cols = np.array([ 157.,  146.,  111.,   70.,  180.,  136.,  336.,
                          148.,  156.])

    exp_scales = np.array([ 1.,  1.,  1.,  1.,  1.,  2.,  2.,  2.,  2.])

    exp_orientations = np.array([-105.76503839,  -96.28973044,  -53.08162354,
                                 -173.4479964 , -175.64733392, -106.07927215,
                                 -163.40016243,   75.80865813, -154.73195911])

    exp_response = np.array([ 0.13197835,  0.24931321,  0.44351774,
                              0.39063076,  0.96770745,  0.04935129,
                              0.21431068,  0.15826555,  0.42403573])

    assert_almost_equal(exp_rows, detector_extractor.keypoints[:, 0])
    assert_almost_equal(exp_cols, detector_extractor.keypoints[:, 1])
    assert_almost_equal(exp_scales, detector_extractor.scales)
    assert_almost_equal(exp_response, detector_extractor.responses)
    assert_almost_equal(exp_orientations,
                        np.rad2deg(detector_extractor.orientations), 5)

    detector_extractor.detect_and_extract(img)
    assert_almost_equal(exp_rows, detector_extractor.keypoints[:, 0])
    assert_almost_equal(exp_cols, detector_extractor.keypoints[:, 1])
开发者ID:A-0-,项目名称:scikit-image,代码行数:31,代码来源:test_orb.py


示例15: test

def test():
    img = skimage.img_as_float(data.lena())
    img_size = img.shape[:2]

    trans = get_transform(20,15,1.05, 0.02, img_size)
    img_transformed = transform.warp(img, trans)
    obj_func = lambda x: transform_and_compare(img_transformed, img, x)
    x0 = np.array([0,0,1, 0])
    results = optimize.fmin_bfgs(obj_func, x0)

    transform_estimated = get_simple_transform(results) 
    transform_optimal = transform.AffineTransform(np.linalg.inv(trans._matrix))
    params_optimal = np.concatenate([transform_optimal.translation,
                                    transform_optimal.scale[0:1],
                                    [transform_optimal.rotation]])
    img_registered = transform.warp(img_transformed, 
                                    transform_estimated)
    err_original = mean_sq_diff(img_transformed, img)
    err_optimal = transform_and_compare(img_transformed, img, params_optimal) 
    err_actual = transform_and_compare(img_transformed, img, results) 
    err_relative = err_optimal/err_original
    
    print "Params optimal:", params_optimal
    print "Params estimated:", results
    print "Error without registration:", err_original
    print "Error of optimal registration:", err_optimal 
    print "Error of estimated transformation %f (%.2f %% of intial)" % (err_actual,
                                                            err_relative*100.)

    plt.figure()
    plt.subplot(121)
    plt.imshow(img_transformed)
    plt.subplot(122)
    plt.imshow(img_registered)
开发者ID:btel,项目名称:imageregistration,代码行数:34,代码来源:registration.py


示例16: test_original_images

    def test_original_images(self):
        images = self.manager.original_images()
        n_images = sum(1 for _ in images)
        self.assertEqual(n_images, 1)

        lena = data.lena()
        for image in images:
            self.assertEqual(image.shape, lena.shape)
开发者ID:IshitaTakeshi,项目名称:ClothingRecommenderML,代码行数:8,代码来源:test_dataset.py


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


示例18: test_tv_denoise_float_result_range

 def test_tv_denoise_float_result_range(self):
     # lena image
     lena = color.rgb2gray(data.lena())[:256, :256]
     int_lena = np.multiply(lena, 255).astype(np.uint8)
     assert np.max(int_lena) > 1       
     denoised_int_lena = filter.tv_denoise(int_lena, weight=60.0)
     # test if the value range of output float data is within [0.0:1.0]
     assert denoised_int_lena.dtype == np.float
     assert np.max(denoised_int_lena) <= 1.0
     assert np.min(denoised_int_lena) >= 0.0        
开发者ID:GerardoLopez,项目名称:scikits-image,代码行数:10,代码来源:test_tv_denoise.py


示例19: test_rotated_lena

 def test_rotated_lena(self):
     """
     The harris filter should yield the same results with an image and it's
     rotation.
     """
     im = img_as_float(data.lena().mean(axis=2))
     results = harris(im)
     im_rotated = im.T
     results_rotated = harris(im_rotated)
     assert (results[:, 0] == results_rotated[:, 1]).all()
开发者ID:rajnishs91,项目名称:scikits-image,代码行数:10,代码来源:test_harris.py


示例20: test_num_peaks

def test_num_peaks():
    """For a bunch of different values of num_peaks, check that
    peak_local_max returns exactly the right amount of peaks. Test
    is run on Lena in order to produce a sufficient number of corners"""

    lena_corners = corner_harris(data.lena())

    for i in range(20):
        n = np.random.random_integers(20)
        results = peak_local_max(lena_corners, num_peaks=n)
        assert (results.shape[0] == n)
开发者ID:almarklein,项目名称:scikit-image,代码行数:11,代码来源:test_corner.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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