{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Interpolation: Edge Modes\n\nThis example illustrates the different edge modes available during\ninterpolation in routines such as :py:func:`skimage.transform.rescale`\nand :py:func:`skimage.transform.resize`.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt\n\n\nimg = np.zeros((16, 16))\nimg[:8, :8] += 1\nimg[:4, :4] += 1\nimg[:2, :2] += 1\nimg[:1, :1] += 2\nimg[8, 8] = 4\n\nmodes = ['constant', 'edge', 'wrap', 'reflect', 'symmetric']\nfig, axes = plt.subplots(2, 3)\nax = axes.flatten()\n\nfor n, mode in enumerate(modes):\n    img_padded = np.pad(img, pad_width=img.shape[0], mode=mode)\n    ax[n].imshow(img_padded, cmap=plt.cm.gray)\n    ax[n].plot(\n        [15.5, 15.5, 31.5, 31.5, 15.5],\n        [15.5, 31.5, 31.5, 15.5, 15.5],\n        'y--',\n        linewidth=0.5,\n    )\n    ax[n].set_title(mode)\n\nfor a in ax:\n    a.set_axis_off()\n    a.set_aspect('equal')\n\nplt.tight_layout()\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "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.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}