Rotating Images

This section seeks to showcase rotating images by using matrix-vector multiplication on each pair of coordinates in a given image. This is different to multiplying the actual values contained at the given location, but rather multiplying the location coordinates (x,y) instead. The implementation included using Matplotlib.pyplot to display the results and a 2D rotation matrix that took in an angle of rotation (theta) as input. For example, pi/2 would imply a counter clockwise rotation by 90 degrees, whereas -pi/4 would imply a clockwise rotation by 45 degrees.

Process

    1. Read in our image, convert to numpy array, and scale down to speed up computation time
    2. Create list x values and a list of y values corresponding to the dimensions of our image
    3. Iterate through each pair of (x,y) coordinates and transform them using a 2d rotation matrix
    4. Specify theta ( our angel of rotation ) and apply matrix-vector multiplication to each (x,y) coordinate pair
    5. Assign the corresponding color of the original coordinate pair to the transformed coordinate pair using matplotlib
    6. Display the plot uing plt.show()
    7. The process is now complete!

Examples

  • The first image was created using a 2d rotation with angle pi/2 while the second image was created using an angle -pi/3.
  • Tools Used

  • Python
  • Matplotlib.pyplot