皮尤斯变换

2024-06-26 14:35:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在寻找一个函数,可以使用所有的转换矩阵逐段仿射转换应用于源数据,以获得目标数据一次运行。我可以使用分段转换,但我找不到同时使用所有转换矩阵的函数,这段代码可以在一个循环中使用所有的转换矩阵,这不是正确的方法,我也在skimage包中展示了估计的转换矩阵的所有函数

import numpy as np
from skimage import transform as tf
from sklearn.metrics import mean_squared_error
from skimage.transform import PiecewiseAffineTransform
src = np.array([0,0 , 1,0 , 1,1 , 0,1]).reshape((4, 2))
dst = np.array([3,1 , 3,2 , 2,2 , 2,1]).reshape((4, 2))
tform = tf.estimate_transform('piecewise-affine', src, dst)
print(src)
print(dst)
print(tform.affines[0].params)
print(tform.affines[1].params)
mt = tf.matrix_transform(src, tform.affines[0].params)
print(mt)



>>> dir(tform)
['__add__', '__call__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_inverse_tesselation', '_tesselation', 'affines', 'estimate', 'inverse', 'inverse_affines', 'residuals']

Tags: 函数fromimportsrctfnptransform矩阵