File Exchange

image thumbnail

Gender recognition from face images with trainable COSFIRE filters

version (13.4 MB) by Antonio Greco
This MATLAB code allows you to perform gender recognition from face images for a given dataset.


Updated 06 Jun 2018

View License

Gender recognition from face images is an important application in the fields of security, retail advertising and marketing. We propose a novel descriptor based on COSFIRE filters for gender recognition. A COSFIRE filter is trainable, in that its selectivity is determined in an automatic configuration process that analyses a given prototype pattern of interest. We demonstrate the effectiveness of the proposed approach on a new dataset called GENDER-FERET with 474 training and 472 test samples and achieve an accuracy rate of 93.7%. It also outperforms an approach that relies on handcrafted features and an ensemble of classifiers. Furthermore, we perform another experiment by using the images of the Labeled Faces in the Wild (LFW) dataset to train our classifier and the test images of the GENDER-FERET dataset for evaluation. This experiment demonstrates the generalization ability of the proposed approach and it also outperforms two commercial libraries, namely Face++ and Luxand.
Due to the random selection of features, the recognition rate that you will obtain with this script may not be precisely the same as the reported one in the paper. It should, however, be very close. Please read the readme.txt file before running the code.
You are kindly invited to use this Matlab implementation and cite the following articles:
1. George Azzopardi, Antonio Greco, and Mario Vento. "Fusion of domain-specific and trainable features for gender recognition from face images." IEEE Access, 2018.
2. George Azzopardi, Antonio Greco, and Mario Vento. "Gender recognition from face images with trainable COSFIRE filters." Advanced Video and Signal Based Surveillance (AVSS), 2016 13th IEEE International Conference on. (pp. 235-241) IEEE, 2016.
3. George Azzopardi and Nicolai Petkov, "Trainable COSFIRE filters for keypoint detection and pattern recognition", IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 35(2), pp. 490-503, 2013.

Cite As

Antonio Greco (2021). Gender recognition from face images with trainable COSFIRE filters (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (19)

Nabeel Hashim

can any one send basepaper for e-mail id is

Ashkan Nazemi

Hello Dr. Greco

I have a question about your published code on the mathworks site.
When I run the Gender recognition code in matlab there is an error that I couldn't fix. The error is this:

"Undefined function or variable 'maxblurring'.

Error in maxblur (line 12)
output = maxblurring(maxblurring(inputImage,gauss1D',1,nc,1,nr),gauss1D,1,nc,1,nr);"

I'll be glad if you can help me to solve this problem.

Sincerely yours,

Annie micheal

hi.. the code runs perfectly well. but i need the output for an input image as shown in the paper i.e The superimposed (inverted) response maps of a
bank of Gabor filters , the structure of a COSFIRE filter that is configured to be selective for the prototype pattern and the (inverted) response map of the concerned COSFIRE filter to the input image. kindly help me to display the output. reply ASAP

Dare daricocity

Hi guys, i've try the code but when i run setup.m it give this error

Building with 'MinGW64 Compiler (C)'.
Error: C:\Users\hp\Documents\MATLAB\New Project\COSFIRE_Gender_recognition_1_0\libsvm_3_21\matlab\make.m failed (line 13)
gcc: error: \-fexceptions: No such file or directory

please what can i do

Mohd Zamri

Antonio Greco

Dear M.Muhajid,
the module Gender_recognition/testCOSFIREPyramidModel can help you for this purpose.

[pl,~,svmscore] = svmpredict(data.testing.labels',testingKernel,model);
result = classperf(data.testing.labels,pl);

As we did for the structure result, you may save pl, which gives you information about the decisions taken by the classifier. Using such information, you can perform reverse engineering to understand which are the images wrongly classified.


Mujahid Iqbal

Hi MR @Antonio Greco
Your code works perfectly.As the code gives overall result in accuracy percentage, how should i know from the result variables that which of the test images belongs to which class???Reply ASAP

alice rules

alice rules

Hi guys, i've already try the codes.. it works and Mr. Antonio assisted me with the code too. Thank you.

Rere yuni

Antonio Greco

Dear Syahdan Edy Murad,
you have less than 180 images in your training set.
So you have two possibilities:
1) Increase the number of samples in the training set
2) Start the program with Gender_recognition_with_COSFIRE(X, 'COSFIRE', 1, NaN), where X is less than the number of samples in the training set


syahdan edy murad

Otherwise, I got another error. Could you please help me?
>> Gender_recognition_with_COSFIRE(180, 'COSFIRE', 1, NaN)
Configuring COSFIRE filters from Male face images
Error using randperm
K must be less than or equal to N.

Error in configureCOSFIREfilters (line 14)
permlist = randperm(size(imageset,3),noperators);

Error in getCOSFIREoperators (line 7)
operatormalelist = configureCOSFIREfilters(,noperators,1);

Error in Gender_recognition_with_COSFIRE (line 89)
operatorlist = getCOSFIREoperators(outdir,dataset,noperatorspergender);

Ramya keerthi

Ishita Mittal

Thanks for the code.Can you please help me in running this?

Antonio Greco

Hi Wafa! Thank you for your interest. My e-mail is on the paper: .

wafa khan

Hi Antonio Greco ,
Thanks for publishing such matlab code it's very useful
I found difficulties to run this
can u help me, please?
How can I contact you ?
best wishes ^_^

wafa khan

Antonio Greco

Hi Akhil,
considering your e-mail, I guess that you solved the problems with the compilation of libsvm. Please contact me if you need more help. Regards!

Akhil Sreenivasulu

Hi Antonio Greco,
Thanks for providing matlab code. I read readme file,
I selected Application folder and executed "setup;"
But I am facing few issues as follows

Error ..\svm.cpp: 15 syntax error; found `<' expecting `;'
Error ..\svm.cpp: 18 too many errors

<matlab_folder>\BIN\MEX.PL: Error: Compile of '..\svm.cpp' failed.
Error:<matlab_folder>\toolbox\matlab\general\mex.m failed (line 221)
Unable to complete successfully.

Could you please help me out, How to solve this issue.?

Wafa Alshaikh

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!