Rotation is another must-know technique when working with any type of image. We will start by initializing the required libraries and loading the image from disk. We will also be using the CoordinateTransformations package from the JuliaImages collection to define a rotation transformation:
using Images, CoordinateTransformations
img = load("sample-images/cats-3061372_640.jpg");
tfm = LinearMap(RotMatrix(-pi/4))
img = warp(img, tfm)
imshow(img)
This results in the img variable being updated with a new image, which is shown as follows:
For ease of use, please refer to the following table:
Degree | Formula |
-30o | -pi/6 |
-90o | -pi/2 |
180 | pi |
Please be aware that rotating by degrees other than 90°, -90°, and 180° will result in a black background being added around the original image.