-
Notifications
You must be signed in to change notification settings - Fork 2
/
Syn_Type.py
60 lines (49 loc) · 1.24 KB
/
Syn_Type.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 5 18:37:30 2022
@author: Administrator
"""
import cv2
import numpy as np
import random
import math
import torch
import numpy as np
import cv2
import time
import os
from LPSLE_Model import *
import utils_train
# classification
import os
import json
import torch
from PIL import Image
from torchvision import transforms
import matplotlib.pyplot as plt
def hwc_to_chw(img):
return np.transpose(img, axes=[2, 0, 1])
def chw_to_hwc(img):
return np.transpose(img, axes=[1, 2, 0])
def LowLight(img):
g = np.random.uniform(0.1,0.2)
img_l = img*g
return img_l
def Hazey(img):
a = np.random.uniform(0.70,0.95)
t = np.random.uniform(0.1,0.5)
img_l = img*t +a*(1-t)
return img_l
# epoch = 1
# test_dir1 = './dataset/Test_Lowlight'
# testfiles1 = os.listdir(test_dir1)
# result_dir = './result'
# for f in range(len(testfiles1)):
# img = cv2.imread(test_dir1 + '/' + testfiles1[f])/255
# # img = cv2.imread('2.jpg')/255
# # cv2.imwrite('output1.jpg',Hazey(img)*255)
# cv2.imwrite(result_dir + '/' + testfiles1[f][:-4] + '_%d_9' % (epoch) + '.png',
# Hazey(img)*255)
#
img = cv2.imread('4.jpg')/255
cv2.imwrite('output4.jpg',Hazey(img)*255)