<jupyter_start><jupyter_text>Drawing shapes Dr. <NAME>, Fremont CA 94536This example shows how to draw several different shapes:* line* Bezier curve* polygon* circle* ellipseAnti-aliased drawing for:* line* circle<jupyter_code>import math
import numpy as np
import matplotlib.pyplot as plt

from skimage.draw import (line, polygon, circle,
                          circle_perimeter,
                          ellipse, ellipse_perimeter,
                          bezier_curve)
from skimage.draw import line_aa, circle_perimeter_aa<jupyter_output><empty_output><jupyter_text>Blank canvas<jupyter_code>img = np.zeros((500, 500, 3), dtype=np.double)
img = np.zeros((500, 500, 3))<jupyter_output><empty_output><jupyter_text>Draw line<jupyter_code>rr, cc = line(120, 123, 20, 400)
img[rr, cc, 0] = 255<jupyter_output><empty_output><jupyter_text>Fill polygon<jupyter_code>poly = np.array((
    (300, 300),
    (480, 320),
    (380, 430),
    (220, 590),
    (300, 300),
))

rr, cc = polygon(poly[:, 0], poly[:, 1], img.shape)
img[rr, cc, 1] = 1<jupyter_output><empty_output><jupyter_text>Fill circle<jupyter_code>rr, cc = circle(200, 200, 100, img.shape)
img[rr, cc, :] = (1, 1, 0)<jupyter_output><empty_output><jupyter_text>Fill ellipse<jupyter_code>rr, cc = ellipse(300, 300, 100, 200, img.shape)
img[rr, cc, 2] = 1<jupyter_output><empty_output><jupyter_text>Circle<jupyter_code>rr, cc = circle_perimeter(120, 400, 15)
img[rr, cc, :] = (1, 0, 0)<jupyter_output><empty_output><jupyter_text>Bezier curve<jupyter_code>rr, cc = bezier_curve(70, 100, 10, 10, 150, 100, 1)
img[rr, cc, :] = (1, 0, 0)<jupyter_output><empty_output><jupyter_text>Ellipses<jupyter_code>rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=math.pi / 4.)
img[rr, cc, :] = (1, 0, 1)
rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=-math.pi / 4.)
img[rr, cc, :] = (0, 0, 1)
rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=math.pi / 2.)
img[rr, cc, :] = (1, 1, 1)
fig, ax1 = plt.subplots(ncols=1, nrows=1, figsize=(6, 6))
ax1.imshow(img)
ax1.set_title('Shapes',fontsize=16)
ax1.axis('off')
plt.show()<jupyter_output>Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers).<jupyter_text>Anti-aliasing drwaing<jupyter_code>img = np.zeros((100, 100), dtype=np.double)

# anti-aliased line
rr, cc, val = line_aa(12, 12, 20, 50)
img[rr, cc] = val

# anti-aliased circle
rr, cc, val = circle_perimeter_aa(60, 40, 30)
img[rr, cc] = val

fig, ax2 = plt.subplots(ncols=1, nrows=1, figsize=(6, 6))
ax2.imshow(img, cmap=plt.cm.gray, interpolation='nearest')
ax2.set_title('Anti-aliasing')
ax2.axis('off')

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1629906542056075, 'fraction_numerical': 0.07850467289719626, 'mean_word_length': 5.223255813953489, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '236736', 'license': 'MIT', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1091, 'n_words': 241, 'path': 'Shapes_drawing.ipynb', 'repo_name': 'tirthajyoti/Scikit-image-processing', 'size': '2687'}