您现在的位置:首页 >> ★免费资源 >> 源码下载 >> 内容

MATLAB代做|FPGA代做|Python代做--拉普拉斯金字塔

时间:2019-1-5 15:10:49 点击:

  核心提示:MATLAB代做|FPGA代做|Python代做--拉普拉斯金字塔...
clc;
clear;
close all;
warning off;

A = imread('b1.jpg');
B = imread('b2.jpg');
if size(A,3)==3
   A = rgb2gray(A);
   B = rgb2gray(B);
end
%为了在FPGA中仿真速度快些,我们将图像的大小进行缩小
A = imresize(A,[512 512]);
B = imresize(B,[512 512]);
A = double(A);
B = double(B);

%先进行高斯金字塔分层
%先进行高斯金字塔分层
layer    = 7;      
h        = [1  4  6  4 1;
            4 16 24 16 4; 
            6 24 36 24 6;
            4 16 24 16 4;
            1  4  6  4 1];
        
h        = h/256;
G_A      = cell(layer+1,1);
G_B      = cell(layer+1,1);
T_imgA   = A;
T_imgB   = B;
G_A{1,1} = A;
G_B{1,1} = B;

for i=2:layer+1
  T_imgA   = imfilter(G_A{i-1,1},h,'conv','same');
  T_imgB   = imfilter(G_B{i-1,1},h,'conv','same');
  G_A{i,1} = T_imgA(2:2:end,2:2:end);
  G_B{i,1} = T_imgB(2:2:end,2:2:end);  
end

%拉普拉斯分解 
%拉普拉斯分解 
L_A = cell(layer+1,1);
L_B = cell(layer+1,1);
for i=1:layer
    T_A1     = G_A{i,1};
    T_B1     = G_B{i,1};
    T_A2     = zeros(size(T_A1));
    T_B2     = zeros(size(T_B1));
    T_A2(2:2:end,2:2:end) = G_A{i+1,1};
    T_B2(2:2:end,2:2:end) = G_B{i+1,1};
    L_A{i,1} = 4*imfilter(T_A2,h,'conv','same');
    L_B{i,1} = 4*imfilter(T_B2,h,'conv','same');
    L_A{i,1} = T_A1 - L_A{i,1};
    L_B{i,1} = T_B1 - L_B{i,1};
end
L_A{end,1} = cell2mat(G_A(end,1));
L_B{end,1} = cell2mat(G_B(end,1));

%图像融合
%图像融合
%拉普拉斯金字塔的顶层融合
%拉普拉斯金字塔的顶层融合
diff_Ax =  diff([L_A{end,1} L_A{end,1}(:,end)],1,2);
diff_Ay =  diff([L_A{end,1};L_A{end,1}(end,:)],1,1);
diff_Bx =  diff([L_B{end,1} L_B{end,1}(:,end)],1,2);
diff_By =  diff([L_B{end,1};L_B{end,1}(end,:)],1,1);
diff_A  = sqrt((diff_Ax.^2+diff_Ay.^2)/2);
diff_B  = sqrt((diff_Bx.^2+diff_By.^2)/2);
diff_A  = [diff_A(:,1) diff_A diff_A(:,end)];
diff_A  = [diff_A(1,:);diff_A;diff_A(end,:)];
diff_B  = [diff_B(:,1) diff_B diff_B(:,end)];
diff_B  = [diff_B(1,:);diff_B;diff_B(end,:)];
A_G     = im2col(diff_A,[3 3],'sliding');
B_G     = im2col(diff_B,[3 3],'sliding');
A_G     = sum(A_G,1)/4;
B_G     = sum(B_G,1)/4;
ind     = (A_G>=B_G);
L_C     = cell(layer+1,1);
L_C{end,1}(ind)  = L_A{end,1}(ind);
L_C{end,1}(~ind) = L_B{end,1}(~ind);
L_C{end,1}       = reshape(L_C{end,1},size(L_A{end,1}));

%其余层的融合
%其余层的融合
ARE_A = cell(layer,1);
ARE_B = cell(layer,1);
h_w   = [1 2 1;2 4 2;1 2 1]/16;
 
for i=1:layer
    ARE_A{i,1} = imfilter(abs(L_A{i,1}),h_w,'conv','same');
    ARE_B{i,1} = imfilter(abs(L_B{i,1}),h_w,'conv','same');
end
 
for i=1:layer
    ind            = (ARE_A{i,1}>=ARE_B{i,1});
    L_C{i,1}(ind)  = L_A{i,1}(ind);
    L_C{i,1}(~ind) = L_B{i,1}(~ind);
    L_C{i,1}       = reshape(L_C{i,1},size(L_A{i,1}));
end

%拉普拉斯重建 
%拉普拉斯重建
G_C        = cell(layer+1,1);
G_C{end,1} = L_C{end,1}; 
for i=layer:-1:1
    T_C1                  = zeros(size(L_C{i,1}));
    T_C1(2:2:end,2:2:end) = G_C{i+1,1};
    G_C{i,1}              = 4*imfilter(T_C1,h,'conv','same');
    G_C{i,1}              = L_C{i,1}+G_C{i,1};
end
 
figure;
subplot(131);
imshow(A,[]);
title('A(左模糊)');
subplot(132);
imshow(B,[]);
title('B(右模糊)');
subplot(133);
imshow(uint8(G_C{1,1}));
title('融合图像');

联系:highspeedlogic

QQ :1224848052

微信:HuangL1121

邮箱:1224848052@qq.com

网站:http://www.mat7lab.com/

网站:http://www.hslogic.com/

微信扫一扫:

作者:拉普拉斯金字塔 来源:拉普拉斯金字塔
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做|matlab代写(www.hslogic.com) © 2019 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment