同位素图像变换失真问题 [英] Homographic image transformation distortion issue

查看:243
本文介绍了同位素图像变换失真问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用3D变换矩阵变换图像,并假设我的相机是正交的。

I am trying to transform an image using a 3D transformation matrix and assuming my camera is orthonormal.

我使用平面诱导单应性公式定义我的单应性= Rt * n'/ d(d = Inf,H = R)。

I am defining my homography using the plane-induced homography formula H=R-t*n'/d (with d=Inf so H=R) as given in Hartley and Zisserman Chapter 13.

我困惑的是当我使用一个相当温和的旋转,图像似乎扭曲比我预期的多得多(我相信我不混淆弧度和度数)。

What I am confused about is when I use a rather modest rotation, the image seems to be distorting much more than I expect (I'm sure I'm not confounding radians and degrees).

这里可能出现什么问题?

What could be going wrong here?

我已附加我的代码和示例输出。

I've attached my code and example output.

n = [0;0;-1];
d = Inf;

im = imread('cameraman.tif');

 rotations = [0 0.01 0.1 1 10];

 for ind = 1:length(rotations)
       theta = rotations(ind)*pi/180;

       R = [ 1     0           0 ;
           0  cos(theta) -sin(theta);
           0  sin(theta)  cos(theta)];

       t = [0;0;0];

       H = R-t*n'/d;

      tform = maketform('projective',H');
      imT = imtransform(im,tform);

      subplot(1,5,ind) ;
      imshow(imT)
      title(['Rot=' num2str(rotations(ind)) 'deg']);
      axis square
 end


推荐答案

公式 H = Rt * n'/ d 有一个假设不符合您的情况:

The formula H = R-t*n'/d has one assumption which is not met in your case:

您正在使用焦距= 1的针孔相机型号

This formula implies that you are using pinhole camera model with focal length=1

但是在您的情况下,为了让您的相机更真实,应将焦距设置为远大于1的某个正数。(焦距是从相机中心到图像平面的距离)

But in your case, for your camera to be more real and for your code to work, you should set the focal length to some positive number much greater than 1. (focal length is the distance from your camera center to the image plane)

为此,您可以定义处理焦距的校准矩阵K.您只需要将您的公式更改为
H = KR inv(K) - 1 / d K t n'K
其中K是3乘3身份矩阵,其沿着对角线的两个第一元素被设置为焦距(例如f = 300)。

To do this you can define a calibration matrix K which handles the focal length. You just need to change your formula to H=K R inv(K) - 1/d K t n' K in which K is a 3-by-3 identity matrix whose two first elements along the diagonal are set to the focal length (e.g. f=300). The formula can be easily derived if you assume a projective camera.

以下是您的代码的修正版本,其中角度是有意义的。

Below is the corrected version of your code, in which the angles make sense.

n = [0;0;-1];
d = Inf;

im = imread('cameraman.tif');

rotations = [0 0.01 0.1 30 60];

 for ind = 1:length(rotations)
   theta = rotations(ind)*pi/180;

   R = [ 1     0           0 ;
       0  cos(theta) -sin(theta);
       0  sin(theta)  cos(theta)];

   t = [0;0;0];

  K=[300 0    0;
        0    300 0;
        0    0    1];

  H=K*R/K-1/d*K*t*n'*K;

  tform = maketform('projective',H');
  imT = imtransform(im,tform);

  subplot(1,5,ind) ;
  imshow(imT)
  title(['Rot=' num2str(rotations(ind)) 'deg']);
  axis square
end

您可以在下图中看到结果:

You can see the result in the image below:

您也可以围绕其中心旋转图像。为了发生,你应该将图像平面原点设置为图像的中心,我认为是不可能用matlab(maketform)的方法。
您可以使用下面的方法。

You can also rotate the image around its center. For it to happen you should set the image plane origin to the center of the image which I think is not possible with that method of matlab (maketform). You can use the method below instead.

imT=imagehomog(im,H','c');

该方法可以在以下位置找到: https://github.com/covarep/covarep/blob/master/external/voicebox/imagehomog.m

That method can be found at: https://github.com/covarep/covarep/blob/master/external/voicebox/imagehomog.m

imagehomog程序的结果如下所示,看起来更真实。

The result of the program with imagehomog is shown below which seems more real.

这篇关于同位素图像变换失真问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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