Loop that runs through the preprocessed image files and iterate

1 回表示 (過去 30 日間)
G. Nardi
G. Nardi 2018 年 12 月 11 日
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);
%average frame minus current
averagePixelValue = totalPixelValue / lastTenImage;
go through rows
for x= 1:1080
%go through columns
for y= 1:1920
%get a value of an image of a given pixel.
currentFramePixel = impixel(x,y);

回答 (0 件)

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by