forked from THUHoloLab/TextureDeblur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscaleProcess.m
66 lines (53 loc) · 1.15 KB
/
scaleProcess.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function [S, T, M, w, Pp] = scaleProcess(varargin)
% % Scale source image, target image, etc
% default scale is 10
if nargin < 9
scales = 10;
if nargin < 7
times = 5;
else
times = varargin{7};
end
else
scales = varargin{8};
times = varargin{7};
end
S0 = varargin{1};
T0 = varargin{2};
M0 = varargin{3};
w0 = varargin{4};
Pp0 = varargin{5};
scale = varargin{6};
size_h = size(S0,1);
size_w = size(S0,2);
h = size_h / times;
w = size_w / times;
rows = round(h * times ^ ((scale - 1) / (scales - 1)));
cols = round(w * times ^ ((scale - 1) / (scales - 1)));
if ~isempty(S0)
S = imresize(S0, [rows cols],'nearest');
else
S = [];
end
if ~isempty(T0)
T = imresize(T0, [rows cols],'nearest');
else
T = [];
end
if ~isempty(M0)
M = imresize(M0, [rows cols],'nearest');
else
M = [];
end
if ~isempty(w0)
w = imresize(w0, [rows cols],'nearest');
else
w = [];
end
if ~isempty(Pp0)
Pp(:,1) = ( cols / size_w ) * (Pp0(:,1) - 0.5) + 0.5;
Pp(:,2) = ( rows / size_h ) * (Pp0(:,2) - 0.5) + 0.5;
else
Pp = [];
end
end