Wednesday, July 13, 2016

reading-frames-from-video

reading-frames-from-video and store in cell arry

By studying this, one can understand the logic of reading frames from video and store them into cell array in matlab. I tested this program by using MATLAB 2012b. To run the following code, download the video using this link : download

%Matlab program to read frames from video and store all frames into a cell
%array.
% input -  path of the video
% output - cell array contains all frames in video


clear all; clc;
input = 'E:/videos/crosscut.avi';

%create object of videoReader
vid = VideoReader(input);

%find number of frames in video
no_of_frames = vid.NumberOfFrames;
fprintf('number of frames in video : %d \n', no_of_frames);

%create cell array with size of 'no_of_frames'
output = cell([1,no_of_frames]);

%read frame by frame and store it into a cell array 'output'
for i=1:no_of_frames
    frame = read(vid,i);
    output{i} = frame;
end

%convert all frames in cell array 'output' to gray color
for i=1:no_of_frames
    output{i} = rgb2gray(output{i});
end

%displaying all frames in cell arry 'output'
for i=1:6
    imshow(output{i});
    pause(0.1);
end


Output :

   number of frames in video : 100 

Popular Articles:

1. matlab-cropping-binary-image-algorithm

Objective of the Program: Program takes a black and white image as input. It removes the black portion and gives the white portion of the image.

2. Working-with-ROI-of-image-using-Matlab

Objective of the Program:The part of the image, on which you have interest to work out, is called Region of Interest (ROI). In another words, selected subset of image is called ROI. In some contexts, you want to apply operations on ROI of image rather than the entire image. To achieve this, generally people extract the ROI from the image, store it in another variable and then apply operations on ROI. If you want to apply your operations on ROI without extracting from the image, it is bit difficult. This article will explain the performing the operations on ROI without extracting from the image. In this context, the ROI part of image is affected rather than the entire image.

3. Insertion Sort Matlab Program:

Insertion sort is very simple algorithm and easy to implement. It works well when the input size is less. If the input size is more, insertion sort is not efficient(quick sort or merge sort works good when the input size is big).

2 comments:

  1. Thanks a lot. Please how do i determine position of a movie object in a video, having extracted the frames. And how do i make a plot of the position against time?

    ReplyDelete
  2. Thanks a lot. Please how do i determine position of a moving object in a video, having extracted the frames. And how do i make a plot of the position against time?

    ReplyDelete

Python-environment-for-deep-learning-in-windows

Python is increasingly becoming a popular programming language for machine learning and deep learning. If you want to use python for train...