熱線電話:13121318867

登錄
首頁精彩閱讀python實現圖片變亮或者變暗的方法
python實現圖片變亮或者變暗的方法
2018-01-30
收藏

python實現圖片變亮或者變暗的方法

這篇文章主要介紹了python實現圖片變亮或者變暗的方法,涉及Python中Image模塊操作圖片的相關技巧,分享給大家供大家參考。具體實現方法如下:    
import Image
# open an image file (.jpg or.png) you have in the working folder
im1 = Image.open("angelababy.jpg")
# multiply each pixel by 0.9 (makes the image darker)
# works best with .jpg and .png files, darker < 1.0 < lighter
# (.bmp and .gif files give goofy results)
# note that lambda is akin to a one-line function
im2 = im1.point(lambda p: p * 0.5)
# brings up the modified image in a viewer, simply saves the image as
# a bitmap to a temporary file and calls viewer associated with .bmp
# make certain you have associated an image viewer with this file type
im2.show()
# save modified image to working folder as Audi2.jpg
im2.save("angelababy2.jpg")

運行效果如下所示:

希望本文所述對大家的Python程序設計有所幫助。

數據分析咨詢請掃描二維碼

若不方便掃碼,搜微信號:CDAshujufenxi

數據分析師資訊
更多

OK
客服在線
立即咨詢
日韩人妻系列无码专区视频,先锋高清无码,无码免费视欧非,国精产品一区一区三区无码
客服在線
立即咨詢