.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "advanced/image_processing/auto_examples/plot_geom_face.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` 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. .. GENERATED FROM PYTHON SOURCE LINES 7-45 .. image-sg:: /advanced/image_processing/auto_examples/images/sphx_glr_plot_geom_face_001.png :alt: plot geom face :srcset: /advanced/image_processing/auto_examples/images/sphx_glr_plot_geom_face_001.png :class: sphx-glr-single-img .. code-block:: default import numpy as np import scipy as sp import matplotlib.pyplot as plt face = sp.datasets.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 = sp.ndimage.rotate(face, 45) rotate_face_noreshape = sp.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() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.519 seconds) .. _sphx_glr_download_advanced_image_processing_auto_examples_plot_geom_face.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_geom_face.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_geom_face.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_