Mini-Lab: Reflecting Pictures

 


Introduction

The objectives of this lab are to become more familiar with jes4py, to understand and modify more complex programs (which may include if statements, nested loops, functions, etc.), and to do more complicated image manipulations.



Reflection

In this mini-lab, we will be writing a function that reflects an entire image. In our function, we will create a new picture to hold the reflected image.

  1. Write a verticalReflection function that creates a vertical reflection of a picture. It should take a picture as a parameter, and return a new picture of the same size reflected vertically around the right edge. This means that the picture should appear in the new picture as it would if you held the original up to a mirror.  Here are some hints, assuming that the dimensions of the original picture are width and height:
    Design Questions: Focusing on rows first, for any particular pixel (x, y), what should be the y-coordinate of the corresponding pixel in the new, reflected picture? Next, let's focus on the x-coordinates: what should be the x-coordinate of the corresponding pixel in the new, reflected picture?
  2. Make sure you have added appropriate comments for your function.

  3. Test your new function with various pictures. Use the writePictureTo function to save one reflected image, and if necessary, the original image, in your CS107 folder.

Submit your results

  1. Submit the file you created in this mini-lab via Kit.
  2. Submit your reflected image and its original on Kit.