Save all bands (1-336) of a multi-dimensional data in a structure array format
1 回表示 (過去 30 日間)
古いコメントを表示
Hello all, please i want to save any of the datad .dat doble output in a strutue format.
I want it to have all the 336 bands with the matrix order 416x640 for each of the band.
your assistcnae is highly anticipated.
Here is aexcerpt of my code.
clc
close all
clear all
infos = enviinfo('sample.hdr');
infow = enviinfo('White.hdr');
infod = enviinfo('Dark.hdr');
% Read the .raw data file
datas = multibandread('sample.raw',[infos.Height, infos.Width, infos.Bands],...
infos.DataType, infos.HeaderOffset, infos.Interleave, infos.ByteOrder);
dataw = multibandread('White.raw',[infow.Height, infow.Width, infow.Bands],...
infow.DataType, infow.HeaderOffset, infow.Interleave, infow.ByteOrder);
datad = multibandread('Dark.raw',[infod.Height, infod.Width, infod.Bands],...
infod.DataType, infod.HeaderOffset, infod.Interleave, infod.ByteOrder);
Thanks.
2 件のコメント
Walter Roberson
2022 年 2 月 2 日
Do you want to create a struct array with field named datad where each entry is 416 x 640, and the struct array would be 1 x 336 ?
Do you want to create a scalar struct with 336 different numbered fields each of which contains a 416 x 640 array?
Your output seems to suggest that possibly Dark.raw only contains a single 416 x 640 array. If that is not correct, if you think that Dark.raw contains 416 x 640 x 336 all in one file, then you need to investigate why it is saying 416 x 640 only. Your dataw shows that your general method is able to return a 416 x 640 x 336, so it would have to be something about the individual file for which infod.Bands is saying 1 instead of 336.
採用された回答
Walter Roberson
2022 年 2 月 2 日
%example data to illustrate the function
dataw = randi([0 255], 416, 640, 336, 'uint8');
%the work
s = struct('dataw', squeeze(num2cell(dataw, [1 2])));
%check
whos s
size(s(1).dataw)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!