Created
June 23, 2017 01:44
-
-
Save qfgaohao/5181cb4ad46d3a4283962e65bafd4ba9 to your computer and use it in GitHub Desktop.
Examples of Drawing rectangles and circles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib inline | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from skimage.draw import (line, polygon, circle, | |
circle_perimeter, | |
ellipse, ellipse_perimeter, | |
bezier_curve) | |
# Draw a rectangle | |
img = np.ones((10, 10), dtype=np.double) # a gray image | |
left = (3, 5) | |
right = (7, 6) | |
img[left[0]: right[0], left[1]: right[1]] = 0 | |
plt.imshow(img, cmap=plt.cm.gray) | |
# Draw a circle | |
img = np.ones((500, 500, 3), dtype=np.double) | |
rr, cc = circle(200, 300, 100) # x, y, radius | |
img[rr, cc, :] = 0 | |
plt.imshow(img) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment