clear all;
close all;
for jjj = 1:14
name = num2str(jjj,'%02d');
input1=imread(['Images\source' name '_1.tif']);
input2=imread(['Images\source' name '_2.tif']);
input1 = double(input1);
input2 = double(input2);
hei2 = size(input1,1);
wid2 = size(input1,2);
hei = ceil(size(input1,1) /2);
wid = ceil(size(input1,2) /2);
lvl = size(input1,3);
N = 7;
win = ones(N,N);
thold = conv2(ones(hei,wid),win,'same') *0.4;
thold2 = thold * 2;
thold3 = conv2(ones(ceil(hei/N),ceil(wid/N)),win,'same') *0.5;
C1 = zeros(hei,wid);
C2 = zeros(hei,wid);
sum_xh12 = zeros(hei-1,wid-1);
sum_xh22 = zeros(hei-1,wid-1);
map1 = zeros(hei,wid,lvl);
map2 = zeros(hei,wid,lvl);
map_yat = zeros(hei,wid,lvl);
wav = 'haar';
my_fun = @(x) round(x.^2);
tic
thetime = cputime;
for iii = 1:10
[xa1,xh1,xv1,xd1,xxa1,xxh1,xxv1,xxd1]=my_dwt2(input1,wav);
[xa2,xh2,xv2,xd2,xxa2,xxh2,xxv2,xxd2]=my_dwt2(input2,wav);
for i = 1:lvl
C1 = C1 + my_fun(xh1(:,:,i)) + my_fun(xv1(:,:,i)) + my_fun(xd1(:,:,i));
C2 = C2 + my_fun(xh2(:,:,i)) + my_fun(xv2(:,:,i)) + my_fun(xd2(:,:,i));
C1(1:end-1,1:end-1) = C1(1:end-1,1:end-1) + my_fun(xxh1(:,:,i)) + my_fun(xxv1(:,:,i)) + my_fun(xxd1(:,:,i));
C2(1:end-1,1:end-1) = C2(1:end-1,1:end-1) + my_fun(xxh2(:,:,i)) + my_fun(xxv2(:,:,i)) + my_fun(xxd2(:,:,i));
end
delta = sign(conv2(C1-C2, win, 'same'));
temp = zeros(ceil(hei/N),ceil(wid/N));
for i = 1:N:hei-N+1
for j = 1:N:wid-N+1
temp((i+N-1)/N,(j+N-1)/N) = sum(sum(delta(i:i+N-1,j:j+N-1)));
end
end
if sum(abs(temp(:,end))) == 0
temp(:,end) = temp(:,end-1);
end
if sum(abs(temp(end,:))) == 0
temp(end,:) = temp(end-1,:);
end
temp(temp<thold3&temp>-thold3) = 0;
temp(temp>=thold3) = 1;
temp(temp<=-thold3) = -1;
temp1 = conv2(double(temp==1),ones(3,3),'same') ./ conv2(ones(size(temp)),ones(3,3),'same');
temp2 = conv2(double(temp==-1),ones(3,3),'same') ./ conv2(ones(size(temp)),ones(3,3),'same');
temp = zeros(ceil(hei/N),ceil(wid/N));
temp(temp1==1) = 1;
temp(temp2==1) = -1;
tempt = temp == 1;
tempt = 1-bwareaopen(1-tempt,floor(hei*wid/N^2/100));
temp(tempt==1) = 1;
tempt = temp == -1;
tempt = 1-bwareaopen(1-tempt,floor(hei*wid/N^2/100));
temp(tempt==1) = -1;
temp = imresize(temp,N,'nearest');
temp = temp(1:hei,1:wid,:);
W = conv2(delta, win, 'same');
map1 = max(sign(W-thold),0);
map2 = max(sign(-thold-W),0);
map1 = temp==1 | (map1 & temp==0);
map2 = temp==-1 | (map2 & temp==0);
map3 = 1 - map1 - map2;
map_yat = (thold-W)./thold2;
if lvl > 1
map_yat = repmat(map_yat,1,1,lvl);
map1 = repmat(map1,1,1,lvl);
map2 = repmat(map2,1,1,lvl);
map3 = repmat(map3,1,1,lvl);
end
map_yht = abs(xh1) > abs(xh2);
map_yvt = abs(xv1) > abs(xv2);
map_ydt = abs(xd1) > abs(xd2);
yat = xa2.*map_yat + xa1.*(1-map_yat);
yht = xh1.*map_yht + xh2.*(1-map_yht);
yvt = xv1.*map_yvt + xv2.*(1-map_yvt);
ydt = xd1.*map_ydt + xd2.*(1-map_ydt);
ya = xa1.*map1 + xa2.*map2 + yat.*map3;
yh = xh1.*map1 + xh2.*map2 + yht.*map3;
yv = xv1.*map1 + xv2.*map2 + yvt.*map3;
yd = xd1.*map1 + xd2.*map2 + ydt.*map3;
output = my_idwt2(ya,yh,yv,yd,wav);
output = output(1:hei2,1:wid2,:);
end
toc
% imwrite(output(1:hei2,1:wid2,1:lvl)/255, ['R:\source' name '_SSWT.png']);
end
没有合适的资源?快使用搜索试试~ 我知道了~
多焦点图像融合算法附matlab代码
共46个文件
tif:28个
png:14个
m:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 71 浏览量
2022-10-28
21:10:22
上传
评论 1
收藏 7.72MB ZIP 举报
温馨提示
1.版本:matlab2019a,不会运行可私信 2.领域:【图像融合】 3.内容:多焦点图像融合算法附matlab代码 4.适合人群:本科,硕士等教研学习使用
资源推荐
资源详情
资源评论
收起资源包目录
【图像融合】多焦点图像融合算法附matlab代码 上传.zip (46个子文件)
my_idwt2.m 831B
Images
source06_1.tif 629KB
source12_1.tif 23KB
source07_2.tif 160KB
source07_SSWT.png 100KB
source10_SSWT.png 150KB
source02_2.tif 50KB
source06_SSWT.png 288KB
source04_2.tif 59KB
source05_2.tif 908KB
source13_1.tif 170KB
source07_1.tif 162KB
source13_SSWT.png 95KB
source14_2.tif 301KB
source09_SSWT.png 36KB
source04_SSWT.png 28KB
source04_1.tif 58KB
source03_1.tif 128KB
source08_SSWT.png 121KB
source10_2.tif 223KB
source01_1.tif 1.2MB
source09_2.tif 53KB
source09_1.tif 53KB
source02_SSWT.png 27KB
source10_1.tif 223KB
source05_1.tif 908KB
source13_2.tif 170KB
source03_SSWT.png 69KB
source11_SSWT.png 25KB
source12_SSWT.png 11KB
source14_1.tif 301KB
source02_1.tif 50KB
source11_1.tif 62KB
source08_2.tif 214KB
source11_2.tif 62KB
source14_SSWT.png 154KB
source06_2.tif 616KB
source05_SSWT.png 450KB
source01_SSWT.png 570KB
source03_2.tif 124KB
source08_1.tif 194KB
source01_2.tif 1.21MB
source12_2.tif 22KB
A New Multi-Focus Image Fusion Algorithm and Its Efficient Implementation
my_dwt22.m 701B
Proposed_Single.m 4KB
my_dwt2.m 1KB
共 46 条
- 1
资源评论
- 辛辛Lab2023-04-06这个资源对我启发很大,受益匪浅,学到了很多,谢谢分享~
- weixin_482462772023-05-16资源内容总结地很全面,值得借鉴,对我来说很有用,解决了我的燃眉之急。
天天Matlab科研工作室
- 粉丝: 3w+
- 资源: 7259
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功