-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglobal_optimize.m
29 lines (23 loc) · 988 Bytes
/
global_optimize.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
function [ image_high_opt ] = global_optimize( image_high, image_low )
% Enforce global contraints on the image
% Input: image_high - high-resolution image matrix
% image_low - low-resolution image matrix
% Output: image_high_opt - high-resolution image matrix after optimization
[height_high, width_high] = size(image_high);
[height_low, width_low] = size(image_low);
scale_factor = height_high / height_low;
image_high_opt = zeros(height_high, width_high);
for h = 1:height_low
for w = 1:width_low
h_offset = (h - 1) * scale_factor;
w_offset = (w - 1) * scale_factor;
px_high = image_high(h_offset+1:h_offset+scale_factor,...
w_offset+1:w_offset+scale_factor);
px_low = image_low(h, w);
error = px_low - mean(mean(px_high, 1), 2);
px_high = px_high + error;
image_high_opt(h_offset+1:h_offset+scale_factor,...
w_offset+1:w_offset+scale_factor) = px_high;
end
end
end