フィルターのクリア

concat of 3d mat files in a folder

1 回表示 (過去 30 日間)
khaled alsaih
khaled alsaih 2018 年 6 月 5 日
コメント済み: khaled alsaih 2018 年 6 月 6 日
i have 20 3d mat files in a folder and i have different sizes for each ex: 512*1024*128 668*512*64 512*512*49 etc all i need is to load these data then resize the first two dimensions to 512*512 and to make one mat file for all can anyone help me please
  5 件のコメント
Jan
Jan 2018 年 6 月 5 日
If you want to use a loop, how are the wanted files recognized? We cannot guess, which 20 files you want. But a meaningful example code must contain a method to determine the files. So please reveal the details.
khaled alsaih
khaled alsaih 2018 年 6 月 6 日
i have 20 (3d) images 7 images have the size of 512*1024*128 and 7 images have the size of 668*512*64 and 6 images have the size of 512*512*241 i want to load the data in the directory then resize all images to 512*512 then cocatenate them in one mat file

サインインしてコメントする。

採用された回答

Jan
Jan 2018 年 6 月 5 日
With a loop:
Folder = 'C:\Your\Path'; % Adjust the path to your needs
List = dir(fullfile(Folder, '*.mat'));
C = cell(size(List));
for k = 1:numel(List)
Data = load(fullfile(Folder, List(k).name));
M = Data.??? % Unfortunately you do not reveal what in the MAT files is.
% Perhaps:
% M = Data.Value;
C{k} = imresize(M, [512, 512]); % See KSSV's answer
end
Result = cat(3, C{:});
save('Output.mat', 'Result');
  3 件のコメント
khaled alsaih
khaled alsaih 2018 年 6 月 6 日
by the way the data is unit8
khaled alsaih
khaled alsaih 2018 年 6 月 6 日
thanks a lot for your help bro

サインインしてコメントする。

その他の回答 (1 件)

KSSV
KSSV 2018 年 6 月 5 日
A = rand(512,1024,128) ;
B = rand(668,512,64) ;
C = rand(512,512,49) ;
Ai = imresize(A,[512,512]) ;
Bi = imresize(B,[512,512]) ;
Ci = imresize(C,[512,512]) ;
iwant = cat(3,Ai,Bi,Ci) ;
  2 件のコメント
khaled alsaih
khaled alsaih 2018 年 6 月 5 日
No need to make rand I have the data already And I have many mat files so I want to make a for loop to read the mat files then resize them Then concat Thanks a lot for your answer
Jan
Jan 2018 年 6 月 5 日
KSSV used rand to produce some example data.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by