forked from lilstipher/DatascienceChallenge3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoug.py
More file actions
23 lines (18 loc) · 621 Bytes
/
goug.py
File metadata and controls
23 lines (18 loc) · 621 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from skimage.future import graph
from skimage import data, segmentation, color, filters, io
from matplotlib import pyplot as plt
from PIL import Image
import numpy as np
input_filename="azeer.jpg"
im = Image.open(input_filename)
img = np.array(im)
#img = data.coffee()
gimg = color.rgb2gray(img)
labels = segmentation.slic(img, compactness=30, n_segments=2000)
edges = filters.sobel(gimg)
edges_rgb = color.gray2rgb(edges)
g = graph.rag_boundary(labels, edges)
lc = graph.show_rag(labels, g, edges_rgb, img_cmap=None, edge_cmap='viridis',
edge_width=1.2)
plt.colorbar(lc, fraction=0.03)
io.show()