.. _example_segmentation_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 is much slower than global thresholding

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


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


.. literalinclude:: plot_local_otsu.py
    :lines: 18-



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



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

