1 内容介绍
本文介绍了一种基于布谷鸟算法的多级阈值(MT)算法。布谷鸟优化算法[CuckooSearch (CS)],也叫杜鹃搜索,是智能算法的其中一种,于2009年由剑桥大学Xin-SheYang和DEBSuash提出。CS算法是一种新颖的群体智能算法,其通过模拟某些种属布谷鸟的寻窝产卵的行为来有效地求解最优化问题。提出基于改进布谷鸟搜索算法的二维Tsallis熵、kapur、oust多阈值图像分割方法
2 仿真代码
function [Iout,bestnest,fmax,time]=CSMC_tsallis(n)
tic;
if nargin<1,
% Number of nests (or different solutions)
n=25;%(i.e cuckoos( new solution) can lay eggs in any of these n nest)
end
% Discovery rate of alien eggs/solutions
pa=0.5;%(how well the host birdscan detect alian eggs)
%% Change this if you want to get better results
N_IterTotalR=100;
N_IterTotalG=100;
N_IterTotalB=100;
%Data
I=imread('rice.png');
% I=rgb2gray(I);
Lmax= 255;
Nt=size(I,1)*size(I,2);
%% Simple bounds of the search domain
nd=5;% number of thresholds required
if size(I,3)==1 %grayscale image
[n_countR,x_valueR] = imhist(I(:,:,1));
elseif size(I,3)==3 %RGB image
[n_countR,x_valueR] = imhist(I(:,:,1));
[n_countG,x_valueG] = imhist(I(:,:,2));
[n_countB,x_valueB] = imhist(I(:,:,3));
end
for i=1:Lmax
if size(I,3)==1 %grayscale image
probR(i)=n_countR(i)/Nt;
elseif size(I,3)==3 %RGB image
probR(i)=n_countR(i)/Nt;
probG(i)=n_countG(i)/Nt;
probB(i)=n_countB(i)/Nt;
end
end
3 运行结果
4 参考文献
[1]吴禄慎, 程伟, 胡赞. 应用改进布谷鸟算法优化多阈值图像分割[J]. 吉林大学学报:工学版, 2021.
[2]朱浩亮, 李光平. 基于改进布谷鸟搜索算法的图像分割[J]. 计算机工程与设计, 2018, 39(5):6.