{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# Plot geometrical transformations on images\n",
    "\n",
    "Demo geometrical transformations of images.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "jupyter": {
     "outputs_hidden": false
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 434400 characters]",
      "text/plain": [
       "<Figure size 1500x300 with 5 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Load some data\n",
    "import scipy as sp\n",
    "\n",
    "face = sp.datasets.face(gray=True)\n",
    "\n",
    "# Apply a variety of transformations\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "shifted_face = sp.ndimage.shift(face, (50, 50))\n",
    "shifted_face2 = sp.ndimage.shift(face, (50, 50), mode=\"nearest\")\n",
    "rotated_face = sp.ndimage.rotate(face, 30)\n",
    "cropped_face = face[50:-50, 50:-50]\n",
    "zoomed_face = sp.ndimage.zoom(face, 2)\n",
    "zoomed_face.shape\n",
    "\n",
    "plt.figure(figsize=(15, 3))\n",
    "plt.subplot(151)\n",
    "plt.imshow(shifted_face, cmap=\"gray\")\n",
    "plt.axis(\"off\")\n",
    "\n",
    "plt.subplot(152)\n",
    "plt.imshow(shifted_face2, cmap=\"gray\")\n",
    "plt.axis(\"off\")\n",
    "\n",
    "plt.subplot(153)\n",
    "plt.imshow(rotated_face, cmap=\"gray\")\n",
    "plt.axis(\"off\")\n",
    "\n",
    "plt.subplot(154)\n",
    "plt.imshow(cropped_face, cmap=\"gray\")\n",
    "plt.axis(\"off\")\n",
    "\n",
    "plt.subplot(155)\n",
    "plt.imshow(zoomed_face, cmap=\"gray\")\n",
    "plt.axis(\"off\")\n",
    "\n",
    "plt.subplots_adjust(wspace=0.05, left=0.01, bottom=0.01, right=0.99, top=0.99)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
