问题描述
我需要将使用WARP_TRI
函数的IDL源代码转换为MATLAB。 WARP_TRI接受两个(大)输入/输出2D点坐标的数组,并使用两个坐标数组作为控制点对输入图像进行扭曲。
有没有办法在MATLAB中实现等效功能?
解决方法
我发现以下示例演示了MatLab中的等效功能。
sqsize = 60;
I = checkerboard(sqsize,4,4);
nrows = size(I,1);
ncols = size(I,2);
fill = 0.3;
movingPoints = [0 0; 0 nrows; ncols 0; ncols nrows;];
fixedPoints = [0 0; 0 nrows; ncols 0; ncols*1.8 nrows*1.5];
t_piecewise_linear = fitgeotrans(movingPoints,fixedPoints,'pwl');
I_piecewise_linear = imwarp(I,t_piecewise_linear,'FillValues',fill);
imshow(I_piecewise_linear)
title('Piecewise Linear')