【问题标题】:Error in removing the fisheye lens distortion of an image in Matlab [duplicate]在Matlab中去除图像的鱼眼镜头失真时出错[重复]
【发布时间】:2015-06-29 12:00:56
【问题描述】:

我有以下图片:

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

[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,但我仍然收到错误消息。任何人都知道为什么我会收到此错误以及如何解决它?

【问题讨论】:

    标签: matlab image-processing fisheye


    【解决方案1】:

    如消息所述,您需要在使用名称-属性参数语法调用imtransform 期间手动指定XDataYData 属性。

    根据docs,XData例如是:

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

    同样适用于YData。因此,您可以像这样修改对imtransform 的调用:

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

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

    希望有帮助!

    【讨论】:

    • 感谢您的回答,但我仍然有错误。我确实喜欢这样:x = size(X,1); y = size(X,2); newImage = imtransform(X,tf,'XData',[1 x],'YData',[1 y]);
    • XData 代表列数,所以这里应该是[ 1 size(X,2) ] 可能这不是错误的原因。
    • 是的,对不起,我的意思是x=size(X,2),所以错误仍然存​​在。我认为我使用了错误的函数@fisheye_inverse,因为我想从已经失真的图像中去除鱼眼失真,而不是实现它。我认为这个函数实际上实现了失真。
    • 嗯,是的,实际上我认为你是对的。 here函数你服了吗?
    • 是的,没错。不幸的是,我不知道有什么函数可以逆转失真。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-13
    • 1970-01-01
    • 1970-01-01
    • 2012-10-12
    • 2016-05-20
    相关资源
    最近更新 更多