November 2018
Intermediate to advanced
492 pages
12h 19m
English
The following code block shows how to start from one face image (image1 being the face of Messi) and end up with another image (image2 being the face of Ronaldo) by using a linear combination of the two image numpy ndarrays given with the following equation:
We do this by iteratively increasing α from 0 to 1:
im1 = mpimg.imread("../images/messi.jpg") / 255 # scale RGB values in [0,1]im2 = mpimg.imread("../images/ronaldo.jpg") / 255i = 1plt.figure(figsize=(18,15))for alpha in np.linspace(0,1,20): plt.subplot(4,5,i) plt.imshow((1-alpha)*im1 + alpha*im2) plt.axis('off') ...Read now
Unlock full access