用法:
skimage.draw.rectangle_perimeter(start, end=None, extent=None, shape=None, clip=False)
生成恰好圍繞矩形的像素坐標。
- start:元組
內部矩形的原點,例如
(row, column)
。- end:元組
內部矩形的端點
(row, column)
.對於二維矩陣,矩形內部定義的切片是[start:(end+1)]
.任何一個結尾或者程度必須指定。- extent:元組
內部矩形的範圍(大小)。例如:,
(num_rows, num_cols)
.任何一個結尾或者程度必須指定。負範圍是允許的。看skimage.draw.rectangle以更好地了解他們的行為方式。- shape:元組,可選
用於確定輸出坐標的最大邊界的圖像形狀。這對於裁剪超出圖像大小的周長很有用。默認情況下,不進行剪輯。長度必須至少為 2。隻有前兩個值用於確定輸入圖像的範圍。
- clip:布爾型,可選
是否將周長裁剪為提供的形狀。如果設置為 True,則繪製的圖形將始終是一個所有邊都可見的封閉多邊形。
- coords:int 形狀的數組(2,Npoints)
矩形中所有像素的坐標。
參數:
返回:
例子:
>>> import numpy as np >>> from skimage.draw import rectangle_perimeter >>> img = np.zeros((5, 6), dtype=np.uint8) >>> start = (2, 3) >>> end = (3, 4) >>> rr, cc = rectangle_perimeter(start, end=end, shape=img.shape) >>> img[rr, cc] = 1 >>> img array([[0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 1, 0, 0, 1], [0, 0, 1, 0, 0, 1], [0, 0, 1, 1, 1, 1]], dtype=uint8)
>>> img = np.zeros((5, 5), dtype=np.uint8) >>> r, c = rectangle_perimeter(start, (10, 10), shape=img.shape, clip=True) >>> img[r, c] = 1 >>> img array([[0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1], [0, 0, 1, 0, 1], [0, 0, 1, 1, 1]], dtype=uint8)
相關用法
- Python skimage.draw.rectangle用法及代碼示例
- Python skimage.draw.random_shapes用法及代碼示例
- Python skimage.draw.polygon2mask用法及代碼示例
- Python skimage.draw.ellipse_perimeter用法及代碼示例
- Python skimage.draw.bezier_curve用法及代碼示例
- Python skimage.draw.line用法及代碼示例
- Python skimage.draw.set_color用法及代碼示例
- Python skimage.draw.circle_perimeter用法及代碼示例
- Python skimage.draw.polygon用法及代碼示例
- Python skimage.draw.ellipse用法及代碼示例
- Python skimage.draw.polygon_perimeter用法及代碼示例
- Python skimage.draw.circle_perimeter_aa用法及代碼示例
- Python skimage.draw.line_nd用法及代碼示例
- Python skimage.draw.disk用法及代碼示例
- Python skimage.draw.line_aa用法及代碼示例
- Python skimage.data.binary_blobs用法及代碼示例
- Python skimage.data.file_hash用法及代碼示例
- Python skimage.feature.graycomatrix用法及代碼示例
- Python skimage.color.lab2lch用法及代碼示例
- Python skimage.feature.blob_doh用法及代碼示例
注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.draw.rectangle_perimeter。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。