✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
边缘信息是图像最基本的特征,所包含的也是图像中用于识别的有用信息。为人们描述或识别目标以及解释图像提供了有价值的和重要的信息。边缘检测一直是计算机视觉和图像处理领域的经典研究课题之一。其目的是去发现图像中关于形状和反射或透射比的信息,是图像处理、图像分析、模式识别、计算机视觉以及人类视觉的基本步骤之一,其结果的正确性和可靠性将直接影响到机器视觉系统对客观世界的理解。由于目标边缘、图像纹理甚至噪声都可能成为有意义的边缘,因此很难找到一种普适性的边缘检测算法,现有诸多边缘检测的方法各有其特点,同时也都存在着各自的局限性和不足之处,因此图像的边缘检测这个领域还有待于进一步的改进和发展。
⛄ 部分代码
function saliency_EL_2010_main
%
% This is a demo program of the paper L. Ma, J. Tian, and W. Yu,
% "Visual saliency detection in image using ant colony optimisation and local phase coherence,"
% Electronics Letters, Vol. 46, Jul. 2010, pp. 1066-1068.
clear all; close all; clc;
% Load test image
img_in = double(imread('rice.png'));
% Perform saliency detection
mask = func_saliency_aco_phase(img_in);
figure;
subplot(121)
imshow(img_in,[]);
title('原图')
subplot(122)
imshow(mask );
title('蚁群增强后的图')
% Write the output saliency map
imwrite(uint8(mask),'test_saliency_map.bmp','bmp');
temp_col = (ant_search_range_col .* temp)';
[ii, jj, vv] = find(temp_col);
ant_next_col = vv;
ant_current_path_val(:,nMoveStep+1) = img_1D((ant_next_row-1).*ncol+ant_next_col);
ant_current_path_row(:,nMoveStep+1) = ant_next_row;
ant_current_path_col(:,nMoveStep+1) = ant_next_col;
ant_current_row = ant_next_row;
ant_current_col = ant_next_col;
ant_current_val = img_1D((ant_current_row-1).*ncol+ant_current_col);
rr = ant_current_row;
cc = ant_current_col;
delta_p_1D((rr-1).*ncol+cc,1) = 1;
delta_p = func_LexicoOrder_2D(delta_p_1D, nrow, ncol);
end % end of nMoveStep
p = (1-phi).*p + delta_p.*v.*(v>mean(v(:)));
p_1D = func_2D_LexicoOrder(p);
delta_p = zeros(size(img));
delta_p_1D = func_2D_LexicoOrder(delta_p);
end % end of nIteration
% Perform normalization to be range [0,255];
p = p./(sum(sum(p)));
p = (p-min(p(:)))./(max(p(:))-min(p(:))).*255;
%-------------------------------------------------------------------------
%------------------------------Inner Function ----------------------------
%-------------------------------------------------------------------------
% Convert data from 2D format to 1D format
function result = func_2D_LexicoOrder(x)
temp = x';
result = temp(:);
%-------------------------------------------------------------------------
%------------------------------Inner Function ----------------------------
%-------------------------------------------------------------------------
% Convert data from 1D format to 2D format
function result = func_LexicoOrder_2D(x, nRow, nColumn)
result = reshape(x, nColumn, nRow)';
%-------------------------------------------------------------------------
%------------------------------Inner Function ----------------------------
%-------------------------------------------------------------------------
% Calculate local phase coherence at each pixel position
function phaseCongruency = func_phasecong(im)
sze = size(im);
if nargin < 2
nscale = 3; % Number of wavelet scales.
end
if nargin < 3
norient = 6; % Number of filter orientations.
end
if nargin < 4
minWaveLength = 3; % Wavelength of smallest scale filter.
end
if nargin < 5
mult = 2; % Scaling factor between successive filters.
end
if nargin < 6
sigmaOnf = 0.55; % Ratio of the standard deviation of the
% Gaussian describing the log Gabor filter's transfer function
% in the frequency domain to the filter center frequency.
end
if nargin < 7
dThetaOnSigma = 1.7; % Ratio of angular interval between filter orientations
% and the standard deviation of the angular Gaussian
% function used to construct filters in the
% freq. plane.
end
if nargin < 8
k = 3.0; % No of standard deviations of the noise energy beyond the
% mean at which we set the noise threshold point.
% standard deviation to its maximum effect
% on Energy.
end
if nargin < 9
cutOff = 0.4; % The fractional measure of frequency spread
% below which phase congruency values get penalized.
end
g = 10; % Controls the sharpness of the transition in the sigmoid
% function used to weight phase congruency for frequency
% spread.
epsilon = .0001; % Used to prevent division by zero.
thetaSigma = pi/norient/dThetaOnSigma; % Calculate the standard deviation of the
% angular Gaussian function used to
% construct filters in the freq. plane.
imagefft = fft2(im); % Fourier transform of image
sze = size(imagefft);
rows = sze(1);
%-------------------------------------------------------------------------
%------------------------------Inner Function ----------------------------
%-------------------------------------------------------------------------
function a = submat(big,i,cols)
a = big(:,((i-1)*cols+1):(i*cols));
⛄ 运行结果
⛄ 参考文献
[1]张景虎. 基于蚁群算法的图像边缘检测研究[D]. 陕西师范大学, 2009.
[1] Kaur P , Gupta E N . Image Segmentation using Ant Colony Optimization and to Improved the Selection of Poor Segmentation.
❤️ 关注我领取海量matlab电子书和数学建模资料
❤️部分理论引用网络文献,若有侵权联系博主删除