2-D frame correlation
显示 更早的评论
clear
camera is that reports a video frame (30 frames/second and maximum 300 frames) at instant t
represented by the vector F(x, y, t) = [FR(x, y, t) FG(x, y, t) FB(x, y, t)],
where x and y are the coordinates of the pixel in
the frame, while FR, FG and FB represent the level of RGB
components at this pixel.
The 2-D correlation between the current frame and a previous frame at instant to can be dened
by the vector C as follows:
C=[Cr;Cg;Cb]=[corr(Fr(x,y,t),Fr(x,y,t0));corr(Fg(x,y,t),Fg(x,y,t0)) ;corr(Fb(x,y,t) ;Fb(x,y,t0))]
How can I represent The 2-D correlation between the current frame and a previous frame at instant t0 (modify this below code) ?
all
close all
clc
%step_1
%%Extract frames from video
%% source https://youtu.be/GF6guS2DIWY
a=VideoReader('camera.mp4');
% for img=1:a.NumberOfFrames;
for img=1:300;
filename=strcat('frame',num2str(img),'.jpg');
b=read(a,img);
imwrite(b,filename);
end
%step_2
%%%read the download frames from video%%%%
%quantization each R,G,B equivalently to 8*8*8
NumberOfLevelsForR=8;
NumberOfLevelsForG=8;
NumberOfLevelsForB=8;
N=NumberOfLevelsForR*NumberOfLevelsForG*NumberOfLevelsForB;
%Enter name of folder from where you want to upload pictures with full path
srcFile=dir('C:\Users\M7MD\Desktop\EXTVIDEO\*.jpg');
for i=1:length(srcFile)
filename=strcat('C:\Users\M7MD\Desktop\ExtractFramesFromVideo\',srcFile(i).name);
I=imread(filename);
%split image into R,G & B
R=double(I(:,:,1));
G=double(I(:,:,2));
B=double(I(:,:,3));
[x,y,z]=size(I);
%create final histogram matrix of size 8*8*8
hist=zeros(NumberOfLevelsForR, NumberOfLevelsForG, NumberOfLevelsForB);
%create col vector of indicies for later refernce
rows=x;cols=y;
index=zeros(rows*cols, 3);
%%%(Maximum Level D 255) for each of the R, G and B components
MR=ceil(NumberOfLevelsForR.*R/255);
MG=ceil(NumberOfLevelsForG.*G/255);
MB=ceil(NumberOfLevelsForB.*B/255);
%2-D frame autocorrelation between current and previous
if i>1
corrR(i)=corr2(MR(i),MR(i-1));
corrG(i)=corr2(MG(i),MG(i-1));
corrB(i)=corr2(MB(i),MB(i-1));
end
C=[corrR;corrG;corrB];
end
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!