【问题标题】:how to combine two same scene images for image registration如何组合两个相同的场景图像进行图像配准
【发布时间】:2017-12-08 06:36:46
【问题描述】:

我尝试在两张灰度图像上进行图像配准,其中图像以不同的视图拍摄了两次。这些图像是我自己使用 Lifecam 相机拍摄的。

为了注册这些图像,我使用模板匹配方法和标准化互相关作为相似性度量并找到了正确的位置。但是这两张图片组合后的结果并不如我所愿。我不知道如何解决它。在合并之前我需要先做一些旋转或平移吗?如果是这样,我不知道如何获得旋转的真实角度。或者您知道如何在不应用任何旋转的情况下修复图像结果?

输入图片 1:

输入图像 2:

结果:

这是我的代码:

A = imread('image1.jpg');
B = imread('image2.jpg');

[M1, N1] = size(A);      % size imej A n B  
[M2, N2] = size(B);
%% finding coordinated of (r2,c2)
r1 = size(A,1)/2;        % midpoint of image A as coordinate
c1 = size(A,2
template = imcrop(A,[(c1-20) (r1-20) 40 40]);
[r2, c2] = normcorr(temp,B);     % Normalized cross correlation

%% count distance of coordinate (r1,c1) in image A and (r2,c2)in image B 
UA = r1;           % distance of coordinate (r1,c1) from top in image A
BA = M1 - r1;      % distance of coordinate (r1,c1) from bottom 
LA = c1;           % left distance from (r1,c1)
RA = N1 - c1;      % right distance from (r1,c1)

UB = r2;           % finding distance of coordinate (r2,c2) from top, 
BB = M2 - r2;      % bottom, left and right in image B  
LB = c2;
RB = N2 - c2;
%% zero padding for both image
if LA > LB  
L_diff = LA - LB;           % value of columns need to pad with zero on left side        
B = [zeros(M2,L_diff),B];
else
L_diff = LB - LA;
 A = [zeros(M1,L_diff),A];
end
if RA > RB  
 R_diff = RA - RB;          % value of columns need to pad with zero on right side
 B = [B, zeros(M2,R_diff)];
else
 R_diff = RB - RA;
 A = [A, zeros(M1,R_diff)];
end
N1 = size(A, 2);                    % renew value column image A and B    
N2 = size(B, 2);
if UA > UB 
 U_diff = UA - UB;                  % value of rows need to pad with zero on top
 B = [zeros(U_diff,N2);B];
else
 U_diff = UB - UA;
 A = [zeros(U_diff,N1);A];
end
if BA > BB 
 B_diff = BA - BB;         % value of rows need to pad with zero on bottom
 B = [B; zeros(B_diff,N2)];
else
 B_diff = BB - BA;
 A = [A; zeros(B_diff,N1)];
end
%% find coordinate that have double value
if LA > LB
 r = r1;
 c = c1;
else
 r = r2;
 c = c2;
end
if UA >= UB
 i_Start = r - UB + 1;
else
 i_Start = r - UA + 1;
end
if BA >= BB
 i_Stop = r + BB ;
else
 i_Stop = r + BA;
end
 if LA >= LB
 j_Start = c - c2 + 1;
else
 j_Start = c - c1 + 1;
end
if RA >= RB 
 j_Stop = c + RB;
else
 j_Stop = c + RA;
end
%% add image A and B 
A = im2double(A);
B = im2double(B);
final_im = A + B;
for i = i_Start:i_Stop
 for j = j_Start:j_Stop
     final_im(i,j) = final_im(i,j)/2;
 end
end

final_im = im2uint8(final_im);

【问题讨论】:

  • 你检查过this吗?
  • 我在 matlab 工具箱中没有 detectSURFFeatures 函数。我使用的是 2014b 版
  • 嗯...好吧,请检查this
  • 请向我们展示您用于注册这两个图像并将它们组合起来的代码。另外,请说明您是否将图像处理工具箱作为您的 MATLAB 发行版的一部分。根据配准的好坏,它可能只是一个混合问题,也可能是您需要相似变换而不是翻译。

标签: image matlab image-processing computer-vision image-registration


【解决方案1】:

执行此类注册的最佳公开方式是基于基准点。您可以选择最清晰的边缘或交叉点作为基准,然后调整平滑度和正则化参数以将它们注册在一起。 查看 SlicerRT 包。如果您遇到任何问题,请告诉我。

【讨论】:

    【解决方案2】:

    rayryeng 在 Ryan L 的第一个链接中的回答在这里非常适用。互相关可能无法在两幅图像之间提供足够接近的匹配,因为两幅图像之间的变换比二维刚性变换更准确地描述为homography

    准确的图像配准需要您找到这种投影变换。为此,您可以在两张图像中找到一组对应点(使用 SURF,如上所述,通常效果很好),然后使用RANSAC 从对应点获取单应性参数。即使您的两个图像中的某些“对应”特征实际上不是正确匹配,RANSAC 也做得很好。找到后,您可以使用转换将其中一张图像移动到另一张的视点并融合。

    Here's 很好地解释了特征匹配、RANSAC 以及将两个图像与一些 Matlab 代码示例融合。讲座使用了 SIFT 特征,但这个想法仍然适用于 SURF。

    【讨论】:

      猜你喜欢
      • 2016-11-16
      • 1970-01-01
      • 2020-10-11
      • 1970-01-01
      • 2015-04-26
      • 1970-01-01
      • 1970-01-01
      • 2015-11-03
      • 1970-01-01
      相关资源
      最近更新 更多