Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ying.py #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ matplotlib==3.2.1
numpy==1.18.2
opencv-python==4.2.0.34
scikit-image==0.16.2
scipy==1.2.2
scipy==1.8.1
8 changes: 5 additions & 3 deletions ying.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import scipy, scipy.misc, scipy.signal
import cv2
import sys
from PIL import Image

def computeTextureWeights(fin, sigma, sharpness):
dt0_v = np.vstack((np.diff(fin, n=1, axis=0), fin[0,:]-fin[-1,:]))
Expand Down Expand Up @@ -90,7 +91,7 @@ def maxEntropyEnhance(I, isBad, a=-0.3293, b=1.1258):
Y = rgb2gm(tmp)

isBad = isBad * 1
isBad = scipy.misc.imresize(isBad, (50,50), interp='bicubic', mode='F')
isBad = np.array(Image.fromarray(isBad, mode="F").resize((50, 50), Image.BICUBIC))
isBad[isBad<0.5] = 0
isBad[isBad>=0.5] = 1
Y = Y[isBad==1]
Expand All @@ -114,7 +115,8 @@ def Ying_2017_CAIP(img, mu=0.5, a=-0.3293, b=1.1258):

# Weight matrix estimation
t_b = np.max(I, axis=2)
t_our = cv2.resize(tsmooth(scipy.misc.imresize(t_b, 0.5, interp='bicubic', mode='F'), lamda, sigma), (t_b.shape[1], t_b.shape[0]), interpolation=cv2.INTER_AREA)
resized = np.array(Image.fromarray(t_b, mode="F").resize((t_b.shape[1]//2, t_b.shape[0]//2), Image.BICUBIC))
t_our = cv2.resize(tsmooth(resized, lamda, sigma), (t_b.shape[1], t_b.shape[0]), interpolation=cv2.INTER_AREA)

# Apply camera model with k(exposure ratio)
isBad = t_our < 0.5
Expand Down Expand Up @@ -143,4 +145,4 @@ def main():
plt.show()

if __name__ == '__main__':
main()
main()