Error in removing the fisheye lens distortion of an image in Matlab [duplicate]

流过昼夜 提交于 2019-12-12 02:39:49

问题


I have the following image:

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

But I get the following error:

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{:});

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?


回答1:


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.

According to the docs, XData for example is:

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.

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

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

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

Hope that helps!



来源:https://stackoverflow.com/questions/31115164/error-in-removing-the-fisheye-lens-distortion-of-an-image-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!