基于图像处理的公路裂纹检测方法研究与实现

发布时间 : 星期一 文章基于图像处理的公路裂纹检测方法研究与实现更新完毕开始阅读

石家庄铁道大学四方学院毕业设计

if count(i)~=0 st=i-1; break; end end st

for i=L:-1:1 if count(i)~=0 nd=i-1; break; end end nd

f=count(st+1:nd+1); size(f) E=[];

for Th=st:nd-1 Th av1=0; av2=0;

Pth=sum(count(1:Th+1));

%%%第一类的平均相对熵为

for i=0:Th

av1=av1-count(i+1)/Pth*log(count(i+1)/Pth+0.00001); end

%%%第二类的平均相对熵为

for i=Th+1:L-1

av2=av2-count(i+1)/(1-Pth)*log(count(i+1)/(1-Pth)+0.00001); end

E(Th-st+1)=av1+av2; end

position=find(E==(max(E))); th=st+position-1

40

%f是每个灰度出现的概率%%%设定初始分割阈值为 石家庄铁道大学四方学院毕业设计

for i=1:m for j=1:n if a(i,j)>th a(i,j)=255; else

a(i,j)=0; end end end

e2=double(a)-double(II); [m,n]=size(e3);

MSE3=sum(sum(e3(:).^2)/(m*n))

RMSE3=sqrt(sum(e3(:).^2)/(m*n)) PSNR3=10*log10(255^2/MSE3) subplot(223); imshow(BW);title ('Otsu法阈值分割图像'); subplot(224);imshow(a);;title ('最大熵阈值分割图像') ; 5.图像的边缘检测程序

I=imread('C:\\Users\\Zjf\\Desktop\\gllw.bmp'); II=rgb2gray(I)

subplot(231);imshow(II);title('原始图像') [g,t1]=edge(II,'prewitt',[],'both') e1=double(g)-double(II); [m,n]=size(e1);

MSE1=sum(sum(e1(:).^2)/(m*n))

RMSE1=sqrt(sum(e1(:).^2)/(m*n)) PSNR1=10*log10(255^2/MSE1) subplot(232);imshow(g,[]);title('经prewitt算子检测后的图像') [h,t2]=edge(II,'log',[],'both')

subplot(233);imshow(h,[]);title('经log算子检测后的图像') e2=double(h)-double(II); [m,n]=size(e2);

MSE2=sum(sum(e2(:).^2)/(m*n))

RMSE2=sqrt(sum(e1(:).^2)/(m*n))

41

%计算均方根误差 %计算峰值信噪比 %显示阈值分割图像 %显示阈值分割图像 %计算均方根误差 %计算峰值信噪比 %计算均方根误差

联系合同范文客服:xxxxx#qq.com(#替换为@)