{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "287f4356",
            "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": "2624694c",
            "cell_type": "markdown",
            "source": "Use `affine_transform` to stretch an image\n```\n\n```",
            "metadata": {}
        },
        {
            "id": "471c8773",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.ndimage import affine_transform\nfrom scipy.datasets import face\nfrom matplotlib import pyplot as plt\nimport numpy as np\nim = face(gray=True)\nmatrix = (0.5, 2)\nim2 = affine_transform(im, matrix)\nplt.imshow(im2)\nplt.show()",
            "outputs": []
        },
        {
            "id": "7a4d9b95",
            "cell_type": "markdown",
            "source": "Rotate an image by 90 degrees and project it onto an expanded canvas\n```\n\n```",
            "metadata": {}
        },
        {
            "id": "92e4d558",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "matrix = ((0, 1), (1, 0))\nim3 = affine_transform(im, matrix, output_shape=(1024, 1024))\nplt.imshow(im3)\nplt.show()",
            "outputs": []
        },
        {
            "id": "deea26f1",
            "cell_type": "markdown",
            "source": "Offset the rotation so that the image is centred\n```\n\n```",
            "metadata": {}
        },
        {
            "id": "dd49b12f",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "output_shape = (1200, 1200)\noffset = (np.array(im.shape) - output_shape) / 2\nim4 = affine_transform(im, matrix, offset=offset, output_shape=output_shape)\nplt.imshow(im4)\nplt.show()",
            "outputs": []
        }
    ]
}