用法:
skimage.draw.bezier_curve(r0, c0, r1, c1, r2, c2, weight, shape=None)
生成貝塞爾曲線坐標。
- r0, c0:int
第一個控製點的坐標。
- r1, c1:int
中間控製點的坐標。
- r2, c2:int
最後一個控製點的坐標。
- weight:雙倍的
中間控製點權重,說明線張力。
- shape:元組,可選
用於確定輸出像素坐標的最大範圍的圖像形狀。這對於超過圖像大小的曲線很有用。如果沒有,則使用曲線的全部範圍。
- rr, cc:(N,)int的ndarray
屬於貝塞爾曲線的像素的索引。可用於直接索引到數組中,例如
img[rr, cc] = 1
。
參數:
返回:
注意:
該算法是參考 [1] 中介紹的有理二次算法。
參考:
- 1
A Rasterizing Algorithm for Drawing Curves, A. Zingl, 2012 http://members.chello.at/easyfilter/Bresenham.pdf
例子:
>>> import numpy as np >>> from skimage.draw import bezier_curve >>> img = np.zeros((10, 10), dtype=np.uint8) >>> rr, cc = bezier_curve(1, 5, 5, -2, 8, 8, 2) >>> img[rr, cc] = 1 >>> img array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
相關用法
- Python skimage.draw.random_shapes用法及代碼示例
- Python skimage.draw.polygon2mask用法及代碼示例
- Python skimage.draw.ellipse_perimeter用法及代碼示例
- Python skimage.draw.line用法及代碼示例
- Python skimage.draw.set_color用法及代碼示例
- Python skimage.draw.circle_perimeter用法及代碼示例
- Python skimage.draw.polygon用法及代碼示例
- Python skimage.draw.rectangle_perimeter用法及代碼示例
- 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.rectangle用法及代碼示例
- 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.bezier_curve。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。