You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong matrix calculation for shear angle in AffineTransform #3239
The convenience method of constructing an affine transform by providing a shear angle creates a wrong internal transform matrix - the diagonal elements should be 1.0 and in the second column it isn't. The -tan(angle) value is also wrong (apparently mis-scaled the same way as the diagola element.
Shear should not be a 1D parameter should it? I feel like you should have shear_x shear_y? or shear (y, x) (well (x, y) because the transform module is anti-python)
I've written a notebook (HTMLIPYNB that demonstrates how the shear transform is incorrect (as well as a bunch of other peculiarities with how Affine Transforms are applied in python).
The relevant discussion is here (scroll up one paragraph for some discussion). The following image shows the problem, scikit-image implementation at the bottom:
The matplotlib.transforms.Affine2D() function works very well as a substitute. Since skimage has matplotlib as a dependency, maybe one should just use that library instead? As documented in my notebook above, with the exception of the erroneous shear function, the implementation is identical (and supports chaining methods, which is nice).
Activity
hmaarrfk commentedon Aug 6, 2018
Wolfram would say you are right:
http://mathworld.wolfram.com/Shear.html
This line of code and the documentation say it is explicit @ahojnnes
scikit-image/skimage/transform/_geometric.py
Lines 717 to 724 in d3b8b6c
scikit-image/skimage/transform/_geometric.py
Lines 777 to 780 in d3b8b6c
Shear should not be a 1D parameter should it? I feel like you should have shear_x shear_y? or shear
(y, x)(well(x, y)because the transform module is anti-python)For reference, opencv doesn't provide a shortcut for shear
https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html
thomasaarholt commentedon Dec 31, 2020
I've written a notebook (HTML IPYNB that demonstrates how the shear transform is incorrect (as well as a bunch of other peculiarities with how Affine Transforms are applied in python).
The relevant discussion is here (scroll up one paragraph for some discussion). The following image shows the problem, scikit-image implementation at the bottom:
thomasaarholt commentedon Dec 31, 2020
The
matplotlib.transforms.Affine2D()function works very well as a substitute. Since skimage has matplotlib as a dependency, maybe one should just use that library instead? As documented in my notebook above, with the exception of the erroneousshearfunction, the implementation is identical (and supports chaining methods, which is nice).[-]shear transform bug[/-][+]Wrong matrix calculation for shear angle in `AffineTransform`[/+]