Borrar filtros
Borrar filtros

How do i loop this fuction and each time use a different AVI for processing

1 visualización (últimos 30 días)
Hi, I made a Function that will get an AVI and remove the background by using Z-stack so the image is easier to track the moving objects. But i want to do this for a series of AVI files but i'm not sure where to start. I know i should use loop but i don't know how to input the location of the AVIs per loop. Basically i want the fuction to get say an AVI-1 and process it then process AVI-2, then AVI-3, etc. The Bold is the Function and the Italic is the description:
  • Vid1 = VideoReader('Moviessmall.avi') %# Allow MATLAB to recognize the file by using VideoReader
  • Vid1Frames = read(Vid1) %# RECOGNIZING the Frames in the movie
  • Vid2Frames = rgb2gray(Vid1Frames); %# Change the movie to a GRAY SCALE movie. limiting the movie to 3 arrays
  • Vid3Frames = Vid1Frames(:,:,1:450); %# Stacks Z-PROJECT
  • VidB = median(Vid3Frames, 3); %# Run a MEDIAN to get a background image
  • VidB2 = repmat(VidB, [1 1 450]); %# Because images need to be of the same FRAME number to Subtract a Frame duplication with repeat must be done
  • Vid2 = Vid3Frames-VidB2; %# The SUBTRACTION to get an array
  • Vid2 = Vid3Frames-VidB2; %# The SUBTRACTION to get an array
Thank you, Minh

Respuesta aceptada

Matt Fig
Matt Fig el 28 de Mzo. de 2011
You could put the names of the files in a cell array then loop over the array.
% This array stores the names of the files.
C = {'Moviessmall.avi';'Moviessmall_2.avi';'Moviessmall3.avi'};
for ii = 1:length(C)
Vid1 = VideoReader(C{ii})
% The rest of your code... If you need to store data, use a cell.
end

Más respuestas (0)

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by