💥1 概述
图像的边缘是指图像灰度急剧发生变化的不连续的地方,主要存在于目标和目标、背景和目标、不同色彩的区域之间,包含着图像的重要信息,在图像分析和理解中起着重要作用。
图像的边缘检测就是检测图像中灰度不连续的地方,是数字图像处理领域重要的分支之一。检测边缘的难点在于如何精确地定义边缘,随着研究的深入,学者提出了不同的边缘模型,多数边缘检测器的设计都基于某一种固定的边缘模型。例如,基于梯度的边缘检测方法将边缘视为灰度变化速率快的像素点集合,Konishi依据“边缘”和“非边缘”滤波器的统计规律来定义物体边缘",Peli 则提出基于视觉模型的算法3,将视觉可接受范围作为滤波频段,其阈值为人眼的对比敏感度。
📚2 运行结果
🎉3 参考文献
[1]徐艳蕾,赵继印,焦玉斌.噪声图像边缘检测方法的研究[J].计算机应用研究,2009,26(1):387-389
[2]刘闻,别红霞.基于蚁群算法的噪声图像边缘检测[J].软件,2013,34(12):256-259.
👨💻4 Matlab代码
部分代码:
function setNoiseImages(GUI_figure) global noises; imageNum = ceil(sqrt((length(noises)+1))); positionBase = 1/imageNum; shareData = guidata(GUI_figure); testImg = shareData.testImg; axes('Parent', GUI_figure,... 'Units', 'normalized',... 'Position',[0 1/2 1 1/2]*positionBase,... 'Visible', 'off'); imshow(imread(char(testImg.inImg))); for I = 1:length(noises) axes('Parent', GUI_figure,... 'Units', 'normalized',... 'Position',[(mod(I, imageNum)) floor((I)/imageNum)+1/2 1 1/2]*positionBase,... 'Visible','off'); imshow(imread(char(testImg.inNoise(I+1,:)))); end text=uicontrol('Style','text',... 'Units', 'normalized',... 'Position',[3/7 19/20 1/7 1/20]*positionBase,... 'String',strcat('Noise: 0%')); set(text,'BackGroundColor','red'); for I = 1:imageNum text=uicontrol('Style','text',... 'Units', 'normalized',... 'Position',[(mod(I, imageNum))+3/7 floor((I)/imageNum)+19/20 1/7 1/20]*positionBase,... 'String',['Noise: ', int2str(noises(I)*100), '%']); set(text,'BackGroundColor','red'); end drawnow; end function updateNGain2Slider(hObj,event,GUI_figure) global noiseWeights; val=get(hObj,'Value'); noiseWeights(3)=val; updateNGain2Text(); end function updateNGain2Text() global noises; global noiseWeights; imageNum = ceil(sqrt((length(noises)+1))); positionBase = 1/imageNum; uicontrol('Style','text',... 'Units', 'normalized',... 'Position',[(imageNum-1) (imageNum-1)+7/20 3/10 1/20]*positionBase,... 'String',['Noise Gain 2: ',num2str(noiseWeights(3),2)]); end function updateGenerationsSlider(hObj,event) global generations; val=get(hObj,'Value'); generations=round(val); updateGenerationsText(); end function updateGenerationsText() global noises; global generations; imageNum = ceil(sqrt((length(noises)+1))); positionBase = 1/imageNum; uicontrol('Style','text',... 'Units', 'normalized',... 'Position',[(imageNum-1) (imageNum-1)+17/20 3/10 1/20]*positionBase,... 'String',['Generations: ',int2str(generations)]); end function updatePopSizeSlider(hObj, event) global popSize; val=get(hObj,'Value'); popSize=round(val); updatePopSizeText(); end function updatePopSizeText() global noises; global popSize; imageNum = ceil(sqrt((length(noises)+1))); positionBase = 1/imageNum; uicontrol('Style','text',... 'Units', 'normalized',... 'Position',[(imageNum-1) (imageNum-1)+16/20 3/10 1/20]*positionBase,... 'String',['Pop Size: ',int2str(popSize)]); end function updateBestMatrix(inMatrix) global noises; imageNum = ceil(sqrt((length(noises)+1))); positionBase = 1/imageNum; uitable('Units', 'normalized',... 'Position', [(imageNum-1) (imageNum-1)+2/20 1 5/20]*positionBase,... 'Data', inMatrix); end function initialiseImages(GUI_figure) global noises; shareData = guidata(GUI_figure); img = shareData.img; testImg = shareData.testImg; % Generate and write noise and training images. for I=1:length(noises) writeLocation=strcat(testImg.inNoise(1), int2str(I), '.png'); testImg.inNoise(I+1,:)=writeLocation; for II=1:5 writeLocation=strcat(img(II).inNoise(1), int2str(I), '.png'); img(II).inNoise(I+1,:)=writeLocation; end end createNoiseImage(testImg, noises, 'gaussian');
完整代码:
链接:https://pan.baidu.com/s/1EaaNNZpD-eLt4OzUnSSGNg
提取码:22ns
--来自百度网盘超级会员V2的分享