Bug with shear in kwimage.Affine
In kwimage < 0.8.0 there is a serious bug in kwimage.Affine when specifying a transform with a shear component.
The reconstruction (kwimage.Affine.affine
) was using a definition of shear from scikit-image, but the decomposition used an incompatible formulation from SE (https://math.stackexchange.com/a/3521141/353527).
This means that when there were repeated decompose -> reconstruct -> decompose operations the resulting affine matrix would change and become invalid.
This issue has been fixed in 0.8.0 but requires deprecation of the existing shear parameter. Use shearx
instead to get an unambiguously correct solution.
If there is no shear then there shouldn't be any issue. Also if you use Affine.json instead of Affine.concise that will result in a serialization that can be reconstructed correctly. The only place where the bug causes wrong results is if you serialized with a matrix with a shear with Affine.concise, and then reloaded it.
See Also:
dev/check_simple_affine_decomp.py
https://math.stackexchange.com/questions/612006/decomposing-an-affine-transformation