July 2016
Beginner to intermediate
462 pages
9h 14m
English
Spectral clustering is a clustering technique that can be used to segment images. The scikit-learn spectral_clustering() function implements the normalized graph cuts spectral clustering algorithm. This algorithm represents an image as a graph of units. "Graph" here is the same mathematical concept as in Chapter 8, Text Mining and Social Network Analysis. The algorithm tries to partition the image, while minimizing segment size and the ratio of intensity gradient along cuts.
import numpy as np import matplotlib.pyplot as plt from sklearn.feature_extraction.image import img_to_graph from sklearn.cluster import spectral_clustering from sklearn.datasets import load_digits ...