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

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_auto_examples_transform_plot_edge_modes.py>`
        to download the full example code.

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

.. _sphx_glr_auto_examples_transform_plot_edge_modes.py:


=========================
Interpolation: Edge Modes
=========================

This example illustrates the different edge modes available during
interpolation in routines such as :py:func:`skimage.transform.rescale`
and :py:func:`skimage.transform.resize`.

.. GENERATED FROM PYTHON SOURCE LINES 10-43



.. image-sg:: /auto_examples/transform/images/sphx_glr_plot_edge_modes_001.png
   :alt: constant, edge, wrap, reflect, symmetric
   :srcset: /auto_examples/transform/images/sphx_glr_plot_edge_modes_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import numpy as np
    import matplotlib.pyplot as plt


    img = np.zeros((16, 16))
    img[:8, :8] += 1
    img[:4, :4] += 1
    img[:2, :2] += 1
    img[:1, :1] += 2
    img[8, 8] = 4

    modes = ['constant', 'edge', 'wrap', 'reflect', 'symmetric']
    fig, axes = plt.subplots(2, 3)
    ax = axes.flatten()

    for n, mode in enumerate(modes):
        img_padded = np.pad(img, pad_width=img.shape[0], mode=mode)
        ax[n].imshow(img_padded, cmap=plt.cm.gray)
        ax[n].plot(
            [15.5, 15.5, 31.5, 31.5, 15.5],
            [15.5, 31.5, 31.5, 15.5, 15.5],
            'y--',
            linewidth=0.5,
        )
        ax[n].set_title(mode)

    for a in ax:
        a.set_axis_off()
        a.set_aspect('equal')

    plt.tight_layout()
    plt.show()


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

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


.. _sphx_glr_download_auto_examples_transform_plot_edge_modes.py:

.. only:: html

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

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

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

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

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

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_edge_modes.zip <plot_edge_modes.zip>`


.. only:: html

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

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