0

我有以下图像:

在此处输入图像描述

我想从这张图片中去除鱼眼镜头失真,所以我使用了以下代码:

[X,map] = imread('Foam_Image.jpg');  % Read the indexed image
options = [size(X,1) size(X,2) 1];   % An array containing the columns, rows and exponent
tf = maketform('custom',2,2,[],...   % Make the transformation structure
               @fisheye_inverse,options);
newImage = imtransform(X,tf); 
imshow(newImage);                    % show image

但我收到以下错误:

Error using imtransform>parse_inputs (line 438)
XData and YData could not be automatically determined.  Try specifying XData and YData explicitly in the call to
IMTRANSFORM.

Error in imtransform (line 265)
args = parse_inputs(varargin{:});

我也使用imwarp了代替imtransform,但我仍然得到一个错误。任何人都知道为什么我会收到此错误以及如何解决它?

4

1 回答 1

1

如消息所述,您需要在调用过程中使用 Name-Property 参数语法手动指定XData和属性。YDataimtransform

根据文档,例如 XData 是:

一个二元素实向量,当与“YData”组合时,指定输出图像 B 在二维输出空间 XY 中的空间位置。'XData' 的两个元素分别给出 B 的第一列和最后一列的 x 坐标(水平)。

同样对于YData. 因此,您可以将调用修改为imtransform

newImage = imtransform(X,tf,'XData',[1 col],'YData',[1 row]);

其中colrow是您之前计算的大小函数的输出。

希望有帮助!

于 2015-06-29T12:35:56.217 回答