【图像分割】基于花朵授粉算法实现图像的自适应多阈值快速分割附matlab代码

本文涉及的产品
视觉智能开放平台,视频通用资源包5000点
视觉智能开放平台,图像通用资源包5000点
视觉智能开放平台,分割抠图1万点
简介: 【图像分割】基于花朵授粉算法实现图像的自适应多阈值快速分割附matlab代码

1 内容介绍

为快速准确地将图像中目标和背景分离开来,将新型群体智能模型中的花朵授粉算法、最大类间阈值相结合,提出了一种图像分割新方法.该方法将图像阈值看成花朵授粉算法群算法中的花粉,利用信息熵和最大熵原理设计花朵授粉算法的适应度函数,逐代逼近最佳阈值.并利用Matlab实现了图像分割算法,对分割的结果进行分析.实验结果表明,该方法在阈值分割图像时,花朵授粉算法能够快速准确地将图像目标分离出来,分离出来的目标更加适合后序的分析和处理.

2 部分代码

% --------------------------------------------------------------------%

% Flower pollenation algorithm (FPA), or flower algorithm             %

% Programmed by Xin-She Yang @ May 2012                               %

% --------------------------------------------------------------------%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Notes: This demo program contains the very basic components of      %

% the flower pollination algorithm (FPA), or flower algorithm (FA),   %

% for single objective optimization.    It usually works well for     %

% unconstrained functions only. For functions/problems with           %

% limits/bounds and constraints, constraint-handling techniques       %

% should be implemented to deal with constrained problems properly.   %

%                                                                     %

% Citation details:                                                   %

%1)Xin-She Yang, Flower pollination algorithm for global optimization,%

% Unconventional Computation and Natural Computation,                 %

% Lecture Notes in Computer Science, Vol. 7445, pp. 240-249 (2012).   %

%2)X. S. Yang, M. Karamanoglu, X. S. He, Multi-objective flower       %

% algorithm for optimization, Procedia in Computer Science,           %

% vol. 18, pp. 861-868 (2013).                                        %

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


clc

clear all

close all

n=30;           % Population size, typically 10 to 25

p=0.8;           % probabibility switch


% Iteration parameters

N_iter=3000;            % Total number of iterations

fitnessMSE = ones(1,N_iter);


% % Dimension of the search variables Example 1

d=2;

Lb = -1*ones(1,d);

Ub = 1*ones(1,d);



% % Dimension of the search variables Example 2

% d=3;

% Lb = [-2 -1 -1];

% Ub = [2 1 1];


%

% % Dimension of the search variables Example 3

% d=3;

% Lb = [-1 -1 -1];

% Ub = [1 1 1];

%

%

% % % Dimension of the search variables Example 4

% d=9;

% Lb = -1.5*ones(1,d);

% Ub = 1.5*ones(1,d);


% Initialize the population/solutions

for i=1:n,

   Sol(i,:)=Lb+(Ub-Lb).*rand(1,d);

   % To simulate the filters use fitnessX() functions in the next line

   Fitness(i)=fitness(Sol(i,:));

end


% Find the current best

[fmin,I]=min(Fitness);

best=Sol(I,:);

S=Sol;


% Start the iterations -- Flower Algorithm

for t=1:N_iter,

   % Loop over all bats/solutions

   for i=1:n,

       % Pollens are carried by insects and thus can move in

       % large scale, large distance.

       % This L should replace by Levy flights

       % Formula: x_i^{t+1}=x_i^t+ L (x_i^t-gbest)

       if rand>p,

           %% L=rand;

           L=Levy(d);

           dS=L.*(Sol(i,:)-best);

           S(i,:)=Sol(i,:)+dS;

           

           % Check if the simple limits/bounds are OK

           S(i,:)=simplebounds(S(i,:),Lb,Ub);

           

           % If not, then local pollenation of neighbor flowers

       else

           epsilon=rand;

           % Find random flowers in the neighbourhood

           JK=randperm(n);

           % As they are random, the first two entries also random

           % If the flower are the same or similar species, then

           % they can be pollenated, otherwise, no action.

           % Formula: x_i^{t+1}+epsilon*(x_j^t-x_k^t)

           S(i,:)=S(i,:)+epsilon*(Sol(JK(1),:)-Sol(JK(2),:));

           % Check if the simple limits/bounds are OK

           S(i,:)=simplebounds(S(i,:),Lb,Ub);

       end

       

       % Evaluate new solutions

       % To simulate the filters use fitnessX() functions in the next

       % line

       Fnew=fitness(S(i,:));

       % If fitness improves (better solutions found), update then

       if (Fnew<=Fitness(i)),

           Sol(i,:)=S(i,:);

           Fitness(i)=Fnew;

       end

       

       % Update the current global best

       if Fnew<=fmin,

           best=S(i,:)   ;

           fmin=Fnew   ;

       end

   end

   % Display results every 100 iterations

   if round(t/100)==t/100,

       best

       fmin

   end

   

   fitnessMSE(t) = fmin;

   

end

%figure, plot(1:N_iter,fitnessMSE);

% Output/display

disp(['Total number of evaluations: ',num2str(N_iter*n)]);

disp(['Best solution=',num2str(best),'   fmin=',num2str(fmin)]);

figure(1)

plot( fitnessMSE)

xlabel('Iteration');

ylabel('Best score obtained so far');

3 运行结果

4 参考文献

[1]李小琦. 基于Matlab的图像阈值分割算法研究[J]. 软件导刊, 2014, 13(12):3.

[2]霍凤财等. "基于人工蜂群算法的图像阈值分割." 自动化技术与应用 035.002(2016):112-116.

博主简介:擅长智能优化算法神经网络预测信号处理元胞自动机图像处理路径规划无人机雷达通信无线传感器等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。


相关文章
|
2月前
|
机器学习/深度学习 算法 机器人
【水下图像增强融合算法】基于融合的水下图像与视频增强研究(Matlab代码实现)
【水下图像增强融合算法】基于融合的水下图像与视频增强研究(Matlab代码实现)
212 0
|
3月前
|
传感器 机器学习/深度学习 编解码
MATLAB|主动噪声和振动控制算法——对较大的次级路径变化具有鲁棒性
MATLAB|主动噪声和振动控制算法——对较大的次级路径变化具有鲁棒性
206 3
|
3月前
|
存储 编解码 算法
【多光谱滤波器阵列设计的最优球体填充】使用MSFA设计方法进行各种重建算法时,图像质量可以提高至多2 dB,并在光谱相似性方面实现了显著提升(Matlab代码实现)
【多光谱滤波器阵列设计的最优球体填充】使用MSFA设计方法进行各种重建算法时,图像质量可以提高至多2 dB,并在光谱相似性方面实现了显著提升(Matlab代码实现)
140 6
|
2月前
|
机器学习/深度学习 算法 机器人
使用哈里斯角Harris和SIFT算法来实现局部特征匹配(Matlab代码实现)
使用哈里斯角Harris和SIFT算法来实现局部特征匹配(Matlab代码实现)
144 8
|
2月前
|
机器学习/深度学习 算法 自动驾驶
基于导向滤波的暗通道去雾算法在灰度与彩色图像可见度复原中的研究(Matlab代码实现)
基于导向滤波的暗通道去雾算法在灰度与彩色图像可见度复原中的研究(Matlab代码实现)
158 8
|
2月前
|
存储 机器学习/深度学习 监控
网络管理监控软件的 C# 区间树性能阈值查询算法
针对网络管理监控软件的高效区间查询需求,本文提出基于区间树的优化方案。传统线性遍历效率低,10万条数据查询超800ms,难以满足实时性要求。区间树以平衡二叉搜索树结构,结合节点最大值剪枝策略,将查询复杂度从O(N)降至O(logN+K),显著提升性能。通过C#实现,支持按指标类型分组建树、增量插入与多维度联合查询,在10万记录下查询耗时仅约2.8ms,内存占用降低35%。测试表明,该方案有效解决高负载场景下的响应延迟问题,助力管理员快速定位异常设备,提升运维效率与系统稳定性。
195 4
|
2月前
|
机器学习/深度学习 算法 数据可视化
基于MVO多元宇宙优化的DBSCAN聚类算法matlab仿真
本程序基于MATLAB实现MVO优化的DBSCAN聚类算法,通过多元宇宙优化自动搜索最优参数Eps与MinPts,提升聚类精度。对比传统DBSCAN,MVO-DBSCAN有效克服参数依赖问题,适应复杂数据分布,增强鲁棒性,适用于非均匀密度数据集的高效聚类分析。
|
2月前
|
开发框架 算法 .NET
基于ADMM无穷范数检测算法的MIMO通信系统信号检测MATLAB仿真,对比ML,MMSE,ZF以及LAMA
简介:本文介绍基于ADMM的MIMO信号检测算法,结合无穷范数优化与交替方向乘子法,降低计算复杂度并提升检测性能。涵盖MATLAB 2024b实现效果图、核心代码及详细注释,并对比ML、MMSE、ZF、OCD_MMSE与LAMA等算法。重点分析LAMA基于消息传递的低复杂度优势,适用于大规模MIMO系统,为通信系统检测提供理论支持与实践方案。(238字)
|
3月前
|
机器学习/深度学习 传感器 算法
【无人车路径跟踪】基于神经网络的数据驱动迭代学习控制(ILC)算法,用于具有未知模型和重复任务的非线性单输入单输出(SISO)离散时间系统的无人车的路径跟踪(Matlab代码实现)
【无人车路径跟踪】基于神经网络的数据驱动迭代学习控制(ILC)算法,用于具有未知模型和重复任务的非线性单输入单输出(SISO)离散时间系统的无人车的路径跟踪(Matlab代码实现)
214 2
|
3月前
|
canal 算法 vr&ar
【图像处理】基于电磁学优化算法的多阈值分割算法研究(Matlab代码实现)
【图像处理】基于电磁学优化算法的多阈值分割算法研究(Matlab代码实现)
124 1

热门文章

最新文章