
- 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 - 邊緣增強
邊緣增強是影像處理和計算機視覺中常用的技術,用於改進影像的解釋和分析。它指的是強調或突出影像中不同物體或區域之間邊界的過程。其目標是提高邊緣的可見性,使它們更加清晰和突出。
Python Pillow 庫提供了 ImageFilter 模組,其中包含一組預定義的濾鏡,可以使用 Image.filter() 方法應用於影像。該庫的當前版本提供了兩個預定義的影像增強濾鏡,即 EDGE_ENHANCE 和 EDGE_ENHANCE_MORE,用於增強影像中的邊緣。
使用 ImageFilter.EDGE_ENHANCE 卷積核增強邊緣
此 ImageFilter.EDGE_ENHANCE 卷積核濾鏡旨在增強影像中的邊緣。
以下是增強影像邊緣的步驟:
使用 Image.open() 函式載入輸入影像。
將 filter() 函式應用於載入的 Image 物件,並將 ImageFilter.EDGE_ENHANCE 作為引數提供給 Image.filter() 函式,然後它將返回一個帶有增強邊緣的 PIL.Image.Image 物件。
示例
以下示例演示如何使用 ImageFilter.EDGE_ENHANCE 濾鏡卷積核來增強影像中的邊緣。
from PIL import Image, ImageFilter # Open the input image image = Image.open('Images/Flower1.jpg') # Apply edge enhancement filter enhanced_image = image.filter(ImageFilter.EDGE_ENHANCE) # Display the original and enhanced images image.show() enhanced_image.show()
輸入影像

輸出影像
具有增強邊緣的輸出影像:

使用 EDGE_ENHANCE_MORE 卷積核增強邊緣
此方法與 EDGE_ENHANCE 濾鏡類似,但它對邊緣應用更強的增強效果。
示例
以下示例演示如何使用 EDGE_ENHANCE_MORE 濾鏡卷積核更積極地增強影像中的邊緣。
from PIL import Image, ImageFilter # Open the input image image = Image.open('Images/Flower1.jpg') # Apply the EDGE_ENHANCE_MORE filter to the image enhanced_image = image.filter(ImageFilter.EDGE_ENHANCE_MORE) # Display the original and enhanced images image.show() enhanced_image.show()
輸入影像

輸出影像
將 EDGE_ENHANCE_MORE 濾鏡應用於輸入影像後的輸出影像:

廣告