-
Notifications
You must be signed in to change notification settings - Fork 3
/
edge.m
34 lines (24 loc) · 840 Bytes
/
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
data_root = '/home/liuj/dataset/DUTS/DUTS-TR/DUTS-TR-Mask';
out_root = '/home/liuj/dataset/DUTS/DUTS-TR/DUTS-TR-Mask';
lst_set = '/home/liuj/dataset/DUTS/DUTS-TR/train'
index_file = fullfile([lst_set '.lst']);
fileID = fopen(index_file);
im_ids = textscan(fileID, '%s');
im_ids = im_ids{1};
fclose(fileID);
num_images = length(im_ids);
for im_id = 1:10
id = im_ids{im_id};
id = id(1:end-4);
% img_path = fullfile(data_root, [id '.jpg']);
% image = imread(img_path);
gt = imread(fullfile(data_root, [id '.png']));
gt = (gt > 128);
gt = double(gt);
[gy, gx] = gradient(gt);
temp_edge = gy.*gy + gx.*gx;
temp_edge(temp_edge~=0)=1;
bound = uint8(temp_edge*255);
save_path = fullfile(out_root, [id '_edge.png']);
imwrite(bound, save_path);
end