PIL Python 中的仿射变换
我对 PIL python 库中的 im.transform 方法有问题。我以为我弄清楚了参数 A 到 F 的逻辑,但是,尽管由波纹管函数计算的所有四个角都具有正确的正值,但生成的图像却以错误的方向旋转并被切断。
有人能给我计算两个坐标系中三个相同点的仿射参数(A 到 F)的公式吗?
def tran (x_pic, y_pic, A, B, C, D, E, F):
X = A * x_pic + B * y_pic + C
Y = D * x_pic + E * y_pic + F
return X, Y
I have problems with the im.transform method in PIL python library. I thought I figured out the logic of parameters, A to F, however, the resulting image gets rotated in the wrong direction and cut off although all four corners calculated by the bellow function have correct positive values.
Could anybody give me formulas to calculate affine parameters (A to F) from three identical points in both coordinate systems?
def tran (x_pic, y_pic, A, B, C, D, E, F):
X = A * x_pic + B * y_pic + C
Y = D * x_pic + E * y_pic + F
return X, Y
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
变换对我来说效果很好。作为示例,我们将围绕不同于 (0,0) 的中心旋转图像,并可选择缩放和平移到新中心。以下是如何使用转换来做到这一点:
transform works fine for me. As an example we'll rotate an image around a center different from (0,0) with optional scaling and translation to a new center. Here is how to do it with transform:
我认为我的版本更加明确且易于理解。
I think my version of is much more explicit and easy to understand.