.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_advanced_image_processing_auto_examples_plot_geom_face.py: Geometrical transformations ============================== This examples demos some simple geometrical transformations on a Racoon face. .. image:: /advanced/image_processing/auto_examples/images/sphx_glr_plot_geom_face_001.png :class: sphx-glr-single-img .. code-block:: python import numpy as np import scipy.misc from scipy import ndimage import matplotlib.pyplot as plt face = scipy.misc.face(gray=True) lx, ly = face.shape # Cropping crop_face = face[lx//4:-lx//4, ly//4:-ly//4] # up <-> down flip flip_ud_face = np.flipud(face) # rotation rotate_face = ndimage.rotate(face, 45) rotate_face_noreshape = ndimage.rotate(face, 45, reshape=False) plt.figure(figsize=(12.5, 2.5)) plt.subplot(151) plt.imshow(face, cmap=plt.cm.gray) plt.axis('off') plt.subplot(152) plt.imshow(crop_face, cmap=plt.cm.gray) plt.axis('off') plt.subplot(153) plt.imshow(flip_ud_face, cmap=plt.cm.gray) plt.axis('off') plt.subplot(154) plt.imshow(rotate_face, cmap=plt.cm.gray) plt.axis('off') plt.subplot(155) plt.imshow(rotate_face_noreshape, cmap=plt.cm.gray) plt.axis('off') plt.subplots_adjust(wspace=0.02, hspace=0.3, top=1, bottom=0.1, left=0, right=1) plt.show() **Total running time of the script:** ( 0 minutes 0.460 seconds) .. _sphx_glr_download_advanced_image_processing_auto_examples_plot_geom_face.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_geom_face.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_geom_face.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_