Monday 1 June 2015

OpenCv Vs Matlab : Which is best for image processing?

Comparison of the features of various image-processing softwares/tools available:

Image Processing means analyzing and processing image data in order to make it suitable for computer vision or in order to represent it effectively to the humans. For e.g manipulating image data in order to change the brightness of an image or to remove noise from an image so that it can be effectively represented to the humans or can be used for the further computer vision applications.

Computer vision deals with acquiring, analyzing, processing and understanding the digital images and making decision based on that information. In short computer vision is about making the computer see the images as we humans do.

Thus various steps which are involved are:
1 .     Image Acquisition.
2 .     Image Analysation
3 .     Image Manipulation
4 .     Obtaining relevant data
5 .     Decision making
   
 Coming to the question which tool or software should we use for image processing?
                               Matlab / Scilab/ OpenCv/ Aforge.

 OpenCV stands for Open Source Computer Vision. It contains a library of programming functions for real time computer vision applications.Originally developed by Intel and now supported by Willow Garage.

MATLAB, short for MATrix LABoratory is a high level language and programming package specifically designed for quick and easy scientific calculations and I/O.

Scilab is a freely distributed open source scientific software package, released as open source under the CeCILL license (GPL compatible) firstly developed by researchers from INRIA and ENPC, and now by the Scilab Consortium. It is similar to that of Matlab.

AForge.NET is an open source C# framework designed for developers and researchers in the fields of Computer Vision and Artificial Intelligence - image processing, neural networks, genetic algorithms, fuzzy logic, machine learning, robotics, etc.

Out of these OpenCv and Matlab are the most widely used tools for image processing.

 Advantages of OpenCv over Matlab are:
1.     Cost:
OpenCv is OpenSource (released under BSD license) thus it doesn’t require any license to buy it.
While Matlab (commercial single user) costs around USD $2150.
2.     Speed:
OpenCv is built on C/C++
While matlab is built on Java which in turn is built on C.
Thus while compiling the code written in Matlab , your compter is busy trying to interpret the code of Matlab then turn it into Java and then to C/C++.
Hence programs written in OpenCv tends to run faster than that compared to similar program written in Matlab.

In Computer vision we are noramally dealing with real time applications, speed is a major concern in such cases.
3.     Resources needed:
Due to the high level nature of Matlab it occupies a lot of your computer resources(about 1 GB of RAM) as compared to that of OpenCv(about 70MB of RAM) for real time computer vision applications.
4.   Portablility:
Almost any device which can run C can run OpenCv programs.

Inspite of all these amazing features OpenCv loses on Matalb on the below mentioned feature:

1. Ease of Access:
 Matlab is a pretty high-level scripting language, meaning that you don’t have to worry about libraries, declaring variables, memory management or other lower-level programming issues. As such, it can be very easy to throw together some code to prototype your image processing idea. 

Say for example I want to read in an image from file and display it. In Matlab, you could write this as:
  1. I = imread('someImage.jpg');
  2. imshow(I);

This seems to be quite easy.The same thing when it is done with OpenCv would look like this:



  


















  #include "cv.h"              //main OpenCV header
  #include "highgui.h"          //GUI header
    int main()
{
 // declare a new IplImage pointer and load the image
  IplImage* myimage;     
  myimage = cvLoadImage("someImage.jpg",1); 

 //create a new window and display the image
 cvNamedWindow("Arjun", 1);
 cvShowImage("Arjun", myimage);

 //wait for key to close the window
 cvWaitKey(0);
 cvDestroyWindow("Arjun");
 return 0;
 }

2. Memory Management:
   OpenCV is based on C. As such, every time you allocate a chunk of memory you will have to release it again. If you have a loop in your code where you allocate a chunk of memory in that loop and forget release it afterwards, you will get what is called a “leak”. This is where the program will use a growing amount of memory until it crashes from no remaining memory. Due to the high-level nature of Matlab, it is “smart” enough to automatically allocate and release memory in the background.










No comments:

Post a Comment