| 基于MATLAB的图像处理程序 |
|
| 作者:adai 文章来源:本站原创 点击数: 更新时间:2006-12-11 |
|
|
I=im2double(rgb2gray(imread('D:\images\Image009.jpg'))) I=I(41:200,61:260) %level = graythresh(I) 下面是代替graythresh函数的 T=0.5*(min(I(:))+max(I(:))) done=false j=1 while ~done g=I>=T Tnext=0.5*(mean(I(g))+mean(I(~g))) done=abs(T-Tnext)<0.001 T=Tnext j=j+1 end %BW = im2bw(I,level)以BW=I>T代替 BW=I>T BW=~BW [m,n]=find(BW) x=hist(m,10:10:160) y=hist(n,10:10:200) %x [toppoint,Tlocation]=max(x) i=1 while i if x(i)>x(i+1) & x(i+1)<50 BW(1:i*10,:)=0 end i=i+1 end i=Tlocation+1 while i<=16 if x(i-1) BW(10*(i-1):160,:)=0 end i=i+1 end %y [toppoint,Tlocation]=max(y) i=1 while i if y(i)>y(i+1) & y(i+1)<50 BW(:,1:i*10)=0 end i=i+1 end i=Tlocation+1 while i<=20 if y(i-1) BW(:,10*(i-1):200)=0 end i=i+1 end I=I.*BW stddeviation=std(I(:))%std以图片中的算法代替 %下面再添加对图像矩阵I的三维处理
|