資源簡介
使用Matlab來批量處理圖片,可以分割圖片,且支持的格式豐富
代碼片段和文件信息
clc;clear;
filename=dir(‘C:\IMAGE_1\*.tif‘);
for?j=1:length(filename)
????img_src=imread(strcat(‘C:\IMAGE_1\‘filename(j).name));
????[heightwidthnch]=size(img_src);
????gray_src=rgb2gray(img_src);
????row_sum=sum(gray_src);
????threshold=height;
????l_0=0;
????l_1=0;
????%estimate?the?location?of?flame?in?X?direction?OF?LEFT?
????for?i=1:width/2
????????if((l_0==0)?&&?(row_sum(i)>threshold))
?????????l_0=i;
????????end
????????if((l_0>0)?&&(l_1==0)&&?(row_sum(i) ?????????l_1=i;
????????end
????end
????%estimate?the?location?of?flame?in?X?direction?OF?RIGHT
????r_0=width/2;
????r_1=width/2;
????for?i=width/2:width
????????if((r_0==width/2)?&&?(row_sum(i)>threshold))
????????????r_0=i;
????????end
????????if((r_0>width/2)?&&(r_1==width/2)&&?(row_sum(i) ????????????r_1=i;
????????end
????end
????if((r_1-r_0)~=(l_1-l_0))
????????temp=max(((r_1-r_0))((l_1-l_0)));
????????temp=temp/32+1;
????????temp=32*int16((temp
評論
共有 條評論