
- 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 - Unsharp Mask 濾鏡
- 影像增強和校正
- 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 庫提供了一系列降噪濾鏡,允許使用者去除噪點影像中的噪點並恢復原始影像。在本教程中,我們將探索 GaussianBlur 和 Median 濾鏡作為有效的降噪方法。
使用 GaussianBlur 濾鏡去除噪點
使用高斯模糊濾鏡去除影像噪點是一種廣泛使用的技術。此技術透過對影像應用卷積濾鏡來平滑畫素值。
示例
這是一個使用 ImageFilter.GaussianBlur() 濾鏡去除 RGB 影像噪點的示例。
from PIL import Image, ImageFilter # Open a Gaussian Noised Image input_image = Image.open("Images/GaussianNoisedImage.jpg").convert('RGB') # Apply Gaussian blur with some radius blurred_image = input_image.filter(ImageFilter.GaussianBlur(radius=2)) # Display the input and the blurred image input_image.show() blurred_image.show()
輸入噪點影像

輸出去噪影像

使用中值濾波器去除噪點
中值濾波器是另一種降噪方法,尤其適用於噪點像小而分散的影像。此函式透過用其區域性鄰域內的中值替換每個畫素值來工作。Pillow 庫為此目的提供了 ImageFilter.MedianFilter() 濾鏡。
示例
下面的示例使用 ImageFilter.MedianFilter() 去除影像噪點。
from PIL import Image, ImageFilter # Open an image input_image = Image.open("Images/balloons_noisy.png") # Apply median filter with a kernel size filtered_image = input_image.filter(ImageFilter.MedianFilter(size=3)) # Display the input and the filtered image input_image.show() filtered_image.show()
輸入噪點影像

輸出中值濾波影像

示例
此示例演示瞭如何使用中值濾波器減少灰度影像中的椒鹽噪聲。這可以透過使用中值濾波器、增強對比度以提高可見性,然後將影像轉換為二進位制模式以進行顯示來完成。
from PIL import Image, ImageEnhance, ImageFilter, ImageOps # Open the image and convert it to grayscale input_image = ImageOps.grayscale(Image.open('Images/salt-and-pepper noise.jpg')) # Apply a median filter with a kernel size of 5 to reduce noise filtered_image = input_image.filter(ImageFilter.MedianFilter(5)) # Enhance the contrast of the filtered image contrast_enhancer = ImageEnhance.Contrast(filtered_image) high_contrast_image = contrast_enhancer.enhance(3) # Convert the image to binary binary_image = high_contrast_image.convert('1') # Display the input and processed images input_image.show() binary_image.show()
輸入噪點影像

輸出中值濾波影像

廣告