日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab 多个波段,MatLab读取ENVI图像统计多波段图像信息

發布時間:2024/10/8 循环神经网络 76 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab 多个波段,MatLab读取ENVI图像统计多波段图像信息 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在ENVI統計遙感多波段圖像中每個波段的均值、方差、最大值、最小值是比較容易辦到的,但是如果要處理多批的數據就沒有那么方便了,這里轉載一個MatLab讀取ENVI圖像(img+hdr)的程序,并且計算了相關系數。

之前我在利用MatLab讀取ENVI圖像里分享了一個MatLab讀取ENVI圖像的函數,這里可以用上這個函數,具體的請查看上篇文章。

在新的.m文件里面實現批處理程序,代碼如下:

clc;

clear;

filestring='E:\郭\實驗數據2\*.img';%計算不同的路徑中的圖像,只需更改這里

%______以下,對于沒有顯式擴展名的情況,添加擴展名'.img'_________________%

subfile=filestring;

changefile=strrep(subfile,'*.img','');%找到圖像所在文件夾

cfile=dir(changefile);%找到該文件夾下所有文件

for k=1:length(cfile)

if (size(strfind(cfile(k).name,'.'))==0)%判斷文件名中有沒有'.',如果沒有意味著沒有擴展名

copyfile(strcat(changefile,cfile(k).name),strcat(changefile,strcat(cfile(k).name,'.img')));

%上面這句,為沒有'.img'的添加上

%delete(strcat(changefile,cfile(k).name));%刪除多余數據,可選

end

end

%_________________________________________________________________%

filedir=strrep(filestring,'*.img','');

file=dir(filestring);

filenum=length(file);

%___以下代碼計算每個圖像在每個波段的均值,以及每個波段上所有圖像均值的均值___%

fid=fopen(strcat(filedir,'均值.txt'),'wt');

fprintf(fid,'%s', '每個圖像在每個波段的均值');

total=zeros(52,14);

for k=1:filenum

tempfile=strcat(filedir,file(k).name);

imgdata=read_ENVIimagefile(tempfile);

fprintf(fid,'\n%s',strcat('file',cfile(k).name,':'));

for i=1:14%事先已經知道共有14個波段,這點不好,需要對read_ENVIimagefile進行改造

meanvalue=[];

imgband=imgdata(:,:,i);

[x,y]=size(imgband);

reband=reshape(imgband,x*y,1);

countmean=mean(reband);

total(k,i)=countmean;

countmean=num2str(countmean);

meanvalue=[meanvalue countmean ' '];

meanvalue=num2str(meanvalue);

fprintf(fid,'%s',meanvalue);

end

end

fclose(fid);

fid1=fopen(strcat(filedir,'所有圖像均值的均值.txt'),'wt');

fprintf(fid1,'所有圖像均值的均值:');

fprintf(fid1,'%s',num2str(mean(total)));

fclose(fid1);

%___以下代碼計算每個圖像在每個波段的最大值,以及每個波段上所有圖像的最大值的均值___%

fid=fopen(strcat(filedir,'最大值.txt'),'wt');

total=zeros(52,14);

for k=1:filenum

tempfile=strcat(filedir,file(k).name);

imgdata=read_ENVIimagefile(tempfile);

fprintf(fid,'\n%s',strcat('file',cfile(k).name,':'));

for i=1:14

maxvalue=[];

imgband=imgdata(:,:,i);

[x,y]=size(imgband);

reband=reshape(imgband,x*y,1);

countmax=max(reband);

total(k,i)=countmax;

countmax=num2str(countmax);

maxvalue=[maxvalue countmax ' '];

maxvalue=num2str(maxvalue);

fprintf(fid,'%s',maxvalue);

end

end

fclose(fid);

fid1=fopen(strcat(filedir,'所有圖像最大值的均值.txt'),'wt');

fprintf(fid1,'所有圖像最大值的均值:');

fprintf(fid1,'%s',num2str(mean(total)));

fclose(fid1);

%___以下代碼計算每個圖像在每個波段的最小值,以及每個波段上所有圖像的最小值的均值___%

fid=fopen(strcat(filedir,'最小值.txt'),'wt');

total=zeros(52,14);

for k=1:filenum

tempfile=strcat(filedir,file(k).name);

imgdata=read_ENVIimagefile(tempfile);

fprintf(fid,'\n%s',strcat('file',cfile(k).name,':'));

for i=1:14

minvalue=[];

imgband=imgdata(:,:,i);

[x,y]=size(imgband);

reband=reshape(imgband,x*y,1);

countmin=min(reband);

total(k,i)=countmin;

countmin=num2str(countmin);

minvalue=[minvalue countmin ' '];

minvalue=num2str(minvalue);

fprintf(fid,'%s',minvalue);

end

end

fclose(fid);

fid1=fopen(strcat(filedir,'所有圖像最小值的均值.txt'),'wt');

fprintf(fid1,'所有圖像最小值的均值:');

fprintf(fid1,'%s',num2str(mean(total)));

fclose(fid1);

%___以下代碼計算每個圖像在每個波段的方差,以及每個波段上所有圖像的方差的均值___%

fid=fopen(strcat(filedir,'方差.txt'),'wt');

total=zeros(52,14);

for k=1:filenum

tempfile=strcat(filedir,file(k).name);

imgdata=read_ENVIimagefile(tempfile);

fprintf(fid,'\n%s',strcat('file',cfile(k).name,':'));

for i=1:14

meanvalue=[];

imgband=imgdata(:,:,i);

[x,y]=size(imgband);

reband=reshape(imgband,x*y,1);

countvar=var(reband);

total(k,i)=countvar;

countvar=num2str(countvar);

varvalue=[meanvalue countvar ' '];

varvalue=num2str(varvalue);

fprintf(fid,'%s',varvalue);

end

end

fclose(fid);

fid1=fopen(strcat(filedir,'所有圖像方差的均值.txt'),'wt');

fprintf(fid1,'所有圖像方差的均值:');

fprintf(fid1,'%s',num2str(mean(total)));

fclose(fid1);

總結

以上是生活随笔為你收集整理的matlab 多个波段,MatLab读取ENVI图像统计多波段图像信息的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。