300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > python PIL增强或降低图像对比度

python PIL增强或降低图像对比度

时间:2022-08-01 11:26:53

相关推荐

python PIL增强或降低图像对比度

说明

本代码段主要使用Python的Image库执行图像对比对增强和降低的操作,主要使用了PIL中的ImageEnhance类,该类还包括其他的图像增强功能,比如:亮度,锐度,色度等增强功能

# coding: utf-8import osimport randomfrom PIL import Image, ImageEnhancedef enhance_Contrast(path)img = Image.open(os.path.join(path, image)).convert("L")print(img.size)enh_con = ImageEnhance.Contrast(img)radio = round(random.uniform(0.7, 1.5),3)img_ = enh_con.enhance(radio)img_.save(os.path.join(path, image.split('.')[0]+'_test.jpg'))

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。