-
Notifications
You must be signed in to change notification settings - Fork 19
/
testBlend.m
56 lines (46 loc) · 1.25 KB
/
testBlend.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
clear all;
close all;
black = imread('black.jpg');
white = imread('white.jpg');
mask = imread('mask.png');
% Convert mask to alpha mask
maskr = double(mask(:,:,1)) / 255;
%%%% Show stitched image without any blurring
% First image - Mask pixels that belong to label 0
black_im = uint8(zeros(size(black)));
for i = 1 : 3
b = black(:,:,i);
out = zeros([size(black,1) size(black,2)]);
out(maskr == 0) = b(maskr == 0);
black_im(:,:,i) = out;
end
black_im = uint8(black_im);
% Second image - Mask pixels that belong to label 1
white_im = uint8(zeros(size(white)));
for i = 1 : 3
b = white(:,:,i);
out = zeros([size(white,1) size(white,2)]);
out(maskr == 1) = b(maskr == 1);
white_im(:,:,i) = out;
end
white_im = uint8(white_im);
% Stitch the two images together without blending
outStitch1 = black_im + white_im;
%%%% Now do Laplacian blending
outStitch2 = LaplacianBlend(black, white, mask);
% Show all the images individually
figure;
imshow(black);
title('First Image (Black)');
figure;
imshow(white);
title('Second Image (White)');
figure;
imshow(mask);
title('Mask used for blending');
figure;
imshow(outStitch1);
title('Output by simply placing the two together');
figure;
imshow(outStitch2);
title('Output after Laplacian Blending');