{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "c5c43c1f",
            "cell_type": "markdown",
            "source": "<div class='alert alert-warning'>\n\nSciPy's interactive examples with Jupyterlite are experimental and may not always work as expected. Execution of cells containing imports may result in large downloads (up to 60MB of content for the first import from SciPy). Load times when importing from SciPy may take roughly 10-20 seconds. If you notice any problems, feel free to open an [issue](https://github.com/scipy/scipy/issues/new/choose).\n\n</div>",
            "metadata": {}
        },
        {
            "id": "7d1333c4",
            "cell_type": "markdown",
            "source": "Import the necessary modules and an exemplary image.\n",
            "metadata": {}
        },
        {
            "id": "6419207b",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.ndimage import shift\nimport matplotlib.pyplot as plt\nfrom scipy import datasets\nimage = datasets.ascent()",
            "outputs": []
        },
        {
            "id": "dbf98d6e",
            "cell_type": "markdown",
            "source": "Shift the image vertically by 20 pixels.\n",
            "metadata": {}
        },
        {
            "id": "9576e411",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "image_shifted_vertically = shift(image, (20, 0))",
            "outputs": []
        },
        {
            "id": "0704ed1b",
            "cell_type": "markdown",
            "source": "Shift the image vertically by -200 pixels and horizontally by 100 pixels.\n",
            "metadata": {}
        },
        {
            "id": "fc7ade75",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "image_shifted_both_directions = shift(image, (-200, 100))",
            "outputs": []
        },
        {
            "id": "1964418e",
            "cell_type": "markdown",
            "source": "Plot the original and the shifted images.\n",
            "metadata": {}
        },
        {
            "id": "86b88587",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "fig, axes = plt.subplots(3, 1, figsize=(4, 12))\nplt.gray()  # show the filtered result in grayscale\ntop, middle, bottom = axes\nfor ax in axes:\n    ax.set_axis_off()  # remove coordinate system\ntop.imshow(image)\ntop.set_title(\"Original image\")\nmiddle.imshow(image_shifted_vertically)\nmiddle.set_title(\"Vertically shifted image\")\nbottom.imshow(image_shifted_both_directions)\nbottom.set_title(\"Image shifted in both directions\")\nfig.tight_layout()",
            "outputs": []
        }
    ]
}