如何在 MATLAB 中使用 griddata() 来转换图像?
How to use griddata() to transform the image, in MATLAB?
我有一个 8 位图像和一个变换矩阵。我需要使用 griddata() 方法 ONLY 来转换它吗?
我知道如何使用 affine2d() 和 imwarp() 进行此类转换,但是,如何使用 griddata() 完成此任务?
- 获取所有要变换的坐标
- 使用变换获取扭曲坐标
- 使用 griddata 从原始坐标采样变形坐标
% Params
row = 10; % number of rows in the matrix
col = 10; % number of cols in the matrix
ficitoiusValues = rand(col,row);
% Create a mash grid for all the coordinate in the matrix
[Y,X] = meshgrid(1:col,1:row);
corrdaintes = [X(:),Y(:), ones(row*col,1)];
% Create a transform ( In your case you already have this)
transform = rand(3,3);
% Warp all the corrdiantes
transformedCorrdaines = transform*corrdaintes';
% Use griddata to find the new valiues of the new transformed corrdinates
vq = griddata(1:col,1:row,ficitoiusValues,transformedCorrdaines(1,:),transformedCorrdaines(1,:));
我有一个 8 位图像和一个变换矩阵。我需要使用 griddata() 方法 ONLY 来转换它吗? 我知道如何使用 affine2d() 和 imwarp() 进行此类转换,但是,如何使用 griddata() 完成此任务?
- 获取所有要变换的坐标
- 使用变换获取扭曲坐标
- 使用 griddata 从原始坐标采样变形坐标
% Params row = 10; % number of rows in the matrix col = 10; % number of cols in the matrix ficitoiusValues = rand(col,row); % Create a mash grid for all the coordinate in the matrix [Y,X] = meshgrid(1:col,1:row); corrdaintes = [X(:),Y(:), ones(row*col,1)]; % Create a transform ( In your case you already have this) transform = rand(3,3); % Warp all the corrdiantes transformedCorrdaines = transform*corrdaintes'; % Use griddata to find the new valiues of the new transformed corrdinates vq = griddata(1:col,1:row,ficitoiusValues,transformedCorrdaines(1,:),transformedCorrdaines(1,:));