trim a plot and modify mesh

11 Ansichten (letzte 30 Tage)
Federico Paolucci
Federico Paolucci am 12 Dez. 2022
Bearbeitet: Abhinaya Kennedy am 22 Aug. 2024
hi, I would like some advice on how to do this job: I have the plot obtained in matlab available. this plot presents several frames, one after the other, like film. each frame has dimensions of 0.025x0.1.
I have to do two things:
  • cut each frame separating it from the others
  • and then I have to convert the above dimensions to 0.1x0.1. for this activity I thought of using the griddata function, which allows me to switch from initial to final coordinates.
Thanks in advance for the advice

Antworten (1)

Abhinaya Kennedy
Abhinaya Kennedy am 22 Aug. 2024
Bearbeitet: Abhinaya Kennedy am 22 Aug. 2024
Step 1: Extract Frames
Assuming img is your data matrix and you know the dimensions and positions of each frame:
% Define frame dimensions and number of frames
frameHeight = 0.025; % Original height
frameWidth = 0.1; % Original width
numFrames = 10; % Example number of frames
% Preallocate cell array for frames
frameData = cell(1, numFrames);
% Extract each frame
for i = 1:numFrames
% Calculate indices for each frame (replace with actual logic)
rowStart = ...; % Define based on frame position
rowEnd = rowStart + frameHeight - 1;
colStart = ...;
colEnd = colStart + frameWidth - 1;
% Extract the frame
frameData{i} = img(rowStart:rowEnd, colStart:colEnd);
end
This will adjust rowStart, rowEnd, colStart, and colEnd based on the actual positions of your frames within the data.
Step 2: Resize Frames
Using imresize (https://www.mathworks.com/help/matlab/ref/imresize.html) for simplicity, especially if working with image data:
% Define new dimensions
newHeight = 0.1; % New height
newWidth = 0.1; % New width
% Resize each frame
resizedFrames = cell(1, numFrames);
for i = 1:numFrames
resizedFrames{i} = imresize(frameData{i}, [newHeight, newWidth]);
end

Kategorien

Mehr zu Install Products finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by