How can I see and modify frames in a filename.mat?

1 visualización (últimos 30 días)
Davide Antonini
Davide Antonini el 9 de Mayo de 2022
Editada: Jan el 9 de Mayo de 2022
Hi, I need to see and modify the single frames of a video in .mat, but i don't know how to do that. I have
tvec: [40.0177 40.0578 40.0980 40.1381 … ]
Video: [623×1152×912×3 uint8]
Can someone help me? thanks

Respuestas (1)

Jan
Jan el 9 de Mayo de 2022
Editada: Jan el 9 de Mayo de 2022
I assume, that ypu want to show e.g. the frame corresponding to a certain value of tvec.
Remember, that comparisons of floating point values are fragile (not only in Matlab, but in all programming languages. So determine the index at first with care:
% tvec: [40.0177 40.0578 40.0980 40.1381 … ]
% Video: [623×1152×912×3 uint8]
sizeVideo = size(Video);
wanted_t = 40.0980;
[~, index] = min(abs(tvec - wanted_t)); % Consider rounding
Frame = Video(:, :, index, :);
Frame = reshape(Frame, sizeVideo([1,2,4]));
This RGB array can be displayed by the image command.
How you can modify it depends on what you want to do. This cannot be answered in general.
The reinserting is easy again:
Video(:, :, index, :) = Frame; % Reshaped implicitly

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by