python进行图片增强

import os from PIL 
import Image from PIL
import ImageEnhance

def ImageAugument(): 
path = r‘C:\Users\wy\Desktop\kd‘
files = os.listdir(path)
prefix = path + ‘/‘
for file in files:
image = Image.open(prefix + file)
# image.show()
#亮度增强
enh_bri = ImageEnhance.Brightness(image)
brightness = 1.5
image_brightened = enh_bri.enhance(brightness)
image_brightened.save(prefix + file[0:6] + ‘lightup‘ + ‘.jpg‘)
 
           #色度增强
enh_col = ImageEnhance.Color(image)
color = 1.5
image_colored = enh_col.enhance(color)
image_colored.save(prefix + file[0:6] + ‘colorup‘ + ‘.jpg‘)
           #对比度增强 
enh_con = ImageEnhance.Contrast(image)
contrast = 1.3
image_contrasted = enh_con.enhance(contrast)
image_contrasted.save(prefix + file[0:6] + ‘contrastup‘ + ‘.jpg‘)
           #锐度增强 
enh_sha = ImageEnhance.Sharpness(image)
sharpness = 2.8
image_sharped = enh_sha.enhance(sharpness)
image_sharped.save(prefix + file[0:6] + ‘moreSharp‘ + ‘.jpg‘)

if __name__ == ‘__main__‘: ImageAugument()
相关文章
相关标签/搜索