Clustering, Spectral Clustering, Machine Learning, Data Science, Python.
SpectralClustering(n_clusters=n_clusters, affinity='precomputed', random_state=42) labels = sc.fit_predict(graph) # Reshape back to the original image dimension labels = labels.reshape(img.shape) # Display the segmented image plt.figure(figsize=(5, 5)) plt.imshow(labels, cmap=plt.cm.nipy_spectral)