4.3 | 101 ratings Rate this file 301 Downloads (last 30 days) File Size: 202 KB File ID: #11073 Version: 1.14
image thumbnail

Face Detection System


Omid Sakhi (view profile)


13 May 2006 (Updated )

Face Detection using Gabor feature extraction and Neural Network

| Watch this File

File Information

Version : 7.0
Version 7.0 adds the implementation of a neural network.

Please visit the official website for this program at the address:


You will find instructions on how to run the program, some basic diagrams of the algorithm and also a forum and a contact page to discuss about it.

To run the program:

    1- copy all files and directories to the MATLAB's work folder
     * In order to run the program you must have Image Processing Toolbox

    2- find the file named "main.m"

    3- Double click on this file or type "main" in the command window

    4- a menu will be shown . click on "Train Network" and wait until the program is done with the training

    5- click on "Test on Photos". A dialog box will be appeared. Select a .jpg photo

    6- Wait until the program detects some faces

Required Products Image Processing Toolbox
MATLAB release MATLAB 8.1 (R2013a)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (157)
26 Dec 2015 Ofir Goldshtok

Dear Omid Sakhi,

I'm running your program on Matlab R2015a-
The file is compiled and everything is working with the built-in pictures--
but when I run this algorithm on my own pictures it doesn't detect any face at all.
How do I make my system to successfully detect new faces? Should I add files to the 'face' / 'non-face' folders? Where can I find more information?

Thank you very much- Ofir.

11 Dec 2015 laura reyes

Sorry I made a typo. The error says :
" Error using imread (line 362)
Unable to determine the file format"

Thank you.

Comment only
11 Dec 2015 laura reyes

Hi Omid,

I am getting an error in line 362 it says"Error using mired(line 362)
Unable to determine the file format.

I read through the comments and did't encounter anyone with this problem. Please help me! I really want to figure this out.

Thank you.

Comment only
30 Oct 2015 Mahmood Ali  
19 Aug 2015 Manishankar Mondal

Error using run (line 70)
include\createGabor.m not found.

Error in main (line 19)
run ('include/createGabor.m');

Error in run (line 74)
evalin('caller',[script ';']);

Comment only
18 Aug 2015 kevine099

hi omid sakhi,
using "im4.jpg" you have given,in the result,some rectangles are close,but some are open,and several are mistakes.why?
by the way,the program cannot run with color images?Can your code be modified without modifing a lot(algorithms,models,and etc)?
thank you for your answer!

06 Aug 2015 chalvin ardany

thank you....on your information

06 Aug 2015 chalvin ardany

thank you....on your information

Comment only
23 Jun 2015 Omid Sakhi

Omid Sakhi (view profile)

Hi Tayashan,

Seems like you are running the main script in the incorrect folder. You should navigate to the correct folder before running the main script.


Comment only
22 Jun 2015 tayashan milinda

hi omid sakhi,
I have used 2014b version when i run main it will error,
Error in main (line 19)
run ('include/createGabor.m');
plz help me

Comment only
22 May 2015 Omid Sakhi

Omid Sakhi (view profile)


You only have to create an empty folder called "data" there. That would probably solve the problem. I will update the program again to make sure that this empty folder exists.

Thank you

Comment only
22 May 2015 masn

masn (view profile)

hi omid sakhi,
i've try run the updated one by using matlab2013, and the error come out

Error using save
Cannot create 'gabor.mat' because '../data' does not exist.

Error in createGabor (line 39)
save ('../data/gabor.mat','G');
Error in run (line 64)
evalin('caller', [script ';']);

Error in main (line 19)
run ('include/createGabor.m');

can you suggestion any solution to fix the error?
thanks in advance

Comment only
20 May 2015 Omid Sakhi

Omid Sakhi (view profile)


The program is updated. Please download the updated program version 7.0 and see if it helps the problem or not.


Comment only
19 May 2015 masn

masn (view profile)

Please i want your help because i realy need this program. after all of the step when i click on "Train Network" i have this error :

Out of memory. Type HELP MEMORY for your options.

Error in nnMex2.codeHints (line 117)
hints.TEMP = zeros(1,ceil(tempSize/8),'double');

Error in nncalc.setup2 (line 13)
calcHints = calcMode.codeHints(calcHints);

Error in network/train (line 306)
[calcLib,calcNet] =

Error in train_net (line 35)
net = train(net,P{1,1},T{1,1});

Error in run (line 64)
evalin('caller', [script ';']);

Error in main (line 40)
run ('include/train_net.m');

thanks for any suggestions

Comment only
25 Feb 2015 mohammad alomari

i want code

Comment only
19 Dec 2014 shivam asati

awesome output of code.thanks a lot!!!

06 Dec 2014 Adilmar

Very good congratulations, as I change the hidden layers, wanted to increase

20 Oct 2014 KALYAN KUMAR

Can any one send the source code for face detection system that works well in matlab 2013

Comment only
06 Aug 2014 banupriya saravanan  
04 Jun 2014 OUMAYMA

Please i want your help because i realy need this program. after all of the step when i click on "Train Network" i have this error :

Out of memory. Type HELP MEMORY for your options.

Error in nnMex2.codeHints (line 117)
hints.TEMP = zeros(1,ceil(tempSize/8),'double');

Error in nncalc.setup2 (line 13)
calcHints = calcMode.codeHints(calcHints);

Error in network/train (line 306)
[calcLib,calcNet] =

Error in train_net (line 35)
net = train(net,P{1,1},T{1,1});

Error in run (line 64)
evalin('caller', [script ';']);

Error in main (line 40)
run ('include/train_net.m');

thanks for any suggestions

11 May 2014 Kun

Kun (view profile)

03 Mar 2014 gitanjali

Sir please send me 3D face detection code..m using matlab 2013b...please..my id is singhgitanjali11@gmail.com

17 Feb 2014 haem

haem (view profile)

04 Feb 2014 Akshay Gore

Akshay Gore (view profile)

Code not working in matlab 2013a

Comment only
28 Jan 2014 blast 461

Can you send the face detection code to

Comment only
28 Nov 2013 sara na

Thanks a lot !
It's great , really great!!!!

17 Sep 2013 George

George (view profile)

02 Jul 2013 andri

andri (view profile)

ıt's wonderful..

how to make database after test on photos

26 Jun 2013 javed patel

pls sent face detectin coding
pls imeditly

Comment only
14 May 2013 philanik


Can any one help me I need to buy face detection code guide. when I click down load I get this message ''This product combination does not exist''.

Comment only
09 May 2013 someone

good work

Comment only
06 May 2013 someone

I want the code for face recognition using neural network in matlab
thank you

Comment only
13 Mar 2013 betül

betül (view profile)

ıt's wonderful..

08 Feb 2013 chakrit kongsue


14 Feb 2012 saurabh bindoo

Need a MATLAB code for 'online face recognition using fuzzy ART'

Comment only
11 Feb 2012 C N N

C N N (view profile)

its great work.. but i would like to change it according to my database. When i train with my database of image, the accuracy is bad. It doesn't detect that well. why is that so?

Comment only
24 Jan 2012 mary

mary (view profile)

Its a good work. do you have any idea about retrieving face image from database using neural network and svm and comparing their results?

13 Jan 2012 k.v.swamy

excellent sir,great work.thank u for giving us the code.

26 Nov 2011 Ali Tayeh

I wanna the documentation its greaat :)

Comment only
15 Nov 2011 SS

SS (view profile)

Need a MATLAB code for Caricature Generation/ Facial Feature Extraction.
Kindly help.

Comment only
25 Oct 2011 donny jason

very well written code. The gabor that sir use is the gabor filter?

Comment only
20 Aug 2011 Fox

Fox (view profile)

07 Aug 2011 scholars

sir can u give code for lip reading thru neural network, i wan2 work in dat field.

waiting for ur reply at

08 Jul 2011 hakim kadhim

It is very good job I hope to see more such that Good Luck

Hakim Adil

Comment only
06 Jul 2011 vidit

vidit (view profile)

nice to see it work, thanks

06 Jul 2011 Mr. BOUREZG

Hi sir,
good work, thanks

15 Apr 2011 Suzzie

Suzzie (view profile)

A good work done. works on all Matlab platforms, ie. Windows, Linux, Mac and it gives a 100% detection rate.

07 Mar 2011 kundan

kundan (view profile)

hello sir,
i am doing my B.Tech project in Image processing.i have to compare the image captured from webcam or camera to images stored in data base.please help me,i undergone with the code,but i don;t understand how to connect with WebCam.

Comment only
06 Feb 2011 hema

hema (view profile)

Hello sir,
I'm interested to do project on 'face and eye detection'. I have downloaded the code and i tried to execute the code but it showed the errors because i don't know anything about programming part & even i don't know commands & functions in matlab. I have tried to execute the code without any manipulations.im a quick learner i can learn all about matlab in a short period of time but i have no time to finalize the project topic name.i have to finalize the topic name by 08-feb-2011.so kindly explain the code with an example or in detail.if u help me in executing the code then i will do project on this topic.so kindly help me.i will be very thankful to you.Forgive me if u find any mistakes in my english.I hope to receive your reply as soon as possible.Thank you.

04 Feb 2011 Krishna Sarbari

can you give me the algorithm for the code.

25 Jan 2011 raghav kowtha

awesome work!!!!
it worked for me very well!!
i'll be glad to see if u could also give any flow chart or algorithm which u used to implement your ideas!!!
thank u !

Comment only
22 Jan 2011 Albin

Albin (view profile)

Excellent! I like your approach with gabor filtering and neural network.

22 Jan 2011 victoria

great job !
but i received the foll error when i press the train network button.

what's the solution?

??? Error using ==> svmtrain at 172
Group must be a vector.

Error in ==> trainnet at 18
net =

Error in ==> main at 32
net = trainnet(IMGDB);

05 Jan 2011 Mark

Mark (view profile)

Great stuff! However when it comes to place the rectangles over the faces I get the following error:

??? Undefined function or variable 'Threshold'.

Error in ==> imscan at 74
xy_ = Cell.net > Threshold;

(as the 'Threshold' variable is not defined anywhere). What should it be set to?

05 Dec 2010 Omid Sakhi

Omid Sakhi (view profile)

Thank you for all your comments and questions. One of the most question that I get all the time is the bugs. This program only works with MATLAB version 7.1 and later. Also you need to have image processing and neural network toolbox installed.

Also recently I have heard that there is also a program with MATLAB x64. Please inform me if the program works on x64 or not. Thank you.


Comment only
18 Nov 2010 Yoav Feldman

Well I guess that the problem is with the Matlab that I used and not with the code.

I used Matlab 6.1 and it appears that it is not compatible
with this application.

Comment only
17 Nov 2010 Yoav Feldman

Your code has Bugs,

Maybe this is your intention in order to sell your reference (-;

14 Nov 2010 XV22

XV22 (view profile)

This is not working on Linux with matlab 2010a, I get the following when I click "Train Network":
??? Error using ==> network.train at 145
P: Element {1,1} has 0 rows instead of 2160.

Error in ==> trainnet at 17
net = train(net,P,T);

Error in ==> main at 38
net = trainnet(net,IMGDB);

can you please help me?

Comment only
21 Oct 2010 Electron Ali

Sir , i m interested in Face detectioN of A particuLAr perSon, in a crowd.....

Example:.. i haVe daTa stored in my a Computer,,of a particular person or a grp...,,,.,.then my live camera detect a face frm a crowd ,who match with, a persons, in my list,,,

i get automatically its complete data and info,,.,.

i m electronic student,.plZ,.,help me,
u gUys help me tOO....


07 Sep 2010 ujjwal talati  
07 Sep 2010 Qiu dw

Qiu dw (view profile)

Thanks for sharing your code.

21 Jul 2010 Nishant Jha  
21 Apr 2010 cui jianzhu

I have seen your Face Detection using Gabor feature extraction and neural network. Your Gabor feature extraction method is different from the papers. And I can not understand it. Can you introduce some materia about your code. Just like some Gabor formulas.

Comment only
08 Feb 2010 siddharth shah  
30 Jan 2010 hira

hira (view profile)

i neeed help in implementing NN for Face detection and recognition
please help me

Comment only
13 Dec 2009 Omid Sakhi

Omid Sakhi (view profile)

03 Nov 2009 hala tbeel

hello .. I need to know how to extract features from facial images as mouth , noise and eyes .. please help me :(

Comment only
10 Oct 2009 Raymond Cheng

Thanks for your code.

21 Sep 2009 Kourosh Afsari  
18 May 2009 Daniel N


04 May 2009 Daniel N

very nice work

02 Jan 2009 fayaz fayaz

i am currently doing this project on face recognition,
so currently i want to extract face from an image using matlab, could you pls do me a favour that to give me some guidance about this topic? your help will be much appreciated. I would like to ask another favour that could i have the code so i can understand more about this topic. Thanks

Comment only
31 Dec 2008 Sivaraam


10 Dec 2008 Sahar Mirzaei

i am currently doing some survey on object recognition and neural network.
Your code is wonderful. Do you have some guidance or documentation about it. It would be very nice, if you could send me some documentation about this topic, so that I can undrestand your code more better. Thank in advance for your help.

Comment only
07 Dec 2008 sara

sara (view profile)

wonderful work , thank you, but it did not detect large image with high resolution

14 Sep 2008 Ivelina Stefanova

User-friendly interface, nice.
The only drawback is that test images need to be re-sized as the algorithm may only recognise faces appr. 27 x 18 pixels.

25 Aug 2008 r r  
25 Aug 2008 se df  
03 Aug 2008 chinmayananda mohapatra


Comment only
24 Jul 2008 M V


20 Jul 2008 asher peretz  
13 Jul 2008 fayth zed

Thanks for ur guidance, i have learned alot from it. I really appreciate ur help mr Omid Sakhi

30 Jun 2008 a a  
24 Jun 2008 Alex Mugioiu

I'm working for my PhD in "Face Recognition". I have a number of databases of still faces. In order to reduce the computational level and to discard the background information i tried your algorithm for detection, but with little success. I'm confident that with your guidance (in training and using the network) i can obtain much better results.
Thank you in advance.

Comment only
04 Jun 2008 anila satish

is it advisable to carry out a research in face detection techniques using image rpocesisng and neural networks?

Comment only
04 Jun 2008 Srikrishna Bhat

With such a small data base a good classifier has been developed. Need to increase the speed.

02 Jun 2008 nzg ningzhigang  
29 May 2008 AKROUT Belhassen

good application.
i encourage you to contenue in this project

16 May 2008 nirjhar bhattacharjee

The codes can't detect face?
What can i do?
i followed the instruction too.

Comment only
29 Mar 2008 Mohan G

hey. do anyone have any paper or thesis for this code... please mail me if u have.. it s very urgent... thanks in advance..
my email id is mohanxpressions@gmail.com

13 Mar 2008 Phyu Moe

matlab Files

Comment only
10 Mar 2008 sandip pandao

very helful for new comers

04 Mar 2008 ravi kiran

a nibble slow

11 Feb 2008 hasan sadikin

could you pls do me a favour that to give me some guidance about this topic? your help will be much appreciated. I would like to ask another favour that could i have the code so i can understand more about this topic. Thanks

06 Feb 2008 fayth yap

i am currently doing some survey on this title, could you pls do me a favour that to give me some guidance about this topic? your help will be much appreciated. I would like to ask another favour that could i have the code so i can understand more about this topic. Thanks

05 Feb 2008 ewan n/a

thanx for giving this.may god bless you.it really help me.

25 Jan 2008 cs joshi

can i have a little favour,by having the code of this excellent subject so that i can work more on this topic

Comment only
18 Jan 2008 madhu jain

it is helpful in research work it is good

Comment only
01 Jan 2008 Abdallah Asrawi

Thanks Its Very nice But it need more work.
I wanna Ask can I use a part of the code in my Thesis Research.
My e-mail:asrwi@yahoo.com

31 Dec 2007 kim Yeh

Very good.
This is an interesting subject.

29 Dec 2007 jihong zhang

thank you !The result is very right.
But I don't know how to use the gaborfilter?

26 Dec 2007 bb bbbbb  
25 Dec 2007 richal zhao

very interested in the subject

Comment only
30 Nov 2007 Ankur goyal

great work

22 Nov 2007 muhammad ekbal ahmad  
31 Oct 2007 Tom Shih

Real face image can't be found with large face

26 Oct 2007 om yadav

well done

25 Oct 2007 Yaron M

got the following error after pressing train network button:

??? Error using ==> network.train
Inputs are incorrectly sized for network.
Matrices must all have 2160 rows.

Error in ==> trainnet at 17
net = train(net,P,T);

Error in ==> main at 36
net = trainnet(net,IMGDB);

what to do?

11 Oct 2007 vishal wankhede

Code has written by rich knoedge person

04 Oct 2007 Josiah Yoder

To run under linux (ubuntu) with Matlab 7.3 (R2006b), I made the following changes:

* Use / instead of \ for paths in loadimages.m
* Use mapminmax( x' )' instead of premnmx( x )
in imscan.m and im2vec.m

22 Sep 2007 kundan debnath  
21 Sep 2007 QI YF


19 Sep 2007 bakri mamun


Comment only
10 Sep 2007 VN Man

thanks u much

Comment only
06 Sep 2007 karan sadarangani

when i try to train the network , it gives an error. do i have to do something before training the n/w

Comment only
03 Sep 2007 Sahar M

Hi dear Mr. Sakhi.I'm a AI student.I run your code & found it very interesting & usefull so I decided to use it as a part of one of my projects.I have some questions about your project:what sort of images can be used for train & specially for test,do you have any database for it?do you have any document & refrences about it(maybe in farsi)?I will be very appriciating if you let me have those docs.I hope to receive your reply as soon as possible.Thanks in advance for your help.

27 Aug 2007 teerawat kamnardsiri  
22 Aug 2007 Lee Jack


16 Aug 2007 ihsan ihsan

Excelent Job, Sir.

03 Aug 2007 swathi reddy

This is an excellent program i have ever seen in mathworks. Good job sir.

I am a student, working for my class project on "multi target tracking". it helped me a lot for the compleation of my project.Thanks a lot :)

30 Jul 2007 anil gaikwad


22 Jul 2007 fer hadaf

I need a fuzzy connectivity toolbox for image segmentation.I can't find anything.plz help me!

Comment only
19 Jul 2007 newgirl newgirl  
19 Jul 2007 a k


11 Jul 2007 Suvad Selman

I am Suvad Selman and I have one thing to ask (report). I have download this file, unzip it and when i run main.m i got some strange error messages. Here is the message that I get:
*WARNING* PREMNMX is an obsolete function.

Use MAPMINMAX instead, type HELP PREMNMX for bug warning.
Type NNTWARN OFF to suppress NNT warning messages.

Please help me so that I can run this program normally.
Thanks in advance.

Comment only
24 Jun 2007 Luigi Rosa

The recognition rate of last release has been improved.

08 Jun 2007 siva kumar viswanadhuni

Very nice project sir,

25 May 2007 Patrick Storer


28 Apr 2007 lisheng XU

Where is the mfile named adapthisteq?

18 Apr 2007 hossam mohammed  
08 Apr 2007 shrikant nangare

your program is awesome man.

24 Mar 2007 jain varsha

find the DCT format

Comment only
24 Mar 2007 Avinash Pokhriyal

dear sakhi, the code is excellent but how it is implemented in MATLAB and how NN is used for it is not explained in detail. pl do some help on these areas.

19 Mar 2007 m m  
01 Mar 2007 Leonid Doroshenkov  
29 Jan 2007 Ankit Nagpal

Help is insufficient on the role of nn in the project......

29 Jan 2007 Ankit Nagpal

Excellent work done.
Can anyone tell me...
How nn is used in face detection ?? (Iam a beginner in nn)


27 Jan 2007 waqas hijazi

Hi i am student of BCS and doing my poject in matlab.So i need help thats why i am visiting this site/

06 Jan 2007 Mamatha Reddy


Comment only
30 Dec 2006 Amirzeb Badshah

it was really interesting seeing people submitting their work.i hope to do so.it was a good experience.

29 Dec 2006 bal krishna Kalidhar

I am in need of face recognition product for identification of few preselected faces out of crowd of 10000 moving on a railway plateform. product to be integrated to CCTV system of VEINT/ IngerSol Rand surveillance systems.
Please reply yes/no as i am serching such produc for presentation to High level security agency top brasses.
Col Kalidhar (retd)

29 Dec 2006 Greg Kirksey  
14 Dec 2006 gober good

excuse me sir,
my name is GoberGood.
I have been studying in Ahmad Dahlan University.
I have downloaded your program matlab about "face detection" at http://www.mathworks.com.
and I interest to develop your program
to finish the my master education. for that,
I hope to you to assist the me in collecting reference
of about " face detection" and problem any kind of which
you get when doing research. I very requiring of
your paper. forgiveness, if my english is bad.

Comment only
11 Dec 2006 klesk ch  
09 Dec 2006 leo mariaraj

hi like the project.But u should involve the final step of matching the rectangle marked face with image in database.which is actuall face recoginition

09 Nov 2006 good good  
30 Oct 2006 Ngoc Hanh Dang  
26 Oct 2006 aysel saberi

very googd

Comment only
23 Oct 2006 haoxue wang

good example

26 Aug 2006 Bharat Knight


Comment only
23 Aug 2006 Omid Bonakdar Sakhi

This source is for educational purpose only and is tested under MATLAB 7.0 . not for distribution or creating .exe files . Most of the compiling problems and building exe files return to Matlab bugs . Please check Matlab Bugs and Solutions .

Comment only
01 Aug 2006 saba hafez

when I create the exe file recive this massage whats means?
The ntvdm cpu has encountered an illegal instruction
Cs:____ ip:____ op: _ _ _ _ _ choose close to terminate the aplication

Comment only
24 Jun 2006 Alfa Gatriono Kencana

this gonna be a good work today
but, i still didn't get the point after using some RGB image. thanks for the reply. it's mean a lot to me

22 Jun 2006 Tzafrir Shlomo

Dear Omid,
when we run the Main under Matlab we received the following errors:
??? Error: File: C:\MATLAB6p1\work\loadimages.m Line: 6 Column: 6
Missing operator, comma, or semicolon.

Error in ==> C:\MATLAB6p1\work\main.m
On line 41 ==> IMGDB = loadimages;
We would appreciate it if you could help us solving the problem.
best wishes,
Dr. Tzafrir Shlomo

Comment only
21 Jun 2006 Tzafrir Shlomo

good work !!
thank you

Comment only
16 May 2006 Engin Kocaadam

Good work, but has some problems with exact detection.

16 May 2006 Terry Duong

I have just download it and haven't check it yet. But iam sure it good. I am doing in face recognition using NN too. Hope i can learn a lot from yours

23 May 2006

I have Added comments to all files to make them easy and understandable.

21 May 2007

Version 5.0 : Better Algorithm with a user's guide

14 May 2009 1.1

one article ( in Persian ) and one user guide ( in English ) are added to the project.

15 May 2009 1.3

Fixing the FIle Format

10 Aug 2009 1.4

I have only changed the description and added the address of the website for this program.

14 Dec 2009 1.8

Two fixes are solved.
1- correcting path for linux systems
2- problem of mapminmax for older versions of MATLAB

13 Jan 2010 1.10

replacing two functions with built-in functions, so that older versions of MATLAB can run the program correctly.

26 Dec 2010 1.12

Some fixes are applied for executing the program under Linux CentOS

03 May 2015 1.14

Version 7.0 adds the implementation of a neural network.

Contact us