-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresizeImage.m
44 lines (42 loc) · 1.13 KB
/
resizeImage.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
function I = resizeImage(I,vseams,hseams,visualization, handles)
axes(handles.imageDisp);
if visualization
J = I;
end
for v = 1:1:abs(vseams)
E = energyMatrix(I);
[M,T] = scoreMatrix(E);
[height,~] = size(I);
[~,min_ind] = min(M(height,:));
trace = findTrace(M,T,min_ind);
if vseams < 0
I = removeSeam(I,trace);
else
I = addSeam(I,trace);
end
if visualization
H = markImage(J,I);
imshow(H(:,:,1:3), 'Parent', handles.imageDisp)
drawnow
end
end
I = imrotate(I,-90);
for h = 1:1:abs(hseams)
E = energyMatrix(I);
[M,T] = scoreMatrix(E);
[height,~] = size(I);
[~,min_ind] = min(M(height,:));
trace = findTrace(M,T,min_ind);
if hseams < 0
I = removeSeam(I,trace);
else
I = addSeam(I,trace);
end
if visualization
H = markImage(J,imrotate(I,-90));
imshow(H(:,:,1:3),'Parent', handles.imageDisp)
drawnow
end
end
I = imrotate(I,90);
end