In this lab you are to write two python programs: one to modify an
image (rotating it 90 degrees), another to create a synthetic
image. Each .py file should have the same
structure: a function that takes a parameter and returns a
picture, followed by a function that interacts with the user and
displays the picture. The program posted on the course web
page for scaling a picture up and down should serve as a model.
The detailed requirements are given in each problem.
1. Write a program that prompts the user to select an image file, and
then displays it rotated 90 degrees clockwise.
NOTES:
The main work in developing the algorithm is in figuring out how
to change the x- and y-coordinates of pixels in the original image to
the coordinates of the corresponding pixels in the rotated image.
You'll need to draw a picture to do this. You should be inspired
by the mirror example.
The first function in the program should take a picture as a
parameter and return the rotated picture as a value. Again, use
the scaling example as a guide: Note that this function does not
read any input from the keyboard, nor does it display an image to the
screen.
Watch out for an "off-by-one error" in which you get the
coordinates ever so slightly off.
2. Write a program that displays a picture of a yellow square in
the center of a red one. The first function should have two
parameters: The length of a side of the red square, and the
length of the side of the yellow square, and it should return a
picture. The second function should prompt the user for the two
side lengths, and display the result. You might begin by making a
square that's completely red, and then looping over a range to create
the yellow square. Use the program setCenterWhite2.py as a model
for how to do the looping to make the center square, but remember that
the program you write will have quite a different structure.
Both the programs you write should
include comments that contain, first, your name, and second, a
description of what the program does.