clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
name = 5;
% Initialise the maximum split level
level = 0;
% Initialise the maximum block size permitted
pmax = 0;
% default image number and type
N = 2; type = '.bmp';
% Set the Image name
switch name
case 1
str = 'clock';
case 2
str = 'lab';
case 3
str = 'pepsi';
case 4
str = 'OpenGL';
case 5
str = 'flower';
case 6
str = 'disk';
case 7
str = 'toy'; N = 3;
end
fprintf('Processing Image %s :\n', str);
for opt = 2
% Get dimensions of multi-focus images
inImg = double(imread (strcat('example images\',str,num2str(1),type)));
[p1,p2,p3] = size(inImg);
% Extend the image dimensions to 2 ^ X; X <= 512
dim = max(p1, p2);
maxDim = 1024;
while(dim < maxDim || dim == maxDim)
maxDim = maxDim / 2;
end
maxDim = maxDim * 2;
% if the maxDim == 2048, exit the program
if (maxDim == 2048)
disp('Image size is too big, it cannot process!');
return;
end
% Store the multi-focus source images
mImg=zeros(p1,p2,N);
for q=1:N
% Read the image data
inImg = imread (strcat('example images\',str,num2str(q),type));
[p1,p2,p3] = size(inImg);
% Convert image data from uint8 to double
inImg = double(inImg);
% Store the temp image
mImg(:,:,q)=inImg;
end
tic
% Weighted Block Size
sz = 17;
% Initialize the focus measure maps
FMs = zeros(p1, p2, N);
if opt == 1
disp('Fused method 1: Sum of Modified laplacian');
for kk = 1 : N
f = SML(mImg( : , : , kk), 1, 5);
FMs(:,:,kk) = f;
end
method = 'SML';
elseif opt == 2
disp('Fused method 2: Sum of Weighted Modified laplacian');
for kk = 1 : N
f = SML(mImg( : , : , kk), 1, 5);
FM = Local_Saliency(f, sz);
FMs(:,:,kk) = FM;
end
method = 'SWML';
end
%% Extend Imgs and Salmaps to maxDim( 2 ^ X )
Imgs = zeros(maxDim, maxDim, N);
dx = ceil((maxDim - p1) / 2);
dy = ceil((maxDim - p2) / 2);
Imgs(dx + 1 : dx + p1, dy + 1 : dy + p2, : ) = mImg;
Salmaps = zeros(maxDim, maxDim, N);
Salmaps(dx + 1 : dx + p1, dy + 1 : dy + p2, : ) = FMs;
%% Decomposition level and max permitted block-size must be restricted!!!
pmaxDim = maxDim / 2;
% Set the Default level, when not set level
if level == 0
level = log2(maxDim);
end
% Set the default maximum block size permitted
if pmax == 0
pmax = maxDim;
end
%% Quad tree docomposition process
pmin = 2;
Num = N;
[S, Fusion_tag, maxFM] = qt_sm_fusion(Imgs, Salmaps, Num, level);
Fusion_decision_map = Fusion_tag(dx + 1 : dx + p1, dy + 1 : dy + p2);
maxFM = maxFM(dx + 1 : dx + p1, dy + 1 : dy + p2);
%% 1. First Filter: Open and Close morphilogical filtering
Iter = 1;
Fusion_decision_map = morph_filter(Fusion_decision_map, N, Iter);
%% 2. Second Filter: Fiter small blocks inside
smallsz = p1 * p2 / 40;
Fusion_decision_map = Small_Block_Filter(Fusion_decision_map, N, smallsz);
FImg = zeros(p1,p2);
%% 1. the defined part, copied directly according to the decision map
for ii = 1 : Num
FImg = FImg + mImg(:,:,ii) .* (Fusion_decision_map == ii);
end
%% 2. the non-defined part, copied by maximum selection method
max_tag = zeros(p1, p2, N);
img_tag = zeros(p1, p2);
% Find the maximum FM in each FM
for ii = 1 : N
tag = (FMs(:,:,ii) == maxFM);
max_tag(:,:,ii) = tag;
img_tag = img_tag + tag .* ii;
end
% The nonpart images and maximum selection
non_part = (Fusion_decision_map < 1);
nonImgs = mImg;
part1 = zeros(p1,p2);
for ii = 1 : N
nonImgs(:,:,ii) = nonImgs(:,:,ii) .* non_part;
part1 = part1 + nonImgs(:,:,ii) .* max_tag(:,:,ii);
end
% The positions where more than one FM(i) have the maxFM
max_num = sum(max_tag, 3);
% The sigle and multiple positions
single_num = (max_num == 1);
multi_num = 1 - single_num;
% If there are more than one FMi equal to maxFM
part2 = sum(nonImgs, 3) ./ N;
% As to the whole nonpart
nonPart = part1 .* single_num + part2 .* multi_num;
% Final Fused image FImg
FImg = FImg + nonPart;
FImg = uint8(FImg);
figure,imshow(FImg);
figure,imshow(mat2gray(Fusion_decision_map))
%--------------------------------------------------------------------------
% Store the Fusion decision map and the fusion image
%--------------------------------------------------------------------------
imwrite((Fusion_decision_map ./ N), strcat('fusion decision maps\', method, '_', str, '.bmp'));
imwrite(FImg, strcat('fusion results\', method, '_', str, '.bmp'));
end
没有合适的资源?快使用搜索试试~ 我知道了~
基于加权焦点度量和四叉树的多焦点图像分割算法matlab仿真
共43个文件
bmp:30个
m:9个
jpg:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 65 浏览量
2022-10-31
23:12:06
上传
评论
收藏 5.71MB RAR 举报
温馨提示
1.版本:matlab2021a,我录制了仿真操作录像,可以跟着操作出仿真结果 2.领域:四叉树多焦点图像分割 3.内容:基于加权焦点度量和四叉树的多焦点图像分割算法matlab仿真 +仿真录像 4.适合人群:本,硕等教研学习使用
资源推荐
资源详情
资源评论
收起资源包目录
基于加权焦点度量和四叉树的多焦点图像分割算法matlab仿真.rar (43个子文件)
基于加权焦点度量和四叉树的多焦点图像分割算法matlab仿真
55.jpg 84KB
matlab
Main.m 5KB
func
Small_Block_Filter.m 1006B
Local_Saliency.m 385B
morph_filter.m 647B
block_values.m 518B
qt_sm_fusion.m 2KB
hPadImage.m 659B
SML.m 779B
QTDECOMP_Split.m 833B
example images
toy2.bmp 257KB
toy3.bmp 257KB
flower2.bmp 431KB
OpenGL1.bmp 423KB
disk2.bmp 301KB
flower1.bmp 431KB
disk1.bmp 301KB
OpenGL2.bmp 423KB
clock1.bmp 247KB
lab1.bmp 301KB
lab2.bmp 301KB
toy1.bmp 257KB
pepsi2.bmp 257KB
pepsi1.bmp 257KB
clock2.bmp 247KB
fusion decision maps
SWML_flower.bmp 431KB
SWML_toy.bmp 257KB
SWML_lab.bmp 301KB
SWML_clock.bmp 247KB
SWML_pepsi.bmp 257KB
SWML_disk.bmp 301KB
SWML_OpenGL.bmp 423KB
SWML_Image_.bmp 257KB
fusion results
SWML_flower.bmp 431KB
SWML_toy.bmp 257KB
SWML_lab.bmp 301KB
SWML_clock.bmp 247KB
SWML_pepsi.bmp 257KB
SWML_disk.bmp 301KB
SWML_OpenGL.bmp 423KB
11.jpg 53KB
操作录像0034.avi 5.2MB
44.jpg 49KB
共 43 条
- 1
资源评论
- 天下归昕2023-10-21支持这个资源,内容详细,主要是能解决当下的问题,感谢大佬分享~
fpga和matlab
- 粉丝: 17w+
- 资源: 2629
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Kotlin语言的Android开发工具类集合源码
- 零延迟 DirectX 11 扩展实用程序.zip
- 基于Java的语音识别系统设计源码
- 基于Java和HTML的yang_home766个人主页设计源码
- 基于Java与前端技术的全国实时疫情信息网站设计源码
- 基于鸿蒙系统的HarmonyHttpClient设计源码,纯Java实现类似OkHttp的HttpNet框架与优雅的Retrofit注解解析
- 基于HTML和JavaScript的廖振宇图书馆前端设计源码
- 基于Java的Android开发工具集合源码
- 通过 DirectX 12 Hook (kiero) 实现通用 ImGui.zip
- 基于Java开发的YY网盘个人网盘设计源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功