I'm new to Matlab processing, and I would like to read and process a large video (more than 200k frames) inside a "for loop" (or without it). In particular, i would like to:
- read the video with VideoReader,
- subdivide the video into n-epoch of 1000 frames each ones,
- process every epoch of 1000 frames, reading: the first frame of the epoch, skip two, read the frame, skip two, and so on (for example i=1:3:nFrames),
- considering every epoch i need to convert every "RGB-frame" read into im2bw
- after the conversion i need to make the "corr2" 2D cross-correlation considering the first video frame ("mov(1,1).cdata") and every frames read within the epoch,
- store the result from "corr2" into a vector.
In summary, this is what i need to do. Thank You all
This is what I have so far, about "corr2":
for frame_ind = 1 : nFrames
mov(frame_ind).cdata = im2bw(rgb2gray(read(xyloObj,frame_ind)),0.20);
end
%% Corr2 to compare BW video frames
for frame_ind2 = 1:(frame_ind-1)
R(frame_ind2)=corr2(mov(1,frame_ind2).cdata,mov(1,frame_ind2+1).cdata);
end
TF= isnan(R);
g=sum(TF);
f=(length(R)-g);
if (g~=(length(R)))
%%If Part has errors
disp('"Part_1" has video interferences/noise/problems, see "Testresult.txt" for more information.');
else
%%If Part has not errors
displ=strcat('"Part_1" has not video interferences/noise/problems.');
end
Here is my version:
The cell array
corr_coef
contains the correlation coefficients in each epoch, where each cell contains a vectorcorr_coef{e}(i)
ofcorr2
between the first frame and the (i+1)-th frame.Note that if one of the frames is constant (all black for example), the 2D correlation coefficient is simply NaN (zero divided by zero in the formula)