小弟初学图像分割还不怎么大懂p1 = {'Input Num:'}; p2 = {'180'};p3 = inputdlg(p1,'Input Num:256',1,p2);p = str2num(p3{1}); p = p/255;bw = im2bw(I,p);

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 23:41:30

小弟初学图像分割还不怎么大懂p1 = {'Input Num:'}; p2 = {'180'};p3 = inputdlg(p1,'Input Num:256',1,p2);p = str2num(p3{1}); p = p/255;bw = im2bw(I,p);
小弟初学图像分割还不怎么大懂
p1 = {'Input Num:'}; p2 = {'180'};
p3 = inputdlg(p1,'Input Num:256',1,p2);
p = str2num(p3{1}); p = p/255;
bw = im2bw(I,p);

小弟初学图像分割还不怎么大懂p1 = {'Input Num:'}; p2 = {'180'};p3 = inputdlg(p1,'Input Num:256',1,p2);p = str2num(p3{1}); p = p/255;bw = im2bw(I,p);
阈值图像分割
I=imread('1.jpg');
I=double(I(:,:,1));
fxy=zeros(1,256);
[m,n]=size(I);
for i=1:m %统计每个灰度值的个数
for j=1:n
c=I(i,j);
fxy(c+1)=fxy(c+1)+1;
end
end
figure(1);plot(fxy);%画出灰度直方图
p1={'Input Num:'};
p2={'180'};
p3=inputdlg(p1,'Input Num:256',1,p2);
p=str2num(p3{1});
for i=1:m %小于阈值的为黑,大于阈值的为白
for j=1:n
if I(i,j)