フィルターのクリア

Condition on the last last frame of a video

3 ビュー (過去 30 日間)
sarah Abdellahi
sarah Abdellahi 2018 年 11 月 12 日
回答済み: Guillaume 2018 年 11 月 12 日
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

採用された回答

Guillaume
Guillaume 2018 年 11 月 12 日
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 件)

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by