基于canny算子的边缘检测技术 的matlab程序 要程序可以用的 麻烦你了

如题所述

第1个回答  2011-06-07
I=imread(‘yxl.tif’);%读取图像
imshow(I) %显示原图像
BW3=edge(I,' canny',0.2); %canny图像边缘提取
figure,imshow(BW3) %显示canny图像
Canny方法不容易受噪声干扰,能够检测到真正的弱边缘。
下面附上其他的一些程序希望对你有用:
直方图均衡化:
>> I=imread('ck.bmp');
>> J=rgb2gray(I);
>> H=histeq(J); %计算和显示灰度图像J的直方图
>> subplot(2,2,1),imshow(J)
>> subplot(2,2,2),imshow(H)
>> subplot(2,2,3),imhist(J) %显示原始图像直方图
>> subplot(2,2,4),imhist(H) %显示均衡化后图像的直方图
直方图规定化:
>> I=imread('0.jpg');
>> J=histeq(I,32); %均衡化成32个灰度级的直方图
>> [counts,x]=imhist(J); %返回直方图图像向量counts
>> Q=imread('0.jpg');
>> figure,
>> subplot(2,2,1),imshow(Q);
>> subplot(2,2,2),imhist(Q);
>> M=histeq(Q,counts); %将原始图像Q的直方图变成指定向量counts
>> subplot(2,2,3),imshow(M);
>> subplot(2,2,4),imhist(M);
加入各种噪声:
M=imread('dl011.jpg') %读取MATLAB中的名为dl011.jpg的图像
subplot(3,3,1)
imshow(M) %显示原始图像
title('original')
P1=imnoise(M,'gaussian',0.02) %加入高斯躁声
subplot(3,3,2)
imshow(P1) %加入高斯躁声后显示图像
title('gaussian noise');
P2=imnoise(M,'salt & pepper',0.02) %加入椒盐躁声
subplot(3,3,3)
imshow(P2) %%加入椒盐躁声后显示图像
title('salt & pepper noise');
g=medfilt2(P1) %对高斯躁声中值滤波
subplot(3,3,5)
imshow(g)
title('medfilter gaussian')
h=medfilt2(P2) %对椒盐躁声中值滤波
subplot(3,3,6)
imshow(h)
title('medfilter salt & pepper noise')
l=[1 1 1 %对高斯躁声算术均值滤波
1 1 1
1 1 1];
l=l/9;
k=conv2(P1,l)
subplot(3,3,8)
imshow(k,[])
title('arithmeticfilter gaussian')
%对椒盐躁声算术均值滤波
d=conv2(P2,l)
subplot(3,3,9)
imshow(d,[])
title('arithmeticfilter salt & pepper noise')本回答被网友采纳
相似回答