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.
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.
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
:
width
and height
.
width
- 1, 0) (top right) in the new picture.height
- 1) (bottom left) in the original picture should show
up at location (width
- 1, height
- 1)
(bottom right) in the
new picture.width
- 1, 0) (top right) in the original
picture should show up at location (0, 0) (top left) in the new picture.width
- 1, height
- 1) (bottom
right) in the original
picture should show up at location (0, height
- 1)
(bottom left)
in the new picture.width - 2
, 0) in the new picture.height
- 1) in the original picture should
show up at location (width
- 2, height
- 1)
in the new picture.
width
- 3, 0) in the new picture.height
- 1) in the original picture should
show up at location (width
- 3, height
- 1)
in the new picture.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?
writePictureTo
function to save one reflected image, and if
necessary, the original image, in your CS107 folder.