Assignment 29 — image manipulation
Due Tuesday, April 27
Module cw.py
- Implement functions
rotate()
andfind()
to support producing a clockwise rotation of an image.
Function rotate( original )
- Return the size of the new image when performing a clockwise transformation of
original
.
Function find( nspot, nw, nh )
- Returns the counter-clockwise correspondent location of
nspot
in theoriginal
, wherenw
andnh
are the dimensions of the new image
| Clockwise rotation |
- Observations
- The leftmost x-coordinate of an image is 0.
- The bottommost y-coordinate of an image of height
h
ish-1
.
- Knowing the x-coordinate of a pixel in the new image tells you the y-coordinate of the source pixel in the original image.
- The distance of a pixel from the bottom of the new image is how far the source pixel is from the left in the new image.
- So, knowing the y-coordinate of a pixel in the new image tells you how to calculate the x-coordinate of the source pixel in the original image.
Testing
- The module has built-in testing using a mandrill image.
| |
Background
🦆 © 2022 Jim Cohoon | Resources from previous semesters are available. |