Changing Step 3: Changing which data we use

Below is a selection of images that you can use in the programs in this section.

beach.jpgbaby.jpgvangogh.jpgswan.jpg
puppy.jpgkitten.jpggirl.jpgmotorcycle.jpg
gal1.jpgguy1.jpggal2.jpg

We can also change which part of the picture we read and manipulate.

What happens if we skip every other x and y as we manipulate the colors? Maybe make the green 255 and the blue 0?

Let’s try side-to-side copying.

    csp-11-6-1: Try it: How would you mirror the image from left-to-right around a vertical line in the middle of the picture? Try changing line 20 to these. If you get it right it will look like the women is nose to nose with herself.
  • pixels[halfway - x, y] = new_pixel
  • It does mirror, but only the left half
  • pixels[x + halfway, y] = new_pixel
  • This creates two copies of the left half
  • pixels[(img.size[1] - 1 - x), y] = new_pixel
  • Yes, it looks like the woman is kissing herself
  • pixels[x, height - y - 1] = new_pixel
  • This creates a mirror of the top left quarter in the bottom left quarter

Copy the pixels in the top left quadrant to the the bottom right quadrant. Look at the picture above for the expected result.

Next Section - Chapter 11 - Summary