多频段融合方法——图像拼接

原文地址:http://blog.csdn.net/smallflyingpig/article/details/61200497


图像拼接一般包括warp(映射), compensation(光照补偿)和blend(融合)三部分。 
warp部分主要取决于相机参数估计的准确性,光照补偿主要用于解决不同图像曝光不同所带来的输出图像的不同局部的光照差异,而blend则用于融合不同图像之间的重叠部分,一般使用线性加权的方式来得到最终的输出图像。 
image stitching


多波段融合(multi blend)

多波段融合的基本思想是图像可以分解为不同频率的图像的叠加(类似于傅里叶变换),在不同的频率上,应该使用不同的权重来进行融合,在低频部分应该使用波长较宽的加权信号(例如高斯核函数中sigma比较大),在高频部分应该使用较窄的加权信号(例如高斯核函数的sigma比较小),其算法如下:

  1. 计算输入图像的高斯金字塔。如果输入图像是 A,B ,则计算 GA0,GA1,GA2,GA3, GB0,GB1,GB2,GB3, (如何计算高斯金字塔?)
  2. 计算输入图像的拉普拉斯金字塔。记为 LA0,LA1,LA2,LA3, LB0,LB1,LB2,LB3, (如何计算拉普拉斯金字塔?)
  3. 将处于同一级的拉普拉斯金字塔进行融合。例如在拼接缝两侧使用简单的线性融合。记输出图像为 C ,则这里得到 LC0,LC1
  4. 将高层的拉普拉斯金字塔依次扩展直至和 LC0 相同分辨率。我们记做 LC00,LC11,LC22
  5. 将4中得到的图像依次叠加,则得到最终的输出图像 C

代码实现

使用matlab实现多波段算法如下:

function C = multi_blend(A, B);

%resize A,B,C to the same size
A_size = size(A);
B_size = size(B);
C_size = [512,512];
if(A_size ~= C_size)
    A = imresize(A,C_size);
end
if(B_size ~= C_size)
    B = imresize(B,C_size);
end

%gaussian kernel
kernel=fspecial('gaussian',[5 5],1);

%obtain the Gauss Pyramid
G_A0 = A;
G_A1 = conv2(G_A0,kernel,'same');
G_A1 = G_A1(2:2:size(G_A1,1),2:2:size(G_A1,2));
G_A2 = conv2(G_A1,kernel,'same');
G_A2 = G_A2(2:2:size(G_A2,1),2:2:size(G_A2,2));
G_A3 = conv2(G_A2,kernel,'same');
G_A3 = G_A3(2:2:size(G_A3,1),2:2:size(G_A3,2));
G_A4 = conv2(G_A3,kernel,'same');
G_A4 = G_A4(2:2:size(G_A4,1),2:2:size(G_A4,2));
G_A5 = conv2(G_A4,kernel,'same');
G_A5 = G_A5(2:2:size(G_A5,1),2:2:size(G_A5,2));

G_B0 = B;
G_B1 = conv2(G_B0,kernel,'same');
G_B1 = G_B1(2:2:size(G_B1,1),2:2:size(G_B1,2));
G_B2 = conv2(G_B1,kernel,'same');
G_B2 = G_B2(2:2:size(G_B2,1),2:2:size(G_B2,2));
G_B3 = conv2(G_B2,kernel,'same');
G_B3 = G_B3(2:2:size(G_B3,1),2:2:size(G_B3,2));
G_B4 = conv2(G_B3,kernel,'same');
G_B4 = G_B4(2:2:size(G_B4,1),2:2:size(G_B4,2));
G_B5 = conv2(G_B4,kernel,'same');
G_B5 = G_B5(2:2:size(G_B5,1),2:2:size(G_B5,2));

%get Laplacian Pyramid
L_A0 = double(G_A0)-imresize(G_A1,size(G_A0));
L_A1 = double(G_A1)-imresize(G_A2,size(G_A1));
L_A2 = double(G_A2)-imresize(G_A3,size(G_A2));
L_A3 = double(G_A3)-imresize(G_A4,size(G_A3));
L_A4 = double(G_A4)-imresize(G_A5,size(G_A4));
L_A5 = double(G_A5);

L_B0 = double(G_B0)-imresize(G_B1,size(G_B0));
L_B1 = double(G_B1)-imresize(G_B2,size(G_B1));
L_B2 = double(G_B2)-imresize(G_B3,size(G_B2));
L_B3 = double(G_B3)-imresize(G_B4,size(G_B3));
L_B4 = double(G_B4)-imresize(G_B5,size(G_B4));
L_B5 = double(G_B5);

%construct the mask
size0 = size(L_A0);
mask0 = zeros(size0);
mask0(:,1:size0(2)/2)=1;
mask0(:,size0(2)/2-5:1:size0(2)/2+5)=repmat(1:-0.1:0,[size0(1) 1]);
size1 = size(L_A1);
mask1 = zeros(size1);
mask1(:,1:size1(2)/2)=1;
mask1(:,size1(2)/2-5:1:size1(2)/2+5)=repmat(1:-0.1:0,[size1(1) 1]);
size2 = size(L_A2);
mask2 = zeros(size2);
mask2(:,1:size2(2)/2)=1;
mask2(:,size2(2)/2-5:1:size2(2)/2+5)=repmat(1:-0.1:0,[size2(1) 1]);
size3 = size(L_A3);
mask3 = zeros(size3);
mask3(:,1:size3(2)/2)=1;
mask3(:,size3(2)/2-5:1:size3(2)/2+5)=repmat(1:-0.1:0,[size3(1) 1]);
size4 = size(L_A4);
mask4 = zeros(size4);
mask4(:,1:size4(2)/2)=1;
mask4(:,size4(2)/2-5:1:size4(2)/2+5)=repmat(1:-0.1:0,[size4(1) 1]);
size5 = size(L_A5);
mask5 = zeros(size5);
mask5(:,1:size5(2)/2)=1;
mask5(:,size5(2)/2-5:1:size5(2)/2+5)=repmat(1:-0.1:0,[size5(1) 1]);

%obtain the output
L_C0 = L_A0 .* mask0 + L_B0 .* (1-mask0);
L_C1 = L_A1 .* mask1 + L_B1 .* (1-mask1);
L_C2 = L_A2 .* mask2 + L_B2 .* (1-mask2);
L_C3 = L_A3 .* mask3 + L_B3 .* (1-mask3);
L_C4 = L_A4 .* mask4 + L_B4 .* (1-mask4);
L_C5 = L_A5 .* mask5 + L_B5 .* (1-mask5);
C = L_C0+imresize(L_C1,size0)+imresize(L_C2,size0)+imresize(L_C3,size0)+imresize(L_C4,size0)+imresize(L_C5,size0);

figure(1);
imshow(A);
figure(2);
imshow(B);
figure(3);
imshow(uint8(C));

end

 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100

实验效果:

输入两张光照差别很大的图像: 
输入图片 
左半部分使用左图,右半部分使用右图,进行多波段融合得到如下: 
这里写图片描述


每个波段融合使用的掩膜如下(白色代表左图成分,黑色代表右图成分): 
sigma0 
sigma1 
sigma2 
sigma3 
sigma4 
sigma5

其中前四幅图为显示方便做了偏移处理。

参考

  1. P. Burt and E. Adelson. A multiresolution spline with application to image mosaics. ACM Transactions on Graphics, 2(4):217–236, 1983.
  2. Matthew Brown and David G. Lowe. Automatic Panoramic Image Stitching using Invariant Features.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值