python进行图片增强

て烟熏妆下的殇ゞ 提交于 2019-11-28 13:30:52
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()





易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!