Write image cube in BIP format

3 ビュー (過去 30 日間)
James
James 2011 年 6 月 23 日
I am trying to write a 3-D image cube or 3-D matrix to a file that can be read in ENVI. When I open the file that I wrote from MATLAB in ENVI the image only displays correctly when the header file has the samples and lines switched and the interleave is BSQ. I need the interleave to be BIP and the samples and lines to be correct. I suspect that matlab writes to file by writing all rows and columns of band 1, then all rows and columns of band 2, etc. I need it to write row 1, column 1, all bands; row 1, column 2 all bands, etc. any ideas how to do this? Here is the partial code:
eventIDStr = num2str(eventID);
fwriteid = fopen([eventIDStr '_sav.dat'],'w');
count = fwrite(fwriteid,cube,'single');
status = fclose(fwriteid);
Thank You

回答 (1 件)

Walter Roberson
Walter Roberson 2011 年 6 月 23 日
MATLAB writes in its indexing order, which is down the columns first. You have to pass fwrite() an expression which will give you the desired result when the expression is written down-first.
It appears to me that perhaps
permute(cube,[3 1 2])
would be the expression to pass to fwrite()

カテゴリ

Help Center および File ExchangeBig Data Processing についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by