.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` 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. .. image:: /intro/scipy/auto_examples/images/sphx_glr_plot_image_transform_001.png :class: sphx-glr-single-img .. code-block:: python # Load some data from scipy import misc face = misc.face(gray=True) # Apply a variety of transformations from scipy import ndimage from matplotlib import pyplot as plt shifted_face = ndimage.shift(face, (50, 50)) shifted_face2 = ndimage.shift(face, (50, 50), mode='nearest') rotated_face = ndimage.rotate(face, 30) cropped_face = face[50:-50, 50:-50] zoomed_face = ndimage.zoom(face, 2) zoomed_face.shape plt.figure(figsize=(15, 3)) plt.subplot(151) plt.imshow(shifted_face, cmap=plt.cm.gray) plt.axis('off') plt.subplot(152) plt.imshow(shifted_face2, cmap=plt.cm.gray) plt.axis('off') plt.subplot(153) plt.imshow(rotated_face, cmap=plt.cm.gray) plt.axis('off') plt.subplot(154) plt.imshow(cropped_face, cmap=plt.cm.gray) plt.axis('off') plt.subplot(155) plt.imshow(zoomed_face, cmap=plt.cm.gray) plt.axis('off') plt.subplots_adjust(wspace=.05, left=.01, bottom=.01, right=.99, top=.99) plt.show() **Total running time of the script:** ( 0 minutes 0.773 seconds) .. _sphx_glr_download_intro_scipy_auto_examples_plot_image_transform.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_image_transform.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_image_transform.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_