Beispiel #1
0
import numpy as np
import cv2
import guidedFilter as gf
import scipy.io as sio

img = cv2.imread('./img_enhancement/tulips.bmp') / 255.0
test_img = img[:, :, 2]
p = test_img

r = 16
eps = 0.01

q = np.zeros(test_img.shape)

# q,N,mean_I, mean_p, mean_Ip, cov_Ip,mean_II, var_I, a, b, mean_a, mean_b, q = gf.guidedfilter(test_img, p, r, eps);
q = gf.guidedfilter(test_img, p, r, eps)

I_enhanced = (test_img - q) * 5 + q

# plt.subplot(1,3,1), plt.imshow(test_img)
# # plt.subplot(132), plt.imshow(q)
# # plt.subplot(133), plt.imshow(I_enhanced)

# # plt.show()

cv2.imshow('adsdfd', test_img)
cv2.imshow('ada', q)
cv2.imshow('sdfda', I_enhanced)
cv2.waitKey(0)
cv2.destroyAllWindows()
# sio.savemat('saveddata.mat', {'N': N,'mean_I': mean_I, 'mean_p': mean_p, 'mean_Ip': mean_Ip, 'cov_Ip': cov_Ip, \
# example: detail enhancement
# figure 6 in our paper
import cv2
import numpy as np
import guidedFilter as gf

I = (cv2.imread(
    '/Users/bushanshan/Documents/Workspace/haze_removal/myCode/img_enhancement/tulips.bmp'
)) / 255.0
p = I
r = 16
eps = 0.01

q = np.zeros(I.shape)

q[:, :, 0] = gf.guidedfilter(I[:, :, 2], p[:, :, 0], r, eps)
q[:, :, 1] = gf.guidedfilter(I[:, :, 1], p[:, :, 1], r, eps)
q[:, :, 2] = gf.guidedfilter(I[:, :, 0], p[:, :, 2], r, eps)

I_enhanced = (I - q) * 5 + q

print q.shape
print I.shape
print I_enhanced.shape

cv2.imshow("I", I)
cv2.imshow("q", q)
cv2.imshow('I_enhanced', I_enhanced)
cv2.waitKey(0)
cv2.destroyAllWindows()
# figure();
Beispiel #3
0
import cv2
import numpy as np
import guidedFilter as gf


I = cv2.imread("./cat.bmp")
gray = cv2.cvtColor(I, cv2.COLOR_BGR2GRAY)
# print gray.shape
gray = I[:, :, 0] / 255.0
p = gray

r = 4
# try r=2, 4, or 8
eps = 0.04
# % try eps=0.1^2, 0.2^2, 0.4^2

q = gf.guidedfilter(gray, p, r, eps)


cv2.imshow("a", I)
cv2.imshow("b", q)
cv2.waitKey(0)
cv2.destroyAllWindows()
Beispiel #4
0
import cv2
import guidedFilter as gf
import scipy.io as sio


img = cv2.imread('./img_enhancement/tulips.bmp') / 255.0;
test_img = img[:, :, 2];
p = test_img;

r = 16;
eps = 0.01; 

q = np.zeros(test_img.shape);

# q,N,mean_I, mean_p, mean_Ip, cov_Ip,mean_II, var_I, a, b, mean_a, mean_b, q = gf.guidedfilter(test_img, p, r, eps);
q = gf.guidedfilter(test_img, p, r, eps);

I_enhanced = (test_img - q) * 5 + q;

# plt.subplot(1,3,1), plt.imshow(test_img)
# # plt.subplot(132), plt.imshow(q)
# # plt.subplot(133), plt.imshow(I_enhanced)

# # plt.show()

cv2.imshow('adsdfd', test_img)
cv2.imshow('ada', q)
cv2.imshow('sdfda', I_enhanced)
cv2.waitKey(0)
cv2.destroyAllWindows()
# sio.savemat('saveddata.mat', {'N': N,'mean_I': mean_I, 'mean_p': mean_p, 'mean_Ip': mean_Ip, 'cov_Ip': cov_Ip, \
Beispiel #5
0
import cv2
import numpy as np
import guidedFilter as gf

I = cv2.imread('./cat.bmp')
gray = cv2.cvtColor(I, cv2.COLOR_BGR2GRAY)
# print gray.shape
gray = I[:, :, 0] / 255.0
p = gray

r = 4
# try r=2, 4, or 8
eps = 0.04
# % try eps=0.1^2, 0.2^2, 0.4^2

q = gf.guidedfilter(gray, p, r, eps)

cv2.imshow('a', I)
cv2.imshow('b', q)
cv2.waitKey(0)
cv2.destroyAllWindows()
 # example: detail enhancement
 # figure 6 in our paper
import cv2
import numpy as np
import guidedFilter as gf


I = (cv2.imread('/Users/bushanshan/Documents/Workspace/haze_removal/myCode/img_enhancement/tulips.bmp')) / 255.0;
p = I;
r = 16;
eps = 0.01;

q = np.zeros(I.shape);

q[:, :, 0] = gf.guidedfilter(I[:, :, 2], p[:, :, 0], r, eps);
q[:, :, 1] = gf.guidedfilter(I[:, :, 1], p[:, :, 1], r, eps);
q[:, :, 2] = gf.guidedfilter(I[:, :, 0], p[:, :, 2], r, eps);

I_enhanced = (I - q) * 5 + q;

print q.shape
print I.shape
print I_enhanced.shape


cv2.imshow("I", I)
cv2.imshow("q", q)
cv2.imshow('I_enhanced', I_enhanced)
cv2.waitKey(0)
cv2.destroyAllWindows()
# figure();