Condition on the last last frame of a video
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
sarah Abdellahi
le 12 Nov 2018
Réponse apportée : Guillaume
le 12 Nov 2018
Hello experts,
I extracted the frames of a video and are visible in the current folder (left column in matlab). I have 168 frames.
Before doing any analysis on the image, I want to put a condition on the last frame in the folder. The following code descirbes what I do.
RGB=imread('168.jpg');
I_gray= rgb2gray(RGB) ;
I_binrzd= imbinarize(I_gray,'global');
stats=regionprops('table',I_binrzd,'area');
C1=max(stats.area);
if C1>200
fprintf('SOFT');
end
Now I want Matlab to automatically imports the last frame and check the condition instead of me, saying 168! something like RGB=imread('end.jpg') !
Suggestions?
Thank you
0 commentaires
Réponse acceptée
Guillaume
le 12 Nov 2018
Well, you need to ask the filesystem for the list of files, extract the file numbers from that list then select the greatest one, so:
filelist = dir('*.jpg'); %get list of files
filenumber = arrayfun(@(file) sscanf(file.name, '%d', 1), filelist); %extract file number
[~, selectedindex] = max(filenumber); %select greatest number
RGB = imread(filelist(selectedindex).name);
%... rest of your code
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!