-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Allow homogeneous coordinate transforms in affine_transform #7182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Test failures. The main change probably is OK, assuming the offset is applied in the correct order... |
@pv I think I've addressed your comments. I tested the functions manually for a translation -> rotation -> translation sequence to get a rotation about the center. Splitting the resulting homogeneous matrix as is done in the PR gave the correct result using affine_transform. The scipy.special.orthogonal errors appear unrelated to this PR, am I right there? |
Here's the code I used to check that the offset is used correctly in the PR: import numpy as np
from scipy import ndimage as ndi
from skimage import data
camera = data.camera()
θ = np.deg2rad(30)
C = np.cos
S = np.sin
T0 = np.array([[1, 0, -256], [0, 1, -256], [0, 0, 1.]])
Rot = np.array([[C(θ), -S(θ), 0], [S(θ), C(θ), 0], [0, 0, 1]])
T1 = np.array([[1, 0, 256], [0, 1, 256], [0, 0, 1.]])
Forward = T1 @ Rot @ T0
Inverse = np.linalg.inv(Forward)
camera_rot = ndi.affine_transform(camera, Inverse[:2, :2], Inverse[:2, 2], order=1)
plt.imshow(camera_rot) Result: |
I think the change is fine, but there are some test failures on travis (test_affine_transform26, test_affine_transform27) |
Also, the text |
@pv Thanks for the review! Let's hope third time's the charm! =) |
Oooh Travis is happy. That's a first. =P |
Great - thanks for doing this - it's a very nice addition. |
Thank you, Juan; this will certainly lead to more elegant SciPy use downstream. |
There was some discussion in #2255 (comment) about including support for homogeneous coordinate transforms by detecting the shape of the transformation matrix as being 1 + the dimensionality of the image. This implements that change. Hopefully I haven't broken 50 things in the process. =P