15.2. Combining Pictures¶
We can use a conditional to copy just the non-white pixels from one picture to another picture. We can take this tiny image of the women and put her by the Eiffel tower in Paris, France.
Run the program below. What would happen if
img1 was wider or taller than
img2, like if we tried to do this with the apple (see below) as img1 and gal2 (see below) as img2? Can you modify the program below to work even if that were true? One thing you might need to know is that the function
min(value1,value2) will return the smaller of the two values. If you have trouble figuring out a solution click on the Answer tab to see one way to do this.
Below is a selection of images that you can use in the programs in this section.
Here are a couple of other pictures that we can also use. The first is apple.jpg and the second is gal2.jpg. The apple is 500 wide by 334 high and gal2 is 248 wide by 240 high.
The decimal red-green-blue color code for purple is 128, 0, 128 respectively. Write code to change the white background in gal2.jpg to purple.
Discuss topics in this section with classmates.