{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Using simple NumPy operations for manipulating images\n\nThis script illustrates how to use basic NumPy operations, such as slicing,\nmasking and fancy indexing, in order to modify the pixel values of an image.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport skimage as ski\nimport matplotlib.pyplot as plt\n\ncamera = ski.data.camera()\ncamera[:10] = 0\nmask = camera < 87\ncamera[mask] = 255\ninds_x = np.arange(len(camera))\ninds_y = (4 * inds_x) % len(camera)\ncamera[inds_x, inds_y] = 0\n\nl_x, l_y = camera.shape[0], camera.shape[1]\nX, Y = np.ogrid[:l_x, :l_y]\nouter_disk_mask = (X - l_x / 2) ** 2 + (Y - l_y / 2) ** 2 > (l_x / 2) ** 2\ncamera[outer_disk_mask] = 0\n\nplt.figure(figsize=(4, 4))\nplt.imshow(camera, cmap='gray')\nplt.axis('off')\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
}