在Matlab中,cp2tform
可用于将关键点转换为固定坐标,尤其是在面部对齐中。如何在TensorFlow中实现cp2tform
?
答案 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
或者对图像进行空间转换的另一种一般方法: