Third commit

This commit is contained in:
lan daiqing
2022-07-26 21:27:11 +08:00
commit 079dd34037
11 changed files with 554 additions and 0 deletions

39
GammaCorrection.py Normal file
View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# @Time : 2022-7-26 0026 11:41
# @Author : Qing
# @Email : derighoid@gmail.com
# @File : GammaCorrection.py
# @Software: PyCharm
'''
gamma矫正公式
f(x)=xγ
即输出是输入的幂函数,指数为γ.
'''
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
root = "E:\\桌面\\Python_Picture_Analysis\\data\\"
def gammaCorrect(filePath,val):
im = Image.open(filePath)
img = np.array(im)
img1 = np.power(img / float(np.max(img)), 1 / 1.5)
img2 = np.power(img / float(np.max(img)), val)
plt.subplot(131)
plt.imshow(img)
plt.title("origin")
plt.subplot(132)
plt.imshow(img1)
plt.title("gammar=1/1.5")
plt.subplot(133)
plt.imshow(img2)
plt.title("user-defined")
plt.show()
Image.fromarray(np.uint8(img2)).save(root + 'picture10' + '.jpg')
return img2