张量流中是否有cp2tform等效项?

时间:2018-06-26 04:11:53

标签: matlab tensorflow caffe

在Matlab中,cp2tform可用于将关键点转换为固定坐标,尤其是在面部对齐中。如何在TensorFlow中实现cp2tform

1 个答案:

答案 0 :(得分:1)

在Matlab中,您可以使用以下命令检查函数的代码:

>> edit cp2tform

function [trans,uv,xy,uv_dev,xy_dev] = cp2tform(varargin)
%CP2TFORM Infer spatial transformation from control point pairs.
%   CP2TFORM is not recommended. Use FITGEOTRANS instead.
%   
%   CP2TFORM takes pairs of control points and uses them to infer a
%   spatial transformation. 
%
%   TFORM = CP2TFORM(MOVINGPOINTS,FIXEDPOINTS,TRANSFORMTYPE) returns a TFORM
%   structure containing a spatial transformation. MOVINGPOINTS is an
%   M-by-2 double matrix containing the X and Y coordinates of control
%   points in the moving image you want to transform. FIXEDPOINTS is an
%   M-by-2 double matrix containing the X and Y coordinates of control
%   points in the fixed image. TRANSFORMTYPE can be 'nonreflective
%   similarity', 'similarity', 'affine', 'projective', 'polynomial',
%   'piecewise linear' or 'lwm'. See t
...

因此,您可以在Python中实现它,或尝试将一个库用于空间转换,而python中有各种特定的库:

https://github.com/kevinzakka/spatial-transformer-network

https://github.com/daviddao/spatial-transformer-tensorflow

或者对图像进行空间转换的另一种一般方法:

http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_geometric_transformations/py_geometric_transformations.html