- 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()
输入噪点图像
输出中值滤波图像
广告