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

.. only:: html

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

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

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

.. _sphx_glr_intro_scipy_auto_examples_plot_image_transform.py:


============================================
Plot geometrical transformations on images
============================================

Demo geometrical transformations of images.

.. GENERATED FROM PYTHON SOURCE LINES 8-48



.. image-sg:: /intro/scipy/auto_examples/images/sphx_glr_plot_image_transform_001.png
   :alt: plot image transform
   :srcset: /intro/scipy/auto_examples/images/sphx_glr_plot_image_transform_001.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    Downloading file 'face.dat' from 'https://raw.githubusercontent.com/scipy/dataset-face/main/face.dat' to '/home/runner/.cache/scipy-data'.






|

.. code-block:: Python


    # Load some data
    import scipy as sp

    face = sp.datasets.face(gray=True)

    # Apply a variety of transformations
    import matplotlib.pyplot as plt

    shifted_face = sp.ndimage.shift(face, (50, 50))
    shifted_face2 = sp.ndimage.shift(face, (50, 50), mode="nearest")
    rotated_face = sp.ndimage.rotate(face, 30)
    cropped_face = face[50:-50, 50:-50]
    zoomed_face = sp.ndimage.zoom(face, 2)
    zoomed_face.shape

    plt.figure(figsize=(15, 3))
    plt.subplot(151)
    plt.imshow(shifted_face, cmap="gray")
    plt.axis("off")

    plt.subplot(152)
    plt.imshow(shifted_face2, cmap="gray")
    plt.axis("off")

    plt.subplot(153)
    plt.imshow(rotated_face, cmap="gray")
    plt.axis("off")

    plt.subplot(154)
    plt.imshow(cropped_face, cmap="gray")
    plt.axis("off")

    plt.subplot(155)
    plt.imshow(zoomed_face, cmap="gray")
    plt.axis("off")

    plt.subplots_adjust(wspace=0.05, left=0.01, bottom=0.01, right=0.99, top=0.99)

    plt.show()


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

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


.. _sphx_glr_download_intro_scipy_auto_examples_plot_image_transform.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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