.. _example_plot_local_otsu.py:


=====================
Local Otsu Threshold
=====================
This example shows how Otsu's threshold [1]_ method can be applied locally.
For each pixel, an "optimal" threshold is determined by maximizing the variance between two classes of pixels
of the local neighborhood defined by a structuring element.

The example compares the local threshold with the global threshold.

.. note: local threshold is much slower than global one.

.. [1] http://en.wikipedia.org/wiki/Otsu's_method


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


.. literalinclude:: plot_local_otsu.py
    :lines: 16-



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

