I have implemented image blending by using pyramids. It works well if I resize the first image but I do not get what I want if I resize it. So, what I need to is blending without resizing in order to get a proper result. My code is:
eyeImg = im2double(imread('eye.jpg'));
handImg = im2double(imread('hand.jpg'));
mask1 = im2double(imread('maskOrgan.jpg'));
eyeImage = imresize(eyeImg,[size(handImg,1) size(handImg,2)]);
mask2 = 1-mask1; %complement of the mask
level = 5;
lpA = genPyr(eyeImage,'laplace',level); % the Laplacian pyramid
lpB = genPyr(handImg,'laplace',level); % the Laplacian pyramid
gpM1 = genPyr(mask1, 'gauss', level);
gpM2 = genPyr(mask2, 'gauss', level);
limgo = cell(1,level); % the blended pyramid
for p = 1:level
[Mp, Np, ~] = size(lpA{p});
maskap = imresize(mask1,[Mp Np]);
maskbp = imresize(mask2,[Mp Np]);
limgo{p} = lpA{p}.*maskap + lpB{p}.*maskbp;
end
imgo = pyrReconstruct(limgo);
If I do not resize, I get the following error.
Array dimensions must match for binary array op.
Error in main (line 35)
limgo{p} = lpA{p}.*maskap + lpB{p}.*maskbp;
If you want without resizing, then you must do 'padding', i.e. increase the size of the smallest image to the size of the largest ... thus keeping the original scale Of both your images. Create a larger image with zeroes and copy the smallest image into it.