MATLAB图像处理之人工阈值分割
%人工阈值分割
football = imread('football.jpg');
a=rgb2gray('football');
imhist(a); %灰度直方图
[m,n]=size(a);
football=a;
for i=1:m
for j=1:n
if(a(i,j)<105) %105是根据灰度直方图主观选取的数
football(i,j)=0;
else
football(i,j)=255;
end
end
end
figure;
imshow(football),title('人工阈值分割','fontsize',10);
football.jpg:
灰度直方图:
阈值分割结果: