Wednesday, November 9, 2016

Convert-Video-to-Sequence-of-Frames

Convert-Video-to-Sequence-of-Frames

By studying this article, one can understand that how to read frame by frame from video using MATLAB.

Convert-Video-to-Sequence-of-Frames


% Program to read frames from a given video 

clear all; clc;
inputvideo = VideoReader('E:/videos/aa.mp4');

%informatin of video 
disp(inputvideo);

%number of frames in video 
no_of_frames = inputvideo.NumberOfFrames; 

%read and write operations frame by frame 
for i = 1 : no_of_frames
    
    frame = read(inputvideo,i);
    frame = rgb2gray(frame);
    strr = 'E:/videos/images/';
    str = int2str(i);
    filename = strcat(strr,'frame',str,'.jpg');
    imwrite(frame,filename,'BitDepth',8);
end


The output of the above code is shown below:

Summary of Multimedia Reader Object for 'aa.mp4'.

  Video Parameters:  29.93 frames per second, RGB24 1920x1080.
                     446 total video frames available.




Follow us on Facebook :



Tuesday, July 26, 2016

life-of-engineering-student

Foreword (by Developer of this blog) : I have been writing the articles to motivate young students for a couple of years. It is my passion to write articles related to inspirational and technical. One day, I asked my student to write an article about Life of an Engineering student in both aspects (academic and professional). As a result, she has written this wonderful article. I am thankful for her contribution to motivate the engineering buddies by this article. I hope that this article will give valuable suggestions to little buddies to get success in their life in both aspects(academic and professional).

Life of Engineering Student

I am writing this article to inspire and motivate the little engineering buddies. It depicts my insight about how I have completed the Engineering Graduation and entered into software company. It reveals facts behind the success story of a graduate student academically and professionally.
Lateefa B.Tech
Program Analyst
Cognizant Technology Solutions
Kochi, Kerala

So here is something that I always wrote of in my diary but now when I am asked to write about it to reach out to my juniors, I am falling short of words. College life is not as it is shown in movies there are perks to it as well pitfalls. On entering college each student finds a new freedom, one which they never had before. This blinds them in a way that most of them don’t realize the importance of being in one. College life has more to it than just fun and I know most would disagree. But truly there is a treasure of knowledge which most of us forget to cherish.

It’s the place where new ideas pop up, zeal to learn awaken our minds. College was where I found my apple of wisdom, I have learnt many lessons and here are a few interesting one for you guys. College has taught me the importance of knowledge and when I say that I mean not knowing but understanding what you learn. There will be many subjects and many extra-curricular activities but there should always be one particular thing that fascinates you the most. If you don’t have one its fine, you can end up being the jack of all trades. But at the end what matters is what knowledge you have gained and what have you taken from the 50 minutes lecture. Once a wise men (profoundly one of my dedicated lecturer in college) said “That no matter how bad a lecture is there will always be at least one new thing you could learn from it”.

When he told that to all my fellow classmates along with me none of us understood the depth of what it meant. But we later realized what he meant was there is always something to learn from a bad book or a bad lecture. In college you get the time to explore new stuff (no matter to which subject it be related to) and you get a practical experience of what you have learnt but this comes only when you put efforts. Hard work always pays of it has paid off for me. I was an average student in college, but enthusiastic enough to question and speak out what I felt and what concerned me it may be regarding subject or the way it was thought. You could only be confident later in important situations in life if you speak out your doubts and thoughts. College provide many opportunities for this. So be always enthusiastic to learn new things. College is the best place to get good genuine friends.

The first year of college is all basics like starters in your meal. Make sure you get your basics right because they are the foundation of what you are going to learn in the next three years of engineering life. Fall in love with coding if you are Computer Science student and non CS folks can also do it because coding is something that fascinates all. I still remember how happy I felt when I executes my first C program. The simple sentence “Hello world” displayed on the screen and made my day since then I never turned back. The more you learn the more excited it gets. It builds a hunger for coding. The happiness of finding a syntactical error that was stopping the entire code from being executed or the happiness in getting a bug fixed or executing your own piece of code (small or big) gives more pleasure. That’s what college gave me a new pleasure. The second important thing that each student should do is: true to yourself, study for yourself, do whatever you do, knowing how it would impact your future. Would it make a difference in life and if yes then think in a good way or in a bad way?

The ultimate goal is to get a job in campus selections for those who want to get into Software Industry. All the tests for 6 or 7 subjects, the labs, the practical exams, the mid exams, the scores, the late night studies and the external exams etc..... all for what? To secure a job in on campus placements, and this goal is realized by most of the students only at the end of third year of college. Then starts the cycle of aptitude learning, reasoning and English (RSWL) skills. It’s the first step towards clearing the initial screening or written exam. After you clear this, you will have to go through technical and HR round. For few MNCs, you will also have other rounds like group discussions, stress interviews etc.

A good preparation is required for this. The college arranges third party trainers to bloom the student in all these aspects including personality development. One should simply learn and practice what has been taught to them and coming to English, one can never master a language in a day, so the best way is to try to speak English with friends while in college, at least during English class. And reading books, no matter to which genre it belongs to, also improves the language skills.

And moving on to the actual experience in corporate life. At first all will be new, you will definitely feel as an outcast but trust me that’s how everyone feels when they are new. so, you are not an exception. You might not know what to do in the beginning and might end up making blunders in the project. You never take such things to heart. Though it would make you feel as a complete idiot, but it will pass. Stop blaming yourself and then one day you will laugh on these incidents. That will always remember that you couldn’t be a genius at the first day of your work.

“Remember It’s not how you fall that matters, what matters is how well you brush up yourself and get back up!!”



See also:
1. Article-on-research-for-phd-scholars
This article will be helpful to the students who want to join PhD and already joined PhD students.

Follow us on Facebook :



dealing-with-matrices-matlab

dealing-with-matrices-matlab

By reading this article, one can easily understand the working of Matrices in Matlab. In many cases,especially in the case of research, we need to perform operations on matrices. Matlab provides very simple commands (statements) for performing operations on matrices. This article explains different operations on matrices. In addition, it explains different operations on 3D arrays.

In Image Processing, an image can be considered as a matrix. The operations that can be performed on matrices, can also be applicable for images. Here, we explain the different matrix operations in image processing with neat diagrams.

creating 1D array

By simply assigning some values separated by commas within the square brackets to a variable, say 'a', 'a' is called a vector. Values in vector can be accessed by a(i). i varies from 1 to length of vector. Example is shown below.

creating 2D array (Matrix)

By simply assigning some values separated by commas and semicolons within the square brackets to a variable, say 'a', 'a' is called a Matrix. Values in Matrix can be accessed by a(i,j). i, j refers rows and columns of matrix. Example is shown below.
Follow us on Facebook :



Wednesday, July 20, 2016

image-gradients

Image Gradients

By studying this article, one can understand the meaning of image gradient and role of gradient values in edge detection. The gradient of pixel represents the change of the intensity values in both X and Y directions.

Gradient of image in X – Direction

  • The gradient of image in X-direction is calculated by computing change of each pixel with respect to X-direction.
  • Change of each pixel in X- direction is calculated as follows
    P(x, y) = P(x, y+1) – P(x, y-1) (right pixel – left pixel)
% Matlab program to find X-gradient image for the given image
clear all; clc;

%read a color image and convert it to gray
img = imread('E:images/face.jpg');
img = rgb2gray(img);
 
%find the size of image
[rows,cols] = size(img);
 
%converting image into double for performing operations
img=double(img);
 
%initialization xgradient matrix 'xgrad' with image 'img'
xgrad=img;
 
%calculating gradient image in X-direction
for i=1:rows
    for j=2:cols-1
        xgrad(i,j) = abs(img(i,j+1) - img(i,j-1));  
       
    end
end
 
 
figure, imshow(uint8(img)),title('given image');
figure, imshow(uint8(xgrad+22)), title('X-gradient image');

The output of the above code is shown below:

Gradient of image in Y – Direction

  • The gradient of image in Y-direction is calculated by computing change of each pixel with respect to Y-direction.
  • Change of each pixel in Y-direction is calculated as follows
    P(x, y) = P(x+1, y) – P(x-1, y) (upper pixel – lower pixel)
% Matlab program to find Y-gradient image for the given image
clear all; clc;

%read a color image and convert it to gray
img = imread('E:images/face.jpg');
img = rgb2gray(img);
 
%find the size of image
[rows,cols] = size(img);
 
%converting image into double for performing operations
img=double(img);
 
%initialization ygradient matrix 'ygrad' with image 'img'
ygrad=img;
 
%calculating gradient image in X-direction
for i=2:rows-1
    for j=1:cols
        ygrad(i,j) = abs(img(i+1,j) - img(i-1,j));  
       
    end
end
 
 
figure, imshow(uint8(img)),title('given image');
figure, imshow(uint8(ygrad+22)), title('Y-gradient image');

The output of the above code is shown below:

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).

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).

Tuesday, July 12, 2016

Insertion-sort

Insertion Sort Matlab Program

By studying this, one can understand the logic of insertion sort. 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).

% Program for Insertion sort 
% Author : M Naveenkumar , Research Scholar , NIT Trichy, Tamilnadu, India
% n = input size (array size)

clear all; clc;
n = input('Enter n value:');

% create an array (a) with size 'n' and filled with zeros
a(1,n)=0;

% reading 'n' values to array (a)
for i=1:n
    string = 'value:';
    a(1,i) = input(string);
end

disp ('_______________________________________________________________');

for j=2:n
    key = a(1,j);
    
    % insert 'key' into already sorted array a[1.... j-1]
    i = j-1;
    while (i>0 && a(1,i)> key) 
        a(1,i+1) = a(i);
        i = i-1;
    end 
    a(1,i+1) = key;
    
    disp ('.................................................');
    fprintf('At j =%d:\n',j);
    disp(a);
end

disp ('_______________________________________________________________');
disp('sorted elements:');
disp(a);

Output :


Enter n value:6
value:2
value:1
value:9
value:5
value:7
value:8
_______________________________________________________________
.................................................
At j =2:
     1     2     9     5     7     8

.................................................
At j =3:
     1     2     9     5     7     8

.................................................
At j =4:
     1     2     5     9     7     8

.................................................
At j =5:
     1     2     5     7     9     8

.................................................
At j =6:
     1     2     5     7     8     9

_______________________________________________________________
sorted elements:
     1     2     5     7     8     9


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.

Thursday, April 7, 2016

Attaching-Two-Images-side-by-side-Matlab-Program

Attaching Two Images side by side Matlab Program

By studying this article, one can understand the logic of attaching two images side by side by using Matlab. This logic is not only applicable for gray scale images but also for color images without converting them into gray scale. Matlab is very useful and easy tool for image processing. Most of the researchers use Matlab for their research.

Method 1: (using black border at the bottom) Among two images, the less height of the image is found and its height is increased by padding zeros so that the heights of two images are equal. Hence the black border is added at the bottom of the less height image.

% read images (two)
    image1 =  imread('E:/images/image1.jpg');
    image2 =  imread('E:/images/image2.jpg');

% find the less height image(row size is less) and increase the height by filling zeros
    rows1 = size(image1,1);
    rows2 = size(image2,1);
    if (rows1 < rows2)
        image1(rows2,1) = 0;
    else
        image2(rows1,1) = 0;
    end

% Now append both images side-by-side.
    image = [image1 image2];
    imshow(image);

Input: (Two images)
image1.jpg image2.jpg
Output: (after Attaching images)

Method 2: (without using black border at the bottom)

% read images(two)
    image1 =  imread('E:/images/image1.jpg');
    image2 =  imread('E:/images/image2.jpg');
    
% find the less height image(row size is less) and increase the height by
% using imresize function
    rows1 = size(image1,1);
    rows2 = size(image2,1);

    if (rows1 < rows2)
        image1= imresize(image1,[rows2,size(image1,2)]);
    else
        image2= imresize(image2,[rows1,size(image2,2)]);
    end
% Now append both images side-by-side.
    image = [image1 image2];
    imshow(image);

Input: (Two images) Same as Two images image1.jpg, image2.jpg Output: (after Attaching images)



See also:

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.

Wednesday, March 30, 2016

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

Working with ROI of image using Matlab

M Saravana Mathan MCA
Project Associate
NIT Trichy

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.

I am writing this article to 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.

For example, you want to apply edge detection algorithm on the half of image (example: top of image), study the following example. Let consider the image as shown below.

Here ROI = "Half (Top) of the Image"

% read input image
img=imread('E:/images/input.jpg');

% convert color to gray image if input is color image
img=rgb2gray(img);
subplot(1,3,1);
imshow(img), title('Input image');

% calculating size of the image
[rows,cols]=size(img);
rows = rows/2;

% Apply Canny edge operation
edgeimg=edge(img(1:rows,1:cols),'Canny');
subplot(1,3,2);
imshow(edgeimg), title('Canny operation on Extracted ROI');

% calculating size of the ROI
[row,col]= size(edgeimg);

% edgeimg is in logical values (0,1). converting edgeimg into grayimage
edgeimg=uint8(edgeimg);
for i= 1:row 
     for j=1:col
         if(edgeimg(i,j)==1)
             edgeimg(i,j)=255;
         end
     end
end

% substituting Extracted ROI in Input image
img(1:rows,1:cols)=edgeimg;

subplot(1,3,3);
imshow(img), title('Input Image after substituing ROI');

output:




See also:

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.

Tuesday, February 23, 2016

Matlab-Cropping-binary-image-algorithm-and-program

Matlab

Program for Cropping Binary Image : Matlab Code

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.

Input: Gray or binary image (for example consider the image below)

           

Output: Gray or binary image (as below)

                      

MATLAB Code:


% read the input binary image 

img = imread('path of image');

% calculating size of the image 

[row col] = size(img);

% removing black portion on top side of the image 
  for i = 1:row
    if sum(img(i,:)) > 0
        top = i;
        break
    end
  end

% removing black portion on bottom side of the image 
  for i = row:(-1):1
    if sum(img(i,:)) > 0
        bottom = i;
        break
    end
  end

% removing black portion on left side of the image 
  for i = 1:col
    if sum(img(:,i)) > 0
        left = i;
        break
    end
  end

% removing black portion on right side of the image 
  for i = col:(-1):1
    if sum(img(:,i)) > 0
        right = i;
        break
    end
  end

% output image  
 output = img(top:bottom, left:right);

 imshow(output);



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.

Tuesday, February 16, 2016

Article-on-Research-for-PhD-Scholars

Article on Research for PhD scholars

We are writing this article to motivate research scholars with our little research experience. We hope this article will be helpful to the students who want to join PhD and already joined PhD students.



What is PhD?

  • According to Prakash Iyer, PHD stands for Passion, Hunger and Discipline. He says that in order to be successful in life, one needs to be Passionate about what one wants, have a Hunger to work for it and the Discipline to keep up the work even in the face of adversity.
  • Every one needs PHD to get success in his/her life. (here PHd means Passion, Hunger and Discipline but not a qualification degree i.e Doctorate of Philosophy)
  • When we observe the great persons in the world, all have PHD(Passion, Hunger, Discipline) but not have PhD (Doctorate of Philosophy).
  • There are many evidences to show that winning and being successful in life has little to do with academic qualifications.
    Passion :
    • Do you enjoy what you do? Do you love your work?
    • Passion makes you get out of your bed early morning and get to work to achieve your goals. Not because you have to, but because you love to
    • Passion makes you enjoy the every moment even you are working a long hours for a day. Remember Great things are not achieved through better resources but with passion.
    • Martin Luther King once said: "If a man is called to be a street sweeper, he should sweep streets just as Michelangelo painted, or Beethoven composed music, or Shakespeare wrote poetry. He should sweep streets so well that all the hosts of heaven and earth will pause to say, here lived a great street sweeper who did his job well."
    • Conclusion : It is important to love what you are doing
    Hunger :
    • Are you really hungry for getting success?
    • we are explaining the need for hunger with a little story:
    • story : one day a young man went to Socrates and said he wanted to get wisdom. "Come with me," said Socrates and took him along to a river. Without any warning, Socrates pushed the man's head under water and held it there. The man did not know what was happening. He struggled for air. He moved his head, flailed his hands desperately seeking to get his head above water for some air. Socrates finally let go and asked him, "What did you want when your head was under water?" "I wanted air," said the man. "Right," said Socrates, "When you want wisdom as badly as you wanted the air -- you will get it!"
    • Conclusion : Passion with hunger is needed to get success in life. (only passion is not enough)
    Discipline :
    • Once you have the passion with hunger, you can achieve success in your life. But to keep on doing right things, time after time after time, one need discipline.
    • Success demands discipline. Commit yourself to become a PhD. A Passionate, Hungry, Disciplined person. Success always calls you.

Conclusion : We are Concluding the article by saying that "A person who want to get (degree) Ph.D (Doctorate of Philosophy) needs PHD (Passion,Hunger and Discipline)".


Follow us on Facebook :



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...