CLC;
关闭所有;
清楚;
工作区;
格式长g;
格式紧凑的;
字形大小= 25;
basefilename ='Eeewvwvwv.png';
文件夹= [];
fullfilename = fullfile(文件夹,basefilename);
grayImage = imread (fullFileName);
[行,列,numberofcolorChannels] =大小(灰度);
如果numberofcolorchannels> 1
灰度= rgb2gray(灰度);
结束
次要情节(2 2 1);
imshow (grayImage []);
轴在;
标题= Sprintf(“原始灰度图像”);
标题(标题,'fontsize',fontsize,“翻译”那'没有');
drawnow;
惠普= impixelinfo ();
设置(GCF,“单位”那'标准化'那“OuterPosition”, [0 0 1 1]);
设置(GCF,'工具栏'那'没有'那'菜单'那'没有');
设置(GCF,'名字'那'通过ImageAnalyst的演示'那'numbertitle'那'off')
drawnow;
面具=灰度> 30;
Props = RegionProps(逻辑(掩码),'地区');
allAreas =排序([props.Area])
面膜= Bwareaopen(面膜,25);
mask = inclearborder(mask);
次要情节(2,2,2);
imshow(面具);
轴在;
轴映像;
标题(的二进制映像的面具那'fontsize',fontsize);
drawnow;
maskedGrayImage = grayImage;
MaskedGrayimage(〜掩码)= 0;
子图(2,2,3);
imshow(maskedgrayimage);
轴在;
轴映像;
标题('蒙面灰度图像'那'fontsize',fontsize);
drawnow;