
- Python Pillow 教程
- Python Pillow - 首頁
- Python Pillow - 概述
- Python Pillow - 環境設定
- 基本影像操作
- Python Pillow - 影像處理
- Python Pillow - 調整影像大小
- Python Pillow - 翻轉和旋轉影像
- Python Pillow - 裁剪影像
- Python Pillow - 為影像新增邊框
- Python Pillow - 識別影像檔案
- Python Pillow - 合併影像
- Python Pillow - 影像剪下和貼上
- Python Pillow - 滾動影像
- Python Pillow - 在影像上寫入文字
- Python Pillow - ImageDraw 模組
- Python Pillow - 連線兩個影像
- Python Pillow - 建立縮圖
- Python Pillow - 建立水印
- Python Pillow - 影像序列
- Python Pillow 顏色轉換
- Python Pillow - 影像上的顏色
- Python Pillow - 使用顏色建立影像
- Python Pillow - 將顏色字串轉換為 RGB 顏色值
- Python Pillow - 將顏色字串轉換為灰度值
- Python Pillow - 透過更改畫素值來更改顏色
- 影像處理
- Python Pillow - 降噪
- Python Pillow - 更改影像模式
- Python Pillow - 影像合成
- Python Pillow - 使用 Alpha 通道
- Python Pillow - 應用透視變換
- 影像濾鏡
- Python Pillow - 為影像新增濾鏡
- Python Pillow - 卷積濾鏡
- Python Pillow - 模糊影像
- Python Pillow - 邊緣檢測
- Python Pillow - 浮雕影像
- Python Pillow - 增強邊緣
- Python Pillow - 銳化蒙版濾鏡
- 影像增強和校正
- Python Pillow - 增強對比度
- Python Pillow - 增強銳度
- Python Pillow - 增強顏色
- Python Pillow - 校正色彩平衡
- Python Pillow - 去噪
- 影像分析
- Python Pillow - 提取影像元資料
- Python Pillow - 識別顏色
- 高階主題
- Python Pillow - 建立動畫 GIF
- Python Pillow - 批次處理影像
- Python Pillow - 轉換影像檔案格式
- Python Pillow - 為影像新增填充
- Python Pillow - 顏色反轉
- Python Pillow - 使用 NumPy 進行機器學習
- Python Pillow 與 Tkinter BitmapImage 和 PhotoImage 物件
- 影像模組
- Python Pillow - 影像混合
- Python Pillow 有用資源
- Python Pillow - 快速指南
- Python Pillow - 函式參考
- Python Pillow - 有用資源
- Python Pillow - 討論
Python Pillow - ImageDraw.arc() 函式
在幾何學中,弧是指圓周的一部分或一段,由圓上的兩個點(稱為端點)以及這兩個點之間的連續曲線定義。在影像處理的背景下,Python Pillow 庫在其 ImageDraw 模組中提供了 arc() 方法,可以使用名為 Draw() 的類在影像上繪製弧線。
ImageDraw.arc() 方法用於在指定的邊界框內繪製弧線(它是圓形輪廓的一部分)。
語法
以下是函式的語法:
ImageDraw.arc(xy, start, end, fill=None, width=0)
引數
以下是此函式引數的詳細資訊:
xy - 使用兩個點定義邊界框。可以將其提供為 [(x0, y0), (x1, y1)] 或 [x0, y0, x1, y1] 序列,其中 x1 >= x0 且 y1 >= y0。
Start - 它以度為單位表示弧線的起始角度。角度從 3 點鐘方向開始測量,順時針方向遞增。
end - 它以度為單位表示弧線的結束角度。
fill - 弧線的填充顏色。
width - 它以畫素為單位定義弧線的寬度。此引數在 5.3.0 版中引入。
示例
示例 1
在此示例中,弧線繪製在具有指定座標和預設顏色以及寬度的邊界框內。
from PIL import Image, ImageDraw # Create a blank image image = Image.new("RGB", (300, 300), "black") draw = ImageDraw.Draw(image) # Draw an arc inside a bounding box [(50, 50), (250, 250)] draw.arc([(50, 50), (250, 250)], start=45, end=180) # Display the image image.show() print('Arc is drawn successfully...')
輸出
Arc is drawn successfully...
輸出影像

示例 2
在此示例中,紅色弧線繪製在寬度為 4 畫素的邊界框內。
from PIL import Image, ImageDraw import numpy as np # Create a NumPy array arr = np.zeros([300, 700, 3], dtype=np.uint8) arr[50:250, 50:650] = 250 # Create a Pillow Image from the NumPy array image = Image.fromarray(arr) # Create the draw object draw = ImageDraw.Draw(image) # Draw a red arc inside a bounding box draw.arc([(100, 70), (450, 240)], start=45, end=180, fill="red", width=4) # Display the image image.show() print('The arc is drawn successfully...')
輸出
The arc is drawn successfully...
輸出影像

示例 3
以下示例演示瞭如何在現有影像上使用不同的引數繪製弧線。
from PIL import Image, ImageDraw import numpy as np # Open an Image image = Image.open('Images/TP-W.png') # Create the draw object draw = ImageDraw.Draw(image) # Draw a red arc inside a bounding box draw.arc([(250, 130), (440, 260)], start=30, end=270, fill="red", width=10) # Display the image image.show() print('The arc is drawn successfully...')
輸出
The arc is drawn successfully...

python_pillow_function_reference.htm
廣告