本文实例讲述了python图像的增强处理操作。分享给大家供大家参考,具体如下:
python中pil模块中有一个叫做imageenhance的类,该类专门用于图像的增强处理,不仅可以增强(或减弱)图像的亮度、对比度、色度,还可以用于增强图像的锐度。
具体见下面的例子:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#-*- coding: utf-8 -*- from pil import image from pil import imageenhance #原始图像 image = image. open ( 'lena.jpg' ) image.show() #亮度增强 enh_bri = imageenhance.brightness(image) brightness = 1.5 image_brightened = enh_bri.enhance(brightness) image_brightened.show() #色度增强 enh_col = imageenhance.color(image) color = 1.5 image_colored = enh_col.enhance(color) image_colored.show() #对比度增强 enh_con = imageenhance.contrast(image) contrast = 1.5 image_contrasted = enh_con.enhance(contrast) image_contrasted.show() #锐度增强 enh_sha = imageenhance.sharpness(image) sharpness = 3.0 image_sharped = enh_sha.enhance(sharpness) image_sharped.show() |
结果如下:
原始图像
亮度增强
色度增强
对比度增强
锐度增强
希望本文所述对大家python程序设计有所帮助。
原文链接:https://blog.csdn.net/guduruyu/article/details/71124837