Assignment 28 — image manipulation
Due Monday, November 28
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
- Observations
- (
nw
,nh
) equals (oh
,ow
)
- The leftmost x-coordinate of the new image is 0.
- The rightmost x-coordinate of the new image is
nw-1
.
- The topmost y-coordinate of an image is 0.
- The bottommost y-coordinate of the new image is
nh-1
.
- Knowing the y-coordinate of a pixel in the new image tells you the x-coordinate of the source pixel in the original image.
- The distance of a pixel from the righthand side of the new image is how far the source pixel is from the top in the new image. So, knowing the x-coordinate of a pixel in the new image tells you how to calculate the y-coordinate of the source pixel in the original image.
Testing
- The module has built-in testing using a mandrill image.
| |
Background