Build image pyramidsΒΆ

The pyramid_gaussian 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.

../_images/plot_pyramid_1.png

import numpy as np
import matplotlib.pyplot as plt

from skimage import data
from skimage.transform import pyramid_gaussian


image = data.lena()
rows, cols, dim = image.shape
pyramid = tuple(pyramid_gaussian(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

fig, ax = plt.subplots()
ax.imshow(composite_image)
plt.show()

STDOUT


        

STDERR


        

Python source code: download (generated using skimage 0.11dev)

IPython Notebook: download (generated using skimage 0.11dev)

aW1wb3J0IG51bXB5IGFzIG5wCmltcG9ydCBtYXRwbG90bGliLnB5cGxvdCBhcyBwbHQKCmZyb20gc2tpbWFnZSBpbXBvcnQgZGF0YQpmcm9tIHNraW1hZ2UudHJhbnNmb3JtIGltcG9ydCBweXJhbWlkX2dhdXNzaWFuCgoKaW1hZ2UgPSBkYXRhLmxlbmEoKQpyb3dzLCBjb2xzLCBkaW0gPSBpbWFnZS5zaGFwZQpweXJhbWlkID0gdHVwbGUocHlyYW1pZF9nYXVzc2lhbihpbWFnZSwgZG93bnNjYWxlPTIpKQoKY29tcG9zaXRlX2ltYWdlID0gbnAuemVyb3MoKHJvd3MsIGNvbHMgKyBjb2xzIC8gMiwgMyksIGR0eXBlPW5wLmRvdWJsZSkKCmNvbXBvc2l0ZV9pbWFnZVs6cm93cywgOmNvbHMsIDpdID0gcHlyYW1pZFswXQoKaV9yb3cgPSAwCmZvciBwIGluIHB5cmFtaWRbMTpdOgogICAgbl9yb3dzLCBuX2NvbHMgPSBwLnNoYXBlWzoyXQogICAgY29tcG9zaXRlX2ltYWdlW2lfcm93Omlfcm93ICsgbl9yb3dzLCBjb2xzOmNvbHMgKyBuX2NvbHNdID0gcAogICAgaV9yb3cgKz0gbl9yb3dzCgpmaWcsIGF4ID0gcGx0LnN1YnBsb3RzKCkKYXguaW1zaG93KGNvbXBvc2l0ZV9pbWFnZSkKcGx0LnNob3coKQ==