PIL 图像增强

python中PIL模块中有一个叫做ImageEnhance的类,该类专门用于图像的增强处理,不仅可以增强(或减弱)图像的亮度、对比度、色度,还可以用于增强图像的锐度。

from PIL import Imagefrom 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()

你可能感兴趣的:(PIL 图像增强)