
- 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 物件
- Image 模組
- Python Pillow - 影像混合
- Python Pillow 有用資源
- Python Pillow - 快速指南
- Python Pillow - 函式參考
- Python Pillow - 有用資源
- Python Pillow - 討論
Python Pillow - ImageChops.offset() 函式
PIL.ImageChops.offset 函式返回輸入影像的副本,其中資料已根據指定的水平和垂直距離偏移。資料圍繞邊緣環繞,如果垂直偏移 (yoffset) 被省略,則假定它等於水平偏移 (xoffset)。該函式採用以下引數:
語法
以下是函式的語法:
PIL.ImageChops.offset(image, xoffset, yoffset=None)
引數
以下是此函式引數的詳細資訊:
image - 輸入影像。
xoffset - 資料偏移的水平距離。
yoffset - 資料偏移的垂直距離。如果省略,則水平和垂直距離都設定為相同的值。
返回值
該函式返回 Image 型別,表示應用偏移後生成的影像。
示例
示例 1
這是一個僅根據給定的水平距離偏移影像的示例。
from PIL import Image, ImageChops # Open an Image original_image = Image.open("Images/Car_2.jpg") # Set the horizontal offset x_offset = 100 # Apply the offset to the image (y_offset defaults to x_offset) result_image = ImageChops.offset(original_image, x_offset) # Display the input and resulting image original_image.show() result_image.show()
輸出
輸入影像

輸出影像

示例 2
以下示例應用 ImageChops.offset() 函式來根據指定的水平和垂直偏移調整影像的位置。
from PIL import Image, ImageChops # Open an Image original_image = Image.open("Images/Car_2.jpg") # Set the horizontal and vertical offsets x_offset = 100 y_offset = -50 # Apply the offset to the image result_image = ImageChops.offset(original_image, x_offset, y_offset) # Display the input and resulting image original_image.show() result_image.show()
輸出
輸入影像

輸出影像

示例 3
以下示例演示瞭如何使用 ImageChops.offset() 來移動影像,然後使用 Image.paste() 函式填充環繞區域的黃色。
from PIL import Image, ImageChops # Open an Image original_image = Image.open('Images/Car_2.jpg') width, height = original_image.size # Apply the offset to the image result_image = ImageChops.offset(original_image, 10, 20) # Fill the wrapped area with the yellow color result_image.paste((255, 255, 255), (0, 0, 10, height)) result_image.paste((255, 255, 255), (0, 0, width, 20)) # Display the input and resulting image original_image.show() result_image.show()
輸出
輸入影像

輸出影像

python_pillow_function_reference.htm
廣告