{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "d25b48e0",
            "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": "819eda29",
            "cell_type": "markdown",
            "source": "Compute the gradient of an image by 2D convolution with a complex Scharr\noperator.  (Horizontal operator is real, vertical is imaginary.)  Use\nsymmetric boundary condition to avoid creating edges at the image\nboundaries.\n",
            "metadata": {}
        },
        {
            "id": "0dbda143",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy import signal\nfrom scipy import datasets\nascent = datasets.ascent()\nscharr = np.array([[ -3-3j, 0-10j,  +3 -3j],\n                   [-10+0j, 0+ 0j, +10 +0j],\n                   [ -3+3j, 0+10j,  +3 +3j]]) # Gx + j*Gy\ngrad = signal.convolve2d(ascent, scharr, boundary='symm', mode='same')",
            "outputs": []
        },
        {
            "id": "0ddfba96",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nfig, (ax_orig, ax_mag, ax_ang) = plt.subplots(3, 1, figsize=(6, 15))\nax_orig.imshow(ascent, cmap='gray')\nax_orig.set_title('Original')\nax_orig.set_axis_off()\nax_mag.imshow(np.absolute(grad), cmap='gray')\nax_mag.set_title('Gradient magnitude')\nax_mag.set_axis_off()\nax_ang.imshow(np.angle(grad), cmap='hsv') # hsv is cyclic, like angles\nax_ang.set_title('Gradient orientation')\nax_ang.set_axis_off()\nfig.show()",
            "outputs": []
        }
    ]
}