mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 18:25:32 +08:00
Merge pull request #642 from sciunto/convex_hull_ex
Doc: Convex hull example. Improvement.
This commit is contained in:
@@ -27,9 +27,24 @@ image = np.array(
|
||||
[0, 1, 0, 0, 0, 0, 0, 1, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=float)
|
||||
|
||||
chull = convex_hull_image(image)
|
||||
image[chull] += 1.7
|
||||
image -= -1.7
|
||||
original_image = np.copy(image)
|
||||
|
||||
chull = convex_hull_image(image)
|
||||
image[chull] += 1
|
||||
# image is now:
|
||||
#[[ 0. 0. 0. 0. 0. 0. 0. 0. 0.]
|
||||
# [ 0. 0. 0. 0. 2. 0. 0. 0. 0.]
|
||||
# [ 0. 0. 0. 2. 1. 2. 0. 0. 0.]
|
||||
# [ 0. 0. 2. 1. 1. 1. 2. 0. 0.]
|
||||
# [ 0. 2. 1. 1. 1. 1. 1. 2. 0.]
|
||||
# [ 0. 0. 0. 0. 0. 0. 0. 0. 0.]]
|
||||
|
||||
|
||||
fig = plt.subplots(figsize=(10, 6))
|
||||
plt.subplot(1, 2, 1)
|
||||
plt.title('Original picture')
|
||||
plt.imshow(original_image, cmap=plt.cm.gray, interpolation='nearest')
|
||||
plt.subplot(1, 2, 2)
|
||||
plt.title('Transformed picture')
|
||||
plt.imshow(image, cmap=plt.cm.gray, interpolation='nearest')
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user