AIM: 1. Study of Video file handling.
2.
Implementing Color to Black and white video conversion.
THEORY:
1.
Study of Video file handling:
Video file reading in Matlab is
interesting process. So aim of this experiments is
1. How to read video file in Matlab?
2. How to play video files in Matlab?
1. Reading video file:
Syntax:
obj = mmreader(filename)
obj = mmreader(filename, 'P1', V1, 'P2', V2,...)
obj = mmreader(filename, 'P1', V1, 'P2', V2,...)
obj = mmreader(filename) constructs
a multimedia reader object, obj, that can read video
data from a multimedia file. filename is a string
specifying the name of a multimedia file. There are no restrictions on file
extensions. By default, the MATLAB software looks for the file filename on the
MATLAB path.
obj = mmreader(filename,
'P1', V1, 'P2', V2,...) constructs a multimedia reader
object, assigning values V1, V2, etc. to the respective specified properties
P1, P2, etc. If you specify an invalid property name or property value, MATLAB
throws an error and does not create the object.
2. Playing Video file:
Syntax:
Implay (filename)
Description:
implay(filename) opens the implay movie player,
displaying the content of the file specified by filename. The file can be
an Audio Video Interleaved (AVI) file. implay reads one frame at a
time, conserving memory during playback. implay does not play audio
tracks.
3. Checking size of Video:
Syntax:
[row,col,planes,frames]=size(video file name)
Video player in Matlab:
2.
Implementing Color to Black and white video conversion:
Frame
of the color video consist of three planes (red, green and blue). Our need is
to convert color frame to gray scale frame and recombine all converted frames
in order to get the final black and white video. Matlab contains one function
which converts color frame to black and white.
Black_and _white_frame = rgb2gray (Color_frame)
Our
aim is to apply this function to each and every color frame and after
converting recombine grayscale frames to get final Black and white video.
Program for Color to Black and White Video Conversion:
Program:
%
Converting video from Color to Black white
out=mmreader('news.avi');
var=read(out);
[r c p
f]=size(var);
implay(var)
for i=1:f
img=var(:,:,:,i);
img1=rgb2gray(img);
new(:,:,:,i)=img1;
end
implay(new)
|
Output:
Color Video Input:
Input Frame number 728
Input Frame number 440
Black
and White Video Output:
Output Frame number 728
Output Frame number 440

No comments:
Post a Comment