-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremoveObject.m
32 lines (32 loc) · 941 Bytes
/
removeObject.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
function I = removeObject(I,direction,visualization,handles)
axes(handles.imageDisp);
if visualization
J=I;
end
removedRegion = roipoly(I(:,:,1:3));
protectedRegion = roipoly(I(:,:,1:3));
if direction == 'h'
I = imrotate(I,-90);
end
while hasObject(I,removedRegion)
[height,~,~] = size(I);
E = energyMatrix(I);
E_weight = biasEnergyWeight(I,removedRegion,protectedRegion);
[M,T] = scoreMatrixWithWeight(E,E_weight);
[~,min_ind] = min(M(height,:));
trace = findTrace(M,T,min_ind);
I = removeSeam(I,trace);
if visualization
if direction == 'h'
H=markImage(J,imrotate(I,-90));
else
H=markImage(J,I);
end
imshow(H(:,:,1:3));
drawnow
end
end
if direction == 'h'
I = imrotate(I,90);
end
end