差分进化算法在图像处理中的应用研究(Matlab代码实现)

简介: 差分进化算法在图像处理中的应用研究(Matlab代码实现)

💥1 概述

文献来源:


生物的进化普遍遵循达尔文的“物竞天择、适者生存”的准则,即通过个体之间的选择、交叉和变异来适应自然环境。进化算法就是仿效生物界进化过程的新型优化方法,不依赖与问题的具体特征,具有通用、简单、并行处理等优点,因此被认为是对21世纪的计算机技术有重大影响的关键技术。 差分进化算法提出时间较晚,但其以较强的全局收敛能力、鲁棒性和稳定性迅速成为进化算法领域的研究热点。差分进化算法保留了基于种群的全局搜索策略,采用实数编码、基于差分的简单变异操作和一对一的竞争生存策略,降低了进化操作的复杂性。差分进化算法作为一种高效、简单的并行优化算法,对其进行理论和应用研究具有重要的学术意义。 本文通过对差分进化算法理论基础的研究,针对不同应用问题给出了不同的改进算法。使用差分进化算法解决图像分割问题,并与最大类间方差法作比较分析,试验证明可节省大量时间。在含噪音图像分割问题中,本文使用二次探索改进差分进化算法,提高了算法在进化后期的搜索能力,改善了图像分割的视觉效果。 图像恢复问题是图像处理的重要问题之一。图像恢复问题的主要难点图像信息大,处理速度慢。因此,本文借助差分进化算法的收敛速度快、算法稳定等优点进行图像恢复。在图像恢复过程中算法结合图像特点,随机选取窗口进行交叉和变异操作,取得了较好的结果。  


📚2 运行结果

部分代码:

generationAtBestFit = [0 0];%stores generation and best fitness
spaceSize = size(searchSpace, 1);
totalPixels = sum(searchSpace);
normProba = searchSpace ./ totalPixels;%normalized probabilities
if thresh < 1 || thresh > spaceSize, disp('Thresholds should be in a range of 1 to 256');return;end
%-----Get an initial Fitness
[fitnessX, X] = OtsuFitness(X, spaceSize, totalPixels, normProba);
[val, fittest] = max(fitnessX);
for gen = 1:generations
    %-----Mutation and crossover
    for p = 1:population
        %don't mutate or crossover the one with best fitness
        if fittest == p, U(:, p) = X(:, p);continue;end
        %Select three vectors for mutation
        randX = linspace(1, population, population);randX(p)=[];
        px1 = ceil(rand(1,1)*numel(randX));x1 = randX(px1);randX(px1)=[];
        px2 = ceil(rand(1,1)*numel(randX));x2 = randX(px2);randX(px2)=[];
        px3 = ceil(rand(1,1)*numel(randX));x3 = randX(px3);   
        mutant = X(:, x1) + round(vBeta.*(X(:, x2) - X(:, x3)));
        %---Crossover (will always happen if threshold is 1)
        chk = rand(thresh, 1);
        chk(ceil(rand(1) * thresh)) = 0;%one compulsory crossover        
        bothSame = 0;
        if mutant == X(:, p), bothSame = 1; end
        for cross = 1:thresh
            %if vectors end up being exactly similar, re-generate randomly
            if bothSame==1, mutant(cross, 1) = floor(minThresh + (maxThresh - minThresh) * rand(1));continue;end
            if chk(cross) <= cr && thresh ~= 1,mutant(cross, 1) = X(cross, p);end            
        end
        %Bring thresholds within range by regeneration instead of clamping
        mutant(mutant > maxThresh | mutant < minThresh) = floor(minThresh + (maxThresh - minThresh) * rand(1));        
        U(:, p) = mutant(:);
    end    
    %-----Selection
    [fitnessU, U] = OtsuFitness(U, spaceSize, totalPixels, normProba);
    for p = 1:population
        if fitnessU(p) > fitnessX(p),
            X(:, p) = U(:, p);
            fitnessX(p) = fitnessU(p);
        end
    end
    [val, fittest] = max(fitnessX);    
    tempFitStore = [tempFitStore fitnessX(fittest)];
    %=======PSO hybrid attempt (does not work well enough)
    %if gen > 5,
    %    %get three X vectors that are closest in fitness to the best X
    %    tempX = X; tFitnessX = fitnessX;
    %    tempX(:,fittest) = []; tFitnessX(fittest) = [];
    %    [v, f] = max(tFitnessX);x1 = tempX(:, f);fitX1=v;tempX(:,f) = [];tFitnessX(f) = [];
    %    [v, f] = max(tFitnessX);x2 = tempX(:, f);fitX2=v;tempX(:,f) = [];tFitnessX(f) = [];        
    %    [v, f] = max(tFitnessX);x3 = tempX(:, f);fitX3=v;tempX(:,f) = [];tFitnessX(f) = [];        
    %    [xBest, fitXBest] = exploitWithPSO(X(:,fittest), x1, x2, x3, val, fitX1, fitX2, fitX3, spaceSize, totalPixels, normProba, maxThresh, minThresh);
    %    if fitXBest > fitnessX(fittest),
    %        X(:,fittest) = xBest;            
    %        fitnessX(fittest) = fitXBest;
    %    end
    %end
    %=====end of PSO
    %---Store the generation at which best fitness was achieved
    if fitnessX(fittest) > generationAtBestFit(2),
        generationAtBestFit(1) = gen;
        generationAtBestFit(2) = fitnessX(fittest);
    end
    if generationAtBestFit(1) > fastestGenerationForBestFitness,
        fastestGenerationForBestFitness = generationAtBestFit(1);
    end
    %fprintf('Image %d is max fit. fitness %f. Achived at gen %d\n', fittest, fitnessX(fittest), generationAtBestFit(1));        
    if fitnessX(fittest) > bestFitnessAmongTrials, 
        bestFitnessAmongTrials = fitnessX(fittest);
        bestThresholdAmongTrials = X(:,fittest);
    end
    %---decrease beta to lower exploration and favour exploitation
    if vBeta > 1/40, vBeta = vBeta - 1/40;end
    %if vBeta > 1/(thresh*4), vBeta = vBeta - 1/(4*thresh);end    
end %end of generation loop
runtime = [runtime toc];
if bestFitnessAmongTrials > tempBestFitnessAmongTrials,
    tempBestFitnessAmongTrials = bestFitnessAmongTrials;
    fitStore = tempFitStore;
end
end %end of trial loop
%---DE completed. Now display data
fprintf('mean: ');
mean(runtime)
fprintf('standard deviation: ');
std(runtime)
fprintf('fastestGenerationForBestFitness=%d\n', fastestGenerationForBestFitness);
fprintf('Best fitness achieved until now=%f with thresholds ', bestFitnessAmongTrials);
disp(bestThresholdAmongTrials');
%-----Display multithresholded images of each vector
figure(figNum);clf;figNum=figNum+1;
T = I;
for j = 1:thresh+1
    if j == 1,%first bunch
        T(I < bestThresholdAmongTrials(j)) = minThresh-1;%0
    else
        if j > thresh,%last bunch
            T(I >= bestThresholdAmongTrials(j-1)) = maxThresh-1;%255
        else%everything else
            T(I >= bestThresholdAmongTrials(j-1) & I < bestThresholdAmongTrials(j)) = bestThresholdAmongTrials(j-1);
        end
    end
end
imshow(T);   
title('Best thresholded image');    
%-----Display fitness graph
figure(figNum);clf;figNum=figNum+1;
plot(linspace(1, gen, gen), fitStore);
xlabel('Generation');ylabel('Fitness');title('Fitness over time');


🌈3 Matlab代码实现

🎉4 参考文献

部分理论来源于网络,如有侵权请联系删除。

[1]赵艳丽. 差分进化算法在图像处理中的应用研究[D].中国石油大学,2010.

相关文章
|
9天前
|
机器学习/深度学习 传感器 算法
【高创新】基于优化的自适应差分导纳算法的改进最大功率点跟踪研究(Matlab代码实现)
【高创新】基于优化的自适应差分导纳算法的改进最大功率点跟踪研究(Matlab代码实现)
97 14
|
9天前
|
机器学习/深度学习 边缘计算 运维
【电能质量扰动】基于ML和DWT的电能质量扰动分类方法研究(Matlab实现)
【电能质量扰动】基于ML和DWT的电能质量扰动分类方法研究(Matlab实现)
79 10
|
7天前
|
运维 监控 JavaScript
基于 Node.js 图结构的局域网设备拓扑分析算法在局域网内监控软件中的应用研究
本文探讨图结构在局域网监控系统中的应用,通过Node.js实现设备拓扑建模、路径分析与故障定位,提升网络可视化、可追溯性与运维效率,结合模拟实验验证其高效性与准确性。
64 3
|
9天前
|
机器学习/深度学习 算法
【概率Copula分类器】实现d维阿基米德Copula相关的函数、HACs相关的函数研究(Matlab代码实现)
【概率Copula分类器】实现d维阿基米德Copula相关的函数、HACs相关的函数研究(Matlab代码实现)
|
9天前
|
存储 算法 安全
【多目标工程应用】基于MOGWO的地铁隧道上方基坑工程优化设计研究(Matlab代码实现)
【多目标工程应用】基于MOGWO的地铁隧道上方基坑工程优化设计研究(Matlab代码实现)
|
9天前
|
传感器 机器学习/深度学习 编解码
【电缆】中压电缆局部放电的传输模型研究(Matlab代码实现)
【电缆】中压电缆局部放电的传输模型研究(Matlab代码实现)
|
9天前
|
机器学习/深度学习 运维 算法
【微电网多目标优化调度】多目标学习者行为优化算法MOLPB求解微电网多目标优化调度研究(Matlab代码实现)
【微电网多目标优化调度】多目标学习者行为优化算法MOLPB求解微电网多目标优化调度研究(Matlab代码实现)
|
11天前
|
算法 计算机视觉
【MPDR & SMI】失配广义夹角随输入信噪比变化趋势、输出信干噪比随输入信噪比变化趋势研究(Matlab代码实现)
【MPDR & SMI】失配广义夹角随输入信噪比变化趋势、输出信干噪比随输入信噪比变化趋势研究(Matlab代码实现)
|
11天前
|
编解码 人工智能 算法
【采用BPSK或GMSK的Turbo码】MSK、GMSK调制二比特差分解调、turbo+BPSK、turbo+GMSK研究(Matlab代码实现)
【采用BPSK或GMSK的Turbo码】MSK、GMSK调制二比特差分解调、turbo+BPSK、turbo+GMSK研究(Matlab代码实现)
|
11天前
|
机器学习/深度学习 编解码 并行计算
【改进引导滤波器】各向异性引导滤波器,利用加权平均来实现最大扩散,同时保持图像中的强边缘,实现强各向异性滤波,同时保持原始引导滤波器的低低计算成本(Matlab代码实现)
【改进引导滤波器】各向异性引导滤波器,利用加权平均来实现最大扩散,同时保持图像中的强边缘,实现强各向异性滤波,同时保持原始引导滤波器的低低计算成本(Matlab代码实现)

热门文章

最新文章