国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

python 調整圖片亮度的示例

瀏覽:4日期:2022-07-03 13:48:45

實現效果

python 調整圖片亮度的示例

實現代碼

import matplotlib.pyplot as pltfrom skimage import iofile_name=’D:/2020121173119242.png’img=io.imread(file_name)Increment = -10.0img = img * 1.0 I = (img[:, :, 0] + img[:, :, 1] + img[:, :, 2])/3.0 + 0.001mask_1 = I > 128.0r = img [:, :, 0]g = img [:, :, 1]b = img [:, :, 2]rhs = (r*128.0 - (I - 128.0) * 256.0) / (256.0 - I) ghs = (g*128.0 - (I - 128.0) * 256.0) / (256.0 - I)bhs = (b*128.0 - (I - 128.0) * 256.0) / (256.0 - I)rhs = rhs * mask_1 + (r * 128.0 / I) * (1 - mask_1)ghs = ghs * mask_1 + (g * 128.0 / I) * (1 - mask_1)bhs = bhs * mask_1 + (b * 128.0 / I) * (1 - mask_1)I_new = I + Increment - 128.0mask_2 = I_new > 0.0R_new = rhs + (256.0-rhs) * I_new / 128.0G_new = ghs + (256.0-ghs) * I_new / 128.0B_new = bhs + (256.0-bhs) * I_new / 128.0R_new = R_new * mask_2 + (rhs + rhs * I_new/128.0) * (1-mask_2)G_new = G_new * mask_2 + (ghs + ghs * I_new/128.0) * (1-mask_2)B_new = B_new * mask_2 + (bhs + bhs * I_new/128.0) * (1-mask_2)Img_out = img * 1.0Img_out[:, :, 0] = R_newImg_out[:, :, 1] = G_newImg_out[:, :, 2] = B_newImg_out = Img_out/255.0# 飽和處理mask_1 = Img_out < 0 mask_2 = Img_out > 1Img_out = Img_out * (1-mask_1)Img_out = Img_out * (1-mask_2) + mask_2plt.figure()plt.imshow(img/255.0)plt.axis(’off’)plt.figure(2)plt.imshow(Img_out)plt.axis(’off’)plt.figure(3)plt.imshow(I/255.0, plt.cm.gray)plt.axis(’off’)plt.show()

以上就是python 調整圖片亮度的示例的詳細內容,更多關于python 調整圖片亮度的資料請關注好吧啦網其它相關文章!

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 长治县| 金溪县| 类乌齐县| 长顺县| 广东省| 长海县| 屏东市| 大洼县| 长白| 沐川县| 鄂伦春自治旗| 石屏县| 渑池县| 阿克苏市| 自治县| 临猗县| 敖汉旗| 莱阳市| 丹阳市| 嫩江县| 河南省| 墨江| 若羌县| 龙岩市| 潞西市| 分宜县| 汽车| 当雄县| 乌拉特前旗| 武陟县| 桂东县| 张家口市| 龙海市| 万盛区| 纳雍县| 海淀区| 会同县| 许昌市| 和平区| 会理县| 崇明县|