mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-12 12:30:16 +08:00
rebase and change API to support mpl colorspec
This commit is contained in:
@@ -1,25 +1,26 @@
|
||||
"""
|
||||
===========
|
||||
RAG Drawing
|
||||
===========
|
||||
=====================================
|
||||
Drawing Region Adjacency Graphs (RAGs)
|
||||
======================================
|
||||
|
||||
This example constructs a Region Adjacency Graph (RAG) and draws it with
|
||||
the `rag_draw` method.
|
||||
"""
|
||||
from skimage import graph, data, segmentation
|
||||
from matplotlib import pyplot as plt
|
||||
from matplotlib import pyplot as plt, colors
|
||||
|
||||
|
||||
img = data.coffee()
|
||||
labels = segmentation.slic(img, compactness=30, n_segments=400)
|
||||
g = graph.rag_mean_color(img, labels)
|
||||
|
||||
out = graph.rag_draw(labels, g, img)
|
||||
out = graph.draw_rag(labels, g, img)
|
||||
plt.figure()
|
||||
plt.title("RAG with all edges shown in green.")
|
||||
plt.imshow(out)
|
||||
|
||||
out = graph.rag_draw(labels, g, img, high_color=(1, 0, 0), thresh=30)
|
||||
cmap = colors.ListedColormap(['cyan', 'red'])
|
||||
out = graph.draw_rag(labels, g, img, colormap=cmap, thresh=30)
|
||||
plt.figure()
|
||||
plt.title("RAG with edge weights less than 30, color "
|
||||
"mapped between green and red.")
|
||||
|
||||
Reference in New Issue
Block a user