

.. _example_cluster_plot_face_segmentation.py:


===================================================
Segmenting the picture of a raccoon face in regions
===================================================

This example uses :ref:`spectral_clustering` on a graph created from
voxel-to-voxel difference on an image to break this image into multiple
partly-homogeneous regions.

This procedure (spectral clustering on an image) is an efficient
approximate solution for finding normalized graph cuts.

There are two options to assign labels:

* with 'kmeans' spectral clustering will cluster samples in the embedding space
  using a kmeans algorithm
* whereas 'discrete' will iteratively search for the closest partition
  space to the embedding space.


**Python source code:** :download:`plot_face_segmentation.py <plot_face_segmentation.py>`

.. literalinclude:: plot_face_segmentation.py
    :lines: 20-
    