在Matlab中消除图像的鱼眼镜头失真的错误 [英] Error in removing the fisheye lens distortion of an image in Matlab

查看:294
本文介绍了在Matlab中消除图像的鱼眼镜头失真的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下图像:

我想从该图像中消除鱼眼镜头的畸变,所以我使用了以下代码:

I want to remove the fisheye lens distortion from this image, so I used the following code:

[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,但是仍然出现错误.任何人都知道为什么我会收到此错误以及如何解决该错误?

I also used imwarp instead of imtransform, but I still get an error. Anyone has any idea why do I get this error and how to fix it?

推荐答案

如消息所示,您需要在使用Name-Property参数语法调用imtransform的过程中手动指定XDataYData属性

As the message says, you need to manually specify the XData and YData properties during the call to imtransform with the Name-Property arguments syntax.

根据 docs ,例如XData是:

According to the docs, XData for example is:

由两个元素组成的实向量,当与"YData"结合使用时,可以指定 输出图像B在二维输出空间中的空间位置 X-Y. "XData"的两个元素给出x坐标(水平) B的第一列和最后一列.

A two-element, real vector that, when combined with 'YData', specifies the spatial location of the output image B in the 2-D output space X-Y. The two elements of 'XData' give the x-coordinates (horizontal) of the first and last columns of B, respectively.

,对于YData同样.因此,您可以像这样修改对imtransform的呼叫:

and likewise for YData. Therefore, you could modify your call to imtransform like so:

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

其中colrow是您先前计算的大小函数的输出.

where col and row are the output of the size function you calculated earlier.

希望有帮助!

这篇关于在Matlab中消除图像的鱼眼镜头失真的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆