コード例 #1
0
def test_build_gaussian_pyramid():
    rows, cols, dim = image.shape
    pyramid = build_gaussian_pyramid(image, downscale=2)

    for layer, out in enumerate(pyramid):
        layer_shape = (rows / 2 ** layer, cols / 2 ** layer, dim)
        assert_array_equal(out.shape, layer_shape)
コード例 #2
0
The `build_gauassian_pyramid` function takes an image and yields successive
images shrunk by a constant scale factor. Image pyramids are often used, e.g.,
to implement algorithms for denoising, texture discrimination, and scale-
invariant detection.
"""

import numpy as np
import matplotlib.pyplot as plt

from skimage import data
from skimage.transform import build_gaussian_pyramid


image = data.lena()
rows, cols, dim = image.shape
pyramid = tuple(build_gaussian_pyramid(image, downscale=2))

composite_image = np.zeros((rows, cols + cols / 2, 3), dtype=np.double)

composite_image[:rows, :cols, :] = pyramid[0]

i_row = 0
for p in pyramid[1:]:
    n_rows, n_cols = p.shape[:2]
    composite_image[i_row:i_row + n_rows, cols:cols + n_cols] = p
    i_row += n_rows

plt.imshow(composite_image)
plt.show()
コード例 #3
0
=====================
CollectionViewer demo
=====================

Demo of CollectionViewer for viewing collections of images. This demo uses
the different layers of the gaussian pyramid as image collection.

You can scroll through images with the slider, or you can interact with the
viewer using your keyboard:

left/right arrows
    Previous/next image in collection.
number keys, 0--9
    0% to 90% of collection. For example, "5" goes to the image in the
    middle (i.e. 50%) of the collection.
home/end keys
    First/last image in collection.

"""
import numpy as np
from skimage import data
from skimage.viewer import CollectionViewer
from skimage.transform import build_gaussian_pyramid


img = data.lena()
img_collection = tuple(build_gaussian_pyramid(img))

view = CollectionViewer(img_collection)
view.show()