Sometimes, the combined effect of two images mixed together makes a big impact compared to viewing the same images differently. Now it's time to give way to your imagination by blending two pictures together. In this example, our resultant image shows birds flying over the Mackinac bridge in Michigan. However, where did they come from? The birds were not there in the original image of the bridge.
Download the following files from Packt website:
0165_3_28_BRIDGE2.png
and0165_3_29_BIRDS2.png
. Rename these files asBRIDGE2.png
andBIRDS2.png
respectively.Add the following code in a Python source file.
1 import Image 2 3 img1 = Image.open( "C:\\images\\BRIDGE2.png ") 4 img1 = img1.convert('RGBA') 5 6 img2 = Image.open( "C:\\images\\BIRDS2.png ") 7 img2 = img2.convert('RGBA') 8 9 img = Image.blend(img1, img2, 0.3) 10 img.show() 11 img.save( "C:\\images\\BLEND.png")
The next illustration shows the two images before blending, represented by
img1
andimg2
in...