Overview:
- An alpha channel in an image introduces transparency to the Image.
- Alpha blending combines two images by applying an alpha value to the images.
- Pillow –Python Image Processing Library provides blend() method as part of the Image class implementation.
- When Image1 and Image2 are blended using alpha value 0, Image1 is returned as and vice versa when the alpha value is 1.
- When the alpha value varies from 0 to 1 and beyond, interpolation is used to determine the color value given by the formula
out=((int) in1[x] + alpha * ((int) in2[x] - (int) in1[x]));
Example:
from PIL import Image # Function to change the image size newWidth = int(widthRatio*image.size[0]) newImage = image.resize((newWidth, newHeight)) # Make the images of uniform size # Make sure images got an alpha channel # Display the images # alpha-blend the images with varying values of alpha # Display the alpha-blended images |