forked from chenxcynthia/reverse-CNN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOcclusion_overlap.m
33 lines (30 loc) · 1.22 KB
/
Occlusion_overlap.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
% VERSION 2 (improved):
% Occlusion_overlap is a script for generating a basic heatmap of an image.
% The script iterates over all places where the occlusion can be placed,
% and places the next occlusion mostly overlapping with the previous one.
% The score generated by this script is just the value of the pixel at that
% point
img = imread('Users/cynthiachen/Internship/CNN_heatmap/Unknow_test_paper/Ankle_Lateral_05.jpeg'); % image file name here
copy = imread('Users/cynthiachen/Internship/CNN_heatmap/Unknow_test_paper/Ankle_Lateral_05.jpeg');
img = imresize(img, [227 227]);
copy = imresize(copy, [227 227]);
r = 227;
c = 227;
s = 20; % size of square occlusion
delta = 5; % controls heatmap pixel size
diff = zeros(r, c, 2);
for i = 1:delta:(r-s)
for j = 1:delta:(c-s)
%img(i:(i+s), j:(j+s)) = 0; INCLUDE THIS LATER
score = img(i, j); % Forward propogate here
%should find difference between this score and regular score
for k = i:(i+s)
for l = j:(j+s)
diff(k, l, 2) = diff(k, l, 2) + 1;
diff(k, l, 1) = (diff(k, l, 1) * (diff(k, l, 2) - 1) + score) / diff(k, l, 2);
end
end
img = copy;
end
end
figure, image(diff(:, :, 1))