필터 지우기
필터 지우기

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 CenterFile Exchange에서 Image 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