26-Blend 2 Images Quiz
Now that we know how to add two images together, and multiply image intensity values by a scaler, let's revisit our example of averaging two images. We saw that division by two can be rewritten as multiplication by 0.5. Now, this results in an image that has equal parts dolphin and equal parts bicycle. What if we wanted to change these ratios? Say we want more of dolphin. But note that, in order to keep the maximum intensity value the same as that of the original images, we should ensure that these weights sum to one. In general, this is known as blending two images. Let's see what it looks like.


Yes, we do see a little bit more surf from the dolphin image, but it's a little hard to tell. How about we change the way it's a little farther? More dolphin. I wish we had a function to do this, which we could call like this. Can you write this function for me? Let me get you started. Put your code inside the function body. Remember, to return something, assign it to the output variable. Also note that a and b are the two images to be blended, and alpha is the weight to be applied to a. Once you have implemented the function, test it out with different values of alpha.Â