Description
Write a program that loads in an image and repeatedly rotates it by x degrees until the image has been rotated 360⁰ in total.
Your program should include the following:
- A parameter for the angle to rotate by at each step
- A function for multiplying two arbitrary nxm matrices (n and m should be dynamic)
- A rotation matrix of the format below. Each pixel in the image must be multiplied by R
cos | − sin | |
using the matrix multiplication function (prior bullet). | ||
= �sin | cos | � |
- An array variable for your image that is large enough for the entire image to be visible during all the intermediate rotations (when you’ve rotated 45⁰, the corners of your image should not be clipped)
- Absolute color error calculation: Code to compute the absolute error between the colors of the original image’s pixels and the colors of the image after it’s been rotated 360⁰
- Pixel displacement calculation: Code to compute the distance each pixel moves during rotation. This total value should be divided by:
(numPixelsInImage * numTimesImageWasRotated)
You can use the OpenCV and Numpy libraries for opening, displaying, and saving images and to create empty arrays/images. You may also use the math library built into Python for sine, cosine, and PI calculations. You may not use any other built-in functions or libraries.
Submit your code and a report. Your report must be a PDF and contain the following:
- Summary of the assignment goals
- 3+ images showing your code at intermediate stages (image rotated x degrees) with captions saying what angle stepsize is being used and the total rotation of the image so far (i.e. Image rotated 60⁰ with steps of 20⁰, 3 rotation operations applied so far.)
- A chart with the following information filled in:
Angle Step Size | # Rotations | Absolute Color Error | Pixel Displacement | (# Rotations) * (Pixel |
Displacement) | ||||
45⁰ | 8 | |||
60⁰ | 6 | |||
90⁰ | 4 | |||
120⁰ | 3 | |||
180⁰ | 2 | |||
360⁰ | 1 |
- Conclusions drawn from the completed chart
- Discussion of any issues encountered