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
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.
Eberechi ICHI
Eberechi ICHI 2022-2-2
Yes thanks Walter, you are right. I meant I dataw data. I want to save it in a structure array for all the bands.

请先登录,再进行评论。

采纳的回答

Walter Roberson
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
Name Size Bytes Class Attributes s 336x1 89491648 struct
size(s(1).dataw)
ans = 1×2
416 640

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by