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

.. only:: html

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

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

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

.. _sphx_glr_advanced_image_processing_auto_examples_plot_numpy_array.py:


Image manipulation and NumPy arrays
====================================

This example shows how to do image manipulation using common NumPy arrays
tricks.

.. GENERATED FROM PYTHON SOURCE LINES 9-30



.. image-sg:: /advanced/image_processing/auto_examples/images/sphx_glr_plot_numpy_array_001.png
   :alt: plot numpy array
   :srcset: /advanced/image_processing/auto_examples/images/sphx_glr_plot_numpy_array_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import numpy as np
    import scipy as sp
    import matplotlib.pyplot as plt

    face = sp.datasets.face(gray=True)
    face[10:13, 20:23]
    face[100:120] = 255

    lx, ly = face.shape
    X, Y = np.ogrid[0:lx, 0:ly]
    mask = (X - lx / 2) ** 2 + (Y - ly / 2) ** 2 > lx * ly / 4
    face[mask] = 0
    face[range(400), range(400)] = 255

    plt.figure(figsize=(3, 3))
    plt.axes((0, 0, 1, 1))
    plt.imshow(face, cmap="gray")
    plt.axis("off")

    plt.show()


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

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


.. _sphx_glr_download_advanced_image_processing_auto_examples_plot_numpy_array.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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