Generating video signal

by

 

Generating video signal from frames. Both sampled & without sampled signal generated

VideoSignalGeneration.m
clc;
clear all;
close all;
r=[];
cum=[];


%reading i/p video...............................
vehObj=mmreader('far.avi');
nFrames =vehObj.NumberOfFrames;
vidHeight = vehObj.Height;
vidWidth = vehObj.Width;


% Preallocate movie structure........................
mov(1:nFrames) = ...
    struct('cdata', zeros(vidHeight, vidWidth, 3, 'uint8'),...
           'colormap', []);
 
% Read one frame at a time...........................
%For simplicity taking only first 10 frames of a video
for k = 1 : 10
b = read(vehObj, k);
c=rgb2gray(b);

kp=c(1:1:end,1:1:end);

%sampling by 50............................
wp=c(1:50:end,1:50:end);

len_wp=size(wp,1)*size(wp,2);
wp1=wp(1:len_wp);

len_kp=size(kp,1)*size(kp,2);
kp1=kp(1:len_kp);

%cumulating signals...........................
r=[r;wp1];
cum=[cum;kp1];

end;


%generating combined video signal sampled by 50...............................
d=r';
p=k*len_wp;
r1=d(1:p);

figure(1);
t2=[0:1:length(r1)-1];
plot(t2,r1);
xlabel('frames');
ylabel('intensity');
title('video signal with N-frames sampled by a factor 50');
set(gca,'XTick',1:len_wp:p);
set(gca,'XTickLabel',{'frame'}); % 'frame' indicates starting of a frame

%generating original video signal

dd=cum';
p=k*len_kp;
r1=dd(1:p);

figure(2);
t0=[0:1:length(r1)-1];
plot(t0,r1);
xlabel('frames');
ylabel('intensity');
title('video signal with N-frames');
set(gca,'XTick',1:len_kp:p);
set(gca,'XTickLabel',{'frame'});  % 'frame' indicates starting of a frame

Contact us