How to accurately process multiple frames in a video file using for and while loops

21 views (last 30 days)
I am interested in tracking a white horizontal line that slowly moves up a semicircle (bottom to top) over time. In my code: I import my video > read the frames > crop them and place them into a cell that contains each frame of the freezing droplet. I then select the same column in each frame and wish to analyze the movement of the freezing droplet over time (or frames).
The problem I am having is my code doesn't read all of the rows in each frame completely. It looks like it stops at the last white pixel. I know this because the cell I am building through my for loop (variable A) has different sized matrices in them. Some matrices have more amounts of rows than others. While what I want is for all matrices to have 230 rows (the max height of the droplet) so that I know the exact location of the freezing line in that frame.
I have attached the variable (Crop1) that contains all 700 of the frames that I want to be observing. The following is my code:
nstart = 260;
nend = 700;
load('Crop1.mat')
middle1 = 243;
for t = nstart:nend % nstart and nend are the first and last frames to be observed respectively
i = 1;
while i<230 % 230 is the max height of the droplet
if Crop1{t}(i,middle1) == 1 %Crop1 is a cell made of up of video frames
A{t}(i,1) = Crop1{t}(i,middle1);
%i = 230;
end
i = i + 1;
end
I{t} = [A{t},;];
end
The end goal of this is to obtain a cell that consists of 700 (which is the amount of frames) matrices. These matrices need to have only 1 column and 230 rows. Then, I will be able to pinpoint the location of the freezing line in each matrix and plot it against time.

Accepted Answer

Image Analyst
Image Analyst on 18 Feb 2018
  7 Comments
user
user on 20 Feb 2018
Yes, your solution works quite nicely! I think at this point I just have to work on a better method of processing my image, thanks!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by