.. _example_plot_view_as_blocks.py:


============================
Block views on images/arrays
============================

This example illustrates the use of `view_as_blocks` from
`skimage.util.shape`.  Block views can be incredibly useful when one
wants to perform local operations on non-overlapping image patches.

We use `lena` from `skimage.data` and virtually 'slice' it into square
blocks.  Then, on each block, we either pool the mean, the max or the
median value of that block. The results are displayed altogether, along
with a spline interpolation of order 3 rescaling of the original `lena`
image.


.. image:: images/plot_view_as_blocks_1.png
    :align: center


.. literalinclude:: plot_view_as_blocks.py
    :lines: 17-



**Python source code:** :download:`download <plot_view_as_blocks.py>`
(generated using ``skimage`` |version|)



**IPython Notebook:** :download:`download <./notebook/plot_view_as_blocks.ipynb>`
(generated using ``skimage`` |version|)

