您好,欢迎访问三七文档
灰度阈值法x=imread(‘*.bmp’);N=256;[row,col]=size(x);th=0;p=zeros(N);fori=1:row*colp(fix(x(i)+1))=p(fix(x(i)+1))+1;endp1=zeros(N);p1(1)=p(1);fori=2:Np1(i)=p(i)-p(i-1);endp2=zeros(N);p2(1)=p1(1);fori=2:Np2(i)=p1(i)-p1(i-1);endfori=1:Nifp2(i)=0th=p2(i);endendfori=1:row*col;ifx(i)thx(i)=256;elsex(i)=0;endendRobert算子f=imread(‘*.bmp’);f1=double(f);[row,col]=size(f);f2=zeros([row,col]);forx=2:(row-1);fory=2:(col-1);f2(x,y)=sqrt((abs(f1(x,y)-f1(x+1,y+1)))^2+(abs(f1(x+1,y)-f1(x,y+1)))^2);endendLaplacian算子f=imread(‘*.bmp’);f1=double(f);[row,col]=size(f);f2=zeros([row,col]);forx=2:(row-1)fory=2:(col-1)f2(x,y)=f1(x-1,y)+f1(x+1,y)+f1(x,y-1)+f1(x,y+1)-4*f1(x,y);endend
本文标题:图像分割参考程序
链接地址:https://www.777doc.com/doc-2558397 .html