-
Notifications
You must be signed in to change notification settings - Fork 10
/
generate_edge.m
executable file
·43 lines (31 loc) · 1.11 KB
/
generate_edge.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
clear;close all;
%% settings
folder_HR = 'Set14';
%% generate data
filepaths_HR = dir(fullfile(folder_HR,'*.png'));
filepaths_EDGE = dir(fullfile(folder_EDGE,'*.png'));
for i = 1 : length(filepaths_HR)
im_hr = imread(fullfile(folder_HR,filepaths_HR(i).name));
im_hr = im2double(im_hr);
im_hr_r = im_hr(:,:,1);
im_hr_g = im_hr(:,:,2);
im_hr_b = im_hr(:,:,3);
[r_u1,r_u2] = gradient(im_hr_r);
r_u1_m = r_u1./(sqrt(1 + r_u1.^2 + r_u2.^2));
r_u2_m = r_u2./(sqrt(1 + r_u1.^2 + r_u2.^2));
R_TD = divergence(r_u1_m, r_u2_m);
[g_u1,g_u2] = gradient(im_hr_g);
g_u1_m = g_u1./(sqrt(1 + g_u1.^2 + g_u2.^2));
g_u2_m = g_u2./(sqrt(1 + g_u1.^2 + g_u2.^2));
G_TD = divergence(g_u1_m, g_u2_m);
[b_u1,b_u2] = gradient(im_hr_b);
b_u1_m = b_u1./(sqrt(1 + b_u1.^2 + b_u2.^2));
b_u2_m = b_u2./(sqrt(1 + b_u1.^2 + b_u2.^2));
B_TD = divergence(b_u1_m, b_u2_m);
RGB_TD = [];
RGB_TD(:,:,1) = R_TD;
RGB_TD(:,:,2) = G_TD;
RGB_TD(:,:,3) = B_TD;
filename = sprintf('Set14_Edge/%s',filepaths_HR(i).name);
imwrite(RGB_TD, filename);
end