-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.m
48 lines (34 loc) · 1.08 KB
/
main.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
clear all;
clc;
leftImage = double(imread('apple.png'));
rightImage = double(imread('orange.png'));
iternum = 5;
if (size(leftImage) ~= size(rightImage))
error('Input images are not the same size!')
end
% Ô¤´¦Àí£¬Ê¹Í¼Æ¬height,widthΪżÊý
[rows, cols, channels] = size(leftImage);
% mask gaussian
mask = double(zeros(rows, cols, channels));
mask(:, 1:floor(cols/2), :) = ones(rows, floor(cols/2), channels);
mask_pyramid = GaussianPyramid(mask, iternum);
% leftImage pyramid and rightImage pyramid
left_pyramid = LaplacianPyramid(leftImage, iternum);
right_pyramid = LaplacianPyramid(rightImage, iternum);
% TODO: get blend laplacian pyramid
blend_pyramid = cell(iternum, 1);
for i = 1:iternum
blend_pyramid{i} = left_pyramid{i} .* mask_pyramid{i} + right_pyramid{i} .* (1 - mask_pyramid{i});
end
% reconstruct the blend image
blendImage = LaplacianReconstruct(blend_pyramid);
imwrite(uint8(blendImage), 'blendImage.png');
figure;
imshow(uint8(leftImage));
title('leftImage');
figure;
imshow(uint8(rightImage));
title('rightImage');
figure;
imshow('blendImage.png');
title('blendImage');