Artificial Intelligence and MatLab

Artificial Intelligence and MatLab


Matlab is an essential application that can be used in the analysis, statistics, simulation, etc in various sections of society. Mathworks developer team created the Matlab application in 1984. Cleve Moler is the chief person in that developer team. Matlab programmed by C programming language. In the early stages, researchers and engineers in control programming used Matlab but now many students, professors, industrial persons, developers, etc are using this precious application.

There are two methods which we can implement and get work by computer. The first one is the traditional way.

No alt text provided for this image

Obtaining the output while inserting data and programs into the computer is the first method. In here data can be image, voice, text, etc. Program is for taking the data and process in the computer for generating the output, For example, obtaining the output of 4 by addition of 2 to another two by the simple calculator.

The second way is the smart way. Actually is it a longer process than the previous initial stage? Yes. Because we have to use machine learning to train data and make a model/program.

No alt text provided for this image
No alt text provided for this image

In here, we simply try to teach machines to learn how to do stuff like us. That's the purpose of model creating. Remember the day first you try to ride a bicycle. Well, to almost all of us, on the first day we ended up with wounds because of the falls of the bicycle. Because our brain didn't experience those incidents before. By the time, the brain learns what is riding with experiences and at some point, we can ride a bicycle without falling. A similar thing is happening in the machine. We have to teach how to teach itself with model training.

In this article, we basically look at how to do face recognition which is a part of image processing. Well, ignore the phrase "image processing".In this face recognition, we simply focus to identify a face. Not more!Because this is the primary stage!.

How we can do it!

Here we are using an algorithm called the Viola-Jones face algorithm.

Well, let's just go to basics. What we have to do? We have to correctly identify a face. For a given input, determine whether it is a face or not. In order to do that model must understand the features of a face. The face consists of a mouth, nose, eyes, lips, etc. So, in order to teach them to the machine, we must first show a human picture and tell them that these are the features of the human face. Ok. Then what? how it gonna identify the picture. Now, the algorithm comes in handy. Photo comprised of pixels. If you look closer at the computer screen, depend on the resolution you can see a single dot. It is a pixel. So, these pixels created this photo and the algorithm tries to look at rectangular sections in the picture. The algorithm looks at many smaller subregions and tries to find a face by looking for specific features in each subregion. It needs to check many different positions and scales because an image can contain many faces of various sizes. In the initial stage, we are using the harr feature for object recognition. So, simply we are looking for darker places and lighter places in the human face. In order to look at which place is lighter or darker, we can sum up the pixel values of both regions and compare them. The Sum of pixels on the lighter side is more than the darker side. Actually, then we are using features which are called an edge, line, and four-sided features for recognition purposes.

No alt text provided for this image

Then, we have to find the value of each feature by substituting the sum of pixels in lighter from darker. Then we are creating a big rectangele that includes pixel values.

No alt text provided for this image
No alt text provided for this image

Then we can convert that into an integral image. You can learn how to do that by this link.

https://www.youtube.com/watch?v=uEJ71VlUmMQ

I am not going to go to that complexity since it can be boring. Since we have an integral image, AdaBoost can be used to check the performance of all classifiers that you supply to it. Evaluation of all subregions of all the images used for training is the next step. Strong responses can be generated in the classifier and it will be classified as positives. In other words, the classifier thinks it contains a human face. If subregions don't give a strong response, it thinks that it doesn’t contain a human face. So, they will be classified as negatives. Finally, a cascaded classifier came to the arena to quickly discard non-faces, and reduce time and space complexity.

In summary, it actually consists of four stages

  1. Haar Feature Selection
  2. Creating an Integral Image
  3. Adaboost Training
  4. Cascading Classifiers

Like that, after we create the model,maybe 1000,2000 images can be trained through this model and improve more.

As show below, you can see the Matlab code we should write for face detection by Viola-Jones face algorithm. If you have simple Matlab syntax knowledge you can understand most of the code.

No alt text provided for this image

At line 5, Fdetect represents cascade object detection. In line 11,you can see the bounding box.The step(Detector,I) returns Bounding Box value that contains [x,y,Height,Width] of the objects of interest.

No alt text provided for this image

Since this matlab application didnt train yet,following output can be expected.Human face and app face are both recorgnizing as faces.

No alt text provided for this image
No alt text provided for this image

So, I think you understood a little bit about Artificial intelligence and MatLab. Actually, this article represents the simple face detection by some algorithm. Don't worry! This is just a start! Long way to go folks! So, if you have any ideas, suggestions let me know! Stay Safe!


Madushan Ranasinghe

Software Engineer Deputed at Sysco LABS | BSc Eng.(Hons) Electrical And Information Engineering | AWS Certified Solutions Architect Associate

4 年

Love this

要查看或添加评论,请登录

社区洞察

其他会员也浏览了