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()
相关文章
相关标签/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
公众号推荐
   一个历史类的公众号,欢迎关注
一两拨千金