26-Blend 2 Images Solution

We know that we want to multiply A by alpha and since the some of weights needs to be one we multiply B by one minus alpha. And finally we assign this to the output variable. That's it. Let's see what we get. Alright, same image as before. Now see how easy it is to change the blending weights. For example, I want little less dolphin and more of bicycle. And, there we go. It almost looks like there is water on the street. This method of obtaining a weighted sum of two images is the basis of alpha blending.

%blend two images
dolphin = imread('a.png');
bicycle = imread('b.png');

function output = blend (a,b, alpha)
output= alpha *a + (1-alpha)*b;
endfunction
result= blend(dolphin, bicycle, 0.85)
imshow(results

Last modified: Saturday, 29 July 2023, 4:55 PM