【发布时间】:2017-11-10 18:27:09
【问题描述】:
我正在寻找一个函数,它可以使用 PiecewiseAffineTransform 的所有转换矩阵应用于源数据以一次运行获取目标数据。我可以使用分段变换,但我找不到同时使用所有变换矩阵的函数,这段代码可以在一个循环中使用所有变换矩阵,这不是应该做的正确方式,我还介绍了所有的函数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']
【问题讨论】:
-
总是使用通用 Python 标记,并且仅在必要时可选地包含任何特定于版本的标记(如果问题与特定版本有关)
-
@juanpa.arrivillaga 谢谢你的建议,确定会这样做
标签: python numpy scikit-image affinetransform piecewise