mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-26 13:37:17 +08:00
FIX Tried to address @stefanv's comments on the PR.
This commit is contained in:
@@ -33,24 +33,22 @@ segments = quickshift(img, kernel_size=5, max_dist=20)
|
||||
|
||||
print("number of segments: %d" % len(np.unique(segments)))
|
||||
|
||||
plt.subplot(131, title="original")
|
||||
plt.imshow(img, interpolation='nearest')
|
||||
plt.axis("off")
|
||||
fig, (ax_org, ax_sp, ax_mean) = plt.subplots(1, 3)
|
||||
ax_org.set_title("original")
|
||||
ax_org.imshow(img, interpolation='nearest')
|
||||
ax_org.axis("off")
|
||||
|
||||
plt.subplot(132, title="superpixels")
|
||||
# shuffle the labels for better visualization
|
||||
permuted_labels = np.random.permutation(segments.max() + 1)
|
||||
plt.imshow(permuted_labels[segments], interpolation='nearest')
|
||||
plt.axis("off")
|
||||
ax_sp.set_title("superpixels")
|
||||
ax_sp.imshow(segments, interpolation='nearest', cmap=plt.cm.prism)
|
||||
ax_sp.axis("off")
|
||||
|
||||
plt.subplot(133, title="mean color")
|
||||
colors = [np.bincount(segments.ravel(), img[:, :, c].ravel()) for c in
|
||||
xrange(img.shape[2])]
|
||||
counts = np.bincount(segments.ravel())
|
||||
colors = np.vstack(colors) / counts
|
||||
plt.imshow(colors.T[segments], interpolation='nearest')
|
||||
plt.axis("off")
|
||||
|
||||
plt.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9,
|
||||
ax_mean.set_title("mean color")
|
||||
ax_mean.imshow(colors.T[segments], interpolation='nearest')
|
||||
ax_mean.axis("off")
|
||||
fig.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9,
|
||||
bottom=0.02, left=0.02, right=0.98)
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user