First, we construct a rotation matrix of the form
[cos(theta) -sin(theta) 0] R = [sin(theta) cos(theta) 0] [0 0 1]
Applying this coordinate transformation gives you a rotation around the origin.
If instead you want to rotate around the center of the image, you need to first shift the center of the image to the origin, then apply the rotation, and then move everything back. You can do this using the translation matrix:
[1 0 -image_width/2] T = [0 1 -image_height/2] [0 0 1]
The transformation matrix for translation, rotation and inverse transformation then becomes:
H = inv(T) * R * T
I need to think a bit about how to relate the skew matrix to 3D transformation. I expect the easiest route is to create a 4D transformation matrix and then project it back into 2D homogeneous coordinates. But at the moment, the general view of the oblique matrix:
[x_scale 0 0] S = [0 y_scale 0] [x_skew y_skew 1]
The values of x_skew and y_skew are usually tiny (1e-3 or less).
Here is the code:
from skimage import data, transform import numpy as np import matplotlib.pyplot as plt img = data.camera() theta = np.deg2rad(10) tx = 0 ty = 0 S, C = np.sin(theta), np.cos(theta)
And the conclusion:

Stefan van der walt
source share