Skip to content

Commit

Permalink
Update edges.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pontikos committed Sep 19, 2015
1 parent 03a9a1b commit b1ab552
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
from skimage.filters import roberts, sobel, scharr, prewitt

image = imread('images/Figure-41.jpg')

#green channel
image=image[:,:,1]

#edges = roberts(image)
edges = sobel(image)

Expand All @@ -21,5 +23,16 @@
plt.imshow(edges)
plt.show()

# probably need to threshold for clustering...

# do clustering
from sklearn import cluster
from sklearn.neighbors import kneighbors_graph
X = StandardScaler().fit_transform(X)
connectivity = kneighbors_graph(X, n_neighbors=10, include_self=False)
connectivity = 0.5 * (connectivity + connectivity.T)
clustering = cluster.AgglomerativeClustering(linkage="average", affinity="cityblock", connectivity=connectivity, n_clusters=5000)
clustering.fit(X)
np.savetxt('clusters.csv',ward.labels_.astype(np.int))


0 comments on commit b1ab552

Please sign in to comment.