利用python如何調(diào)整圖片的亮度-創(chuàng)新互聯(lián)

本篇文章為大家展示了利用python如何調(diào)整圖片的亮度,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

10多年的營口網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。成都全網(wǎng)營銷的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整營口建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)從事“營口網(wǎng)站設(shè)計”,“營口網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。

實現(xiàn)代碼


import matplotlib.pyplot as plt
from skimage import io

file_name='D:/2020121173119242.png'
img=io.imread(file_name)

Increment = -10.0

img = img * 1.0 
I = (img[:, :, 0] + img[:, :, 1] + img[:, :, 2])/3.0 + 0.001

mask_1 = I > 128.0

r = 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.0

mask_2 = I_new > 0.0

R_new = rhs + (256.0-rhs) * I_new / 128.0
G_new = ghs + (256.0-ghs) * I_new / 128.0
B_new = bhs + (256.0-bhs) * I_new / 128.0

R_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.0

Img_out[:, :, 0] = R_new
Img_out[:, :, 1] = G_new
Img_out[:, :, 2] = B_new

Img_out = Img_out/255.0

# 飽和處理
mask_1 = Img_out < 0 
mask_2 = Img_out > 1

Img_out = Img_out * (1-mask_1)
Img_out = Img_out * (1-mask_2) + mask_2

plt.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()

網(wǎng)頁名稱:利用python如何調(diào)整圖片的亮度-創(chuàng)新互聯(lián)
文章源于:http://muchs.cn/article22/dspgcc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計公司、靜態(tài)網(wǎng)站、服務(wù)器托管軟件開發(fā)、全網(wǎng)營銷推廣

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

手機網(wǎng)站建設(shè)