
# https://www.globalsino.com/ICs/
# Clustering of Laplacian


from sklearn.datasets import make_circles
# from sklearn.neighbors import kneighbors_graph

# Apply clustering to a projection of the normalized Laplacian
from sklearn.cluster import SpectralClustering

import numpy as np
import matplotlib.pyplot as plt
import cv2

# S generates data
# X, labels = make_circles(n_samples=500, noise=0.14, factor=.2)

X = cv2.imread(r'C:\GlobalSino2\ICs\images\4367.jpg',cv2.IMREAD_GRAYSCALE)

 # Visual data
plt.scatter(X[:, 0], X[:, 1])
plt.show()

 # Training and prediction
s_cluster = SpectralClustering(n_clusters = 2, eigen_solver='arpack',
        affinity="nearest_neighbors").fit_predict(X)

 # Visual results
plt.scatter(X[:, 0], X[:, 1], c = s_cluster)
plt.show()
