Converting Structure into 3d Matrix

조회 수: 3 (최근 30일)
Afonso Espírito Santo
Afonso Espírito Santo 2021년 11월 24일
댓글: Afonso Espírito Santo 2021년 11월 27일
Hi,
I am trying to post-process matrix of frames I get from a camera. Each frame is outputted as a.mat file with a "Frame" variable that is a 512x640 double. I want to import all of these files for each frame, I have 2497 frames so 2497 files, and create a 3D matrix that is 512x640x2497 with all the frames. I currently import the frames but it creates a 1x2497 strucutre with each field being a 512x640 double. Is it possible to convert this structure to a 3D matrix or import the data straight into a 3D matrix?
Thank you
This is my code so far:
for k = 0:2497
filename = sprintf('Rec--000013_%d.mat', k);
%Checking File Exists
if isfile(filename)
all_frames(k+1) = load(filename,'Frame');
else
fprintf('File %s does not exist.\n', filename);
end
fprintf('Now Reading File : Rec--000013_%d.mat\n', k)
end

채택된 답변

Matt J
Matt J 2021년 11월 24일
Matrix=cat(3, all_frames.Frame);
However, you will need generous RAM. Your all_frames structure already consumes about 5 GB in double flating point, and this will consume another 5 GB.
  댓글 수: 3
Matt J
Matt J 2021년 11월 26일
Since you Accept-clicked the answer, I assume you figured it out?
Afonso Espírito Santo
Afonso Espírito Santo 2021년 11월 27일
Hi Matt,
The original issue was solved.However, I have not figured out how to answer the question I asked in the comment. Should I open a new questions for that specifically?
Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by