
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/transform/plot_pyramid.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_examples_transform_plot_pyramid.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_transform_plot_pyramid.py:


====================
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.

.. GENERATED FROM PYTHON SOURCE LINES 12-36



.. image-sg:: /auto_examples/transform/images/sphx_glr_plot_pyramid_001.png
   :alt: plot pyramid
   :srcset: /auto_examples/transform/images/sphx_glr_plot_pyramid_001.png
   :class: sphx-glr-single-img





.. code-block:: default

    import numpy as np
    import matplotlib.pyplot as plt

    from skimage import data
    from skimage.transform import pyramid_gaussian


    image = data.astronaut()
    rows, cols, dim = image.shape
    pyramid = tuple(pyramid_gaussian(image, downscale=2, channel_axis=-1))

    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()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.193 seconds)


.. _sphx_glr_download_auto_examples_transform_plot_pyramid.py:


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: plot_pyramid.py <plot_pyramid.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_pyramid.ipynb <plot_pyramid.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
