资源简介
matlab基于蚁群算法的图像边缘检测代码,内含解释说明和可运行的例子,仅供参考。

代码片段和文件信息
function edge_ACO
%参考文献:“An Ant Colony Optimization Algorithm For Image Edge
close all; clear all; clc;
% 读入图像
filename = ‘ant128‘;
img=rgb2gray(imread(‘ant.jpg‘));
img = double(img)./255;
[nrow ncol] = size(img);
%公式(3.24.4)初始化
for nMethod = 1:4;
%四种不同的核函数 参见式 (3.24.7)-(3.24.10)
%E: exponential; F: flat; G: gaussian; S:Sine; T:Turkey; W:Wave
fprintf(‘Welcome to demo program of image edge detection using ant colony.\nPlease wait......\n‘);
v = zeros(size(img));
v_norm = 0;
for rr =1:nrow
for cc=1:ncol
%定义像素团
temp1 = [rr-2 cc-1; rr-2 cc+1; rr-1 cc-2; rr-1 cc-1; rr-1 cc; rr-1 cc+1; rr-1 cc+2; rr cc-1];
temp2 = [rr+2 cc+1; rr+2 cc-1; rr+1 cc+2; rr+1 cc+1; rr+1 cc; rr+1 cc-1; rr+1 cc-2; rr cc+1];
temp0 = find(temp1(:1)>=1 & temp1(:1)<=nrow & temp1(:2)>=1 & temp1(:2)<=ncol & temp2(:1)>=1 & temp2(:1)<=nrow & temp2(:2)>=1 & temp2(:2)<=ncol);
temp11 = temp1(temp0 :);
temp22 = temp2(temp0 :);
temp00 = zeros(size(temp111));
for kk = 1:size(temp111)
temp00(kk) = abs(img(temp11(kk1) temp11(kk2))-img(temp22(kk1) temp22(kk2)));
end
if size(temp111) == 0
v(rr cc) = 0;
v_norm = v_norm + v(rr cc);
else
lambda = 10;
switch nMethod
case 1%‘F‘
temp00 = lambda .* temp00;
case 2%‘Q‘
temp00 = lambda .* temp00.^2;
case 3%‘S‘
temp00 = sin(pi .* temp00./2./lambda);
case 4%‘W‘
temp00 = sin(pi.*temp00./lambda).*pi.*temp00./lambda;
end
v(rr cc) = sum(sum(temp00.^2));
v_norm = v_norm + v(rr cc);
end
end
end
% 归一化
v = v./v_norm;
v = v.*100;
p = 0.0001 .* ones(size(img)); % 信息素函数初始化
%参数设置。
alpha = 1; %式(3.24.4)中的参数
beta = 0.1; %式(3.24.4)中的参数
rho = 0.1; %式(3.24.11)中的参数
%式(3.24.12)中的参数
phi = 0.05; %equation (12) i.e. (9) in IEEE-CIM-06
ant_total_num = round(sqrt(nrow*ncol));
% 记录蚂蚁的位置
ant_pos_idx = zeros(ant_total_num 2);
% 初始化蚂蚁的位置
rand(‘state‘ sum(clock));
temp = rand(ant_total_num 2);
ant_pos_idx(:1) = round(1 + (nrow-1) * temp(:1)); %行坐标
ant_pos_idx(:2) = round(1 + (ncol-1) * temp(:2)); %列坐标
search_clique_mode = ‘8‘; %Figure 1
% 定义存储空间容量
if nrow*ncol == 128*128
A = 40;
memory_length = round(rand(1).*(1.15*A-0.85*A)+0.85*A);
elseif nrow*ncol == 256*256
A = 30;
memory_length = round(rand(1).*(1.15*A-0.85*A)+0.85*A);
elseif nrow*ncol == 512*512
A = 20;
memory_length = round(rand(1).*(1.15*A-0.85*A)+0.85*A);
end
ant_memory = zeros(ant_tot
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5121 2011-07-17 18:09 基于蚁群算法的图像边缘检测\ant.jpg
文件 4590 2011-09-26 22:40 基于蚁群算法的图像边缘检测\ant128_edge_aco_1.jpg
文件 4506 2011-09-26 22:41 基于蚁群算法的图像边缘检测\ant128_edge_aco_2.jpg
文件 8509 2012-02-15 23:25 基于蚁群算法的图像边缘检测\edge_ACO.m
文件 24064 2011-09-26 22:48 基于蚁群算法的图像边缘检测\程序运行说明.doc
相关资源
- 用蚁群算法求解TSP问题的matlab程序
- 蚁群算法论文+源代码
- 针对栅格路径规划的蚁群算法MATLAB
- 蚁群算法实现三维路径规划Matlab源码
- matlab蚁群算法.zip
- 论文研究-基于改进蚁群算法的车辆路
- 基于蚁群算法和神经网络匹配算法的
- 边缘检测+hough直线检测
- matlab蚁群算法各种经典蚁群算法for
- 基于栅格地图的蚁群算法路径规划
- 基于蚁群算法和神经网络匹配算法的
- 基于MATLAB的图像边缘检测算法的仿真
- 基于蚁群算法和神经网络匹配算法的
- 多种蚁群算法在机器人路径规划中的
- 机器人避障航路规划蚁群算法MATLAB仿
- 论文研究-基于MATLAB的数字图像边缘检
- matlab图像边缘检测GUI
- 基于matlab的八个方向sobel图像边缘检测
- 蚁群算法进行二维路径规划.zip
- 蚁群算法MATLAB代码287131
- 蚁群算法路径规划避障MATLAB源程序
- 蚁群算法无人机路径规划
- 粒子群 模拟退火 蚁群算法MATLAB实现
- 基本蚁群聚类算法及其改进算法带M
- 基于蚁群算法和神经网络匹配算法的
- 运用matlab编程实现蚁群算法的低压电
- 基于小波变换模极大的多尺度图像边
- 蚁群算法算法的路径规划MATLAB实现
- 利用蚁群算法对PID参数自整定程序源
- 蚁群算法最短路径matlab程序
评论
共有 条评论