
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/numpy_operations/plot_camera_numpy.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_numpy_operations_plot_camera_numpy.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_numpy_operations_plot_camera_numpy.py:


Using simple NumPy operations for manipulating images
=====================================================

This script illustrates how to use basic NumPy operations, such as slicing,
masking and fancy indexing, in order to modify the pixel values of an image.

.. GENERATED FROM PYTHON SOURCE LINES 8-30



.. image-sg:: /auto_examples/numpy_operations/images/sphx_glr_plot_camera_numpy_001.png
   :alt: plot camera numpy
   :srcset: /auto_examples/numpy_operations/images/sphx_glr_plot_camera_numpy_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import numpy as np
    import skimage as ski
    import matplotlib.pyplot as plt

    camera = ski.data.camera()
    camera[:10] = 0
    mask = camera < 87
    camera[mask] = 255
    inds_x = np.arange(len(camera))
    inds_y = (4 * inds_x) % len(camera)
    camera[inds_x, inds_y] = 0

    l_x, l_y = camera.shape[0], camera.shape[1]
    X, Y = np.ogrid[:l_x, :l_y]
    outer_disk_mask = (X - l_x / 2) ** 2 + (Y - l_y / 2) ** 2 > (l_x / 2) ** 2
    camera[outer_disk_mask] = 0

    plt.figure(figsize=(4, 4))
    plt.imshow(camera, cmap='gray')
    plt.axis('off')
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.163 seconds)


.. _sphx_glr_download_auto_examples_numpy_operations_plot_camera_numpy.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_camera_numpy.ipynb <plot_camera_numpy.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_camera_numpy.py <plot_camera_numpy.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_camera_numpy.zip <plot_camera_numpy.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
