for loop over video data
Show older comments
Hi guys,
I want to extract data from a video, which is saved as a 4d Array. My plan is to use a for loop to extract data from the first 30x30 pixels of 50 frames and process these. After that I want to do the same with the next 30x30 pixels.
Right now I have this, but it is not working as I thought it would
for i = 1:50
for r = 1:29:size(data,2)
for c = 1:29:size(data,3)
if c+29 <= 960 && r+29 <= 540
red = mean(data(i,r:r+29,c:c+29,1),"all");
red(red==0) = [];
green = mean(data(i,r:r+29,c:c+29,2), 'all');
green(red==0) = [];
blue = mean(data(i,r:r+29,c:c+29,3), 'all');
blue(red==0) = [];
%%% Processing
end
end
end
end
Thank you in advance :)
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!