Borrar filtros
Borrar filtros

Condition on the last last frame of a video

3 visualizaciones (últimos 30 días)
sarah Abdellahi
sarah Abdellahi el 12 de Nov. de 2018
Respondida: Guillaume el 12 de Nov. de 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

Respuesta aceptada

Guillaume
Guillaume el 12 de Nov. de 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

Más respuestas (0)

Categorías

Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by