本文實例講述了Python圖像的增強處理操作。分享給大家供大家參考,具體如下:
python中PIL模塊中有一個叫做ImageEnhance的類,該類專門用于圖像的增強處理,不僅可以增強(或減弱)圖像的亮度、對比度、色度,還可以用于增強圖像的銳度。
具體見下面的例子:
#-*- coding: UTF-8 -*- from PIL import Imagefrom PIL import ImageEnhance#原始圖像image = Image.open('lena.jpg')image.show()#亮度增強enh_bri = ImageEnhance.Brightness(image)brightness = 1.5image_brightened = enh_bri.enhance(brightness)image_brightened.show()#色度增強enh_col = ImageEnhance.Color(image)color = 1.5image_colored = enh_col.enhance(color)image_colored.show()#對比度增強enh_con = ImageEnhance.Contrast(image)contrast = 1.5image_contrasted = enh_con.enhance(contrast)image_contrasted.show()#銳度增強enh_sha = ImageEnhance.Sharpness(image)sharpness = 3.0image_sharped = enh_sha.enhance(sharpness)image_sharped.show()結果如下:
原始圖像

亮度增強

色度增強

對比度增強

銳度增強

更多關于Python相關內容可查看本站專題:《Python數(shù)學運算技巧總結》、《Python圖片操作技巧總結》、《Python數(shù)據(jù)結構與算法教程》、《Python函數(shù)使用技巧總結》、《Python字符串操作技巧匯總》及《Python入門與進階經典教程》
希望本文所述對大家Python程序設計有所幫助。
新聞熱點
疑難解答