MATLAB 截取有目标物体算法


tic; clear all;  for k=3:40     if k<4         imdata1=imread('00005.bmp');              for k1=1:10:210           for k2=1:10:282               k3=k1+59;               k4=k2+59;         imdata2=imdata1(k1:k3,k2:k4);         b=imdata1(k1:k3,k2:k4);         level=graythresh(b);%获取灰度图片的阈值         b=medfilt2(b,[6,6]);%进行中值滤波;       %  b=imadjust(b,[ ],[ ],2);%增强高灰度级        % disp(level);         c=im2bw(b,0.4);         i=0;         for i1=1:60             for i2=1:60                 if(c(i1,i2)==1)                     i=i+1;                 end             end         end         disp(i)         if(i<3000)                 imwrite(imdata2,strcat('500',int2str(k1),int2str(k2),'.png'),'png');%把每帧图像存入硬盘            %  imwrite(c,strcat('300',int2str(k1),int2str(k2),'.png'),'png');%把每帧图像存入硬盘         end             end       end        end    end   toc;


你可能感兴趣的:(MATLAB 截取有目标物体算法)