Save all bands (1-336) of a multi-dimensional data in a structure array format
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Eberechi ICHI
am 2 Feb. 2022
Kommentiert: Eberechi ICHI
am 3 Feb. 2022
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 Kommentare
Walter Roberson
am 2 Feb. 2022
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.
Akzeptierte Antwort
Walter Roberson
am 2 Feb. 2022
%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)
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!