精选优质文档-倾情为你奉上OTSU算法代码:I=imread(*);th=graythresh(I);J=im2bw(I,th);subplot(121)imshow(I);subplot(122)imshow(J);Bernsen算法代码:clc;clear allclose allI=imread(*);m,n = size(I);I_gray=double(I);T=zeros(m,n);M=3;N=3;for i=M+1:m-Mfor j=N+1:n-N max=1;min=255; for k=i-M:i+M for l=j-N:j+N if I_gray(k,l)max max=I_gray(k,l); end if I_gray(k,l)min min=I_gray(k,l); end end