Yes this is for a class and I am trying to learn. I have preprocessed video and now I want to create a loop that will run through each of the image files. In each of these iterations I want to
a. Compare each of the pixel values (height by width) to the average value stored in the average matrix. If the absolute value of the difference is greater than some threshold (start with threshold = 20) set the value of that correspond pixel in the newImage to be white (intensity value 255). If it’s less than the threshold you will set the value of that corresponding pixel in the newImage to be black (intensity value 0). If the pixel value is white, it is a foreground pixel, if it’s set to black, it’s a background pixel.
b. Then update the average matrix by replacing the oldest image in the matrix with the current image.
What I have so far....
for imageNumber = 1 : mov.NumberOfFrames
img = read(mov,imageNumber);
averagePixelValue = totalPixelValue / lastTenImage;
go through rows
for x= 1:1080
for y= 1:1920
currentFramePixel = impixel(x,y);