I am trying to implement a feature extractor using gabor filter in MATLAB. I have taken images from the JAFFE Database. Here is my code:
angry_database = dir('Path_for_directory'); content_length = length(angry_database); angry_feat = ; for ii = 3:content_length current_file_name = angry_database(ii).name; %reads the image from the database im = imread(current_file_name); %detects the face from the image FDetect = vision.CascadeObjectDetector; x = step(FDetect, im); face = imcrop(im, x); %creates the entire new image after clever cropping using the algo %detects the eye from the face using viola-jones algorithm EyeDetect = vision.CascadeObjectDetector('EyePairBig'); BBE = step(EyeDetect, im); [x y z] = size(BBE); eyes = imcrop(im, BBE(x,:,:)); gaborArray = gabor([4 8 12 16 20], [0 30 45 60 75 90 105 120]); %forms the feature Array of the face gaborFiltFace = imgaborfilt(face, gaborArray); meanArrFace = zeros(1, 40); stdArrFace = zeros(1, 40); %forms the feature array for the eyes gaborFiltEyes = imgaborfilt(eyes, gaborArray); meanArrEyes = zeros(1, 40); stdArrEyes = zeros(1, 40); for i=1:40 meanArrFace(i) = mean2(gaborFiltFace(:,:,i)); stdArrFace(i) = std2(gaborFiltFace(:,:,i)); meanArrEyes(i) = mean2(gaborFiltEyes(:,:,i)); stdArrEyes(i) = std2(gaborFiltEyes(:,:,i)); end featureArray = (horzcat(meanArrFace, stdArrFace, meanArrEyes, stdArrEyes)); featureArray = featureArray./ max(featureArray); featureArray = [num2cell(featureArray) 'A']; angry_feat = [angry_feat; featureArray]; end
The above code is the MATLAB code, it generates a feature vector which is 1x161 matrix, I store this in a csv file and subsequently do for the rest of the images. However, when I implement the csv file in the classifier of WEKA training machine, the classifier shows poor results, the error is close to 90% (worse). I have normalised the data, even used the viola jones, but the error reduction is very small. The above code is the final code that i tried before seeking help. As I am pretty new to MATLAB, can you please tell where I am going wrong, and please suggest me what should I do, so that I can get my desired results?