-
Notifications
You must be signed in to change notification settings - Fork 56
/
Demo_Test.m
56 lines (38 loc) · 1.15 KB
/
Demo_Test.m
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
clear;
clc;
close all;
warning off;
addpath(genpath('./.'));
addpath(genpath('/home/../caffe/')) ;
caffe.set_mode_gpu();
caffe.set_device(0);
folder = 'Model/';
filepaths = dir(fullfile(folder, '*.caffemodel'));
weights = fullfile(folder,filepaths.name);
model = 'Twostage.prototxt';
net = caffe.Net(model, weights,'test');
img_In = imread('Test/79.JPG');
img_In = imresize(img_In, 3/5, 'bicubic');
img_In = modcrop(img_In, 4);
I = double(rgb2gray(img_In));
I = I./max(I(:));
lumin = im2single(wlsFilter(I, 2, 2));
detail = im2single(I - lumin);
img_In = im2single(img_In);
DL = cat(3, img_In, lumin);
DD = cat(3, img_In, detail);
[H, W, C] = size(img_In);
if (H>1200 && W>1200)
dataL = DL(H/2-600:H/2+599, W/2-600:W/2+599, :);
dataD = DD(H/2-600:H/2+599, W/2-600:W/2+599, :);
data = img_In(H/2-600:H/2+599, W/2-600:W/2+599, :);
end
net.blobs('data').reshape([size(data,1) size(data,2), 3, 1]);
net.reshape();
net.blobs('dataL').reshape([size(data,1) size(data,2), 4, 1]);
net.reshape();
net.blobs('dataD').reshape([size(data,1) size(data,2), 4, 1]);
net.reshape();
res = net.forward({data, dataL, dataD});
result = res{1};
imshow([data result])