Select Faces from folder
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have 200 face images in a folder,I have to select only male faces from it,please help below is my code thanks!!!
clear all;
close all;
clc;
CLASSROOM_FOLDER = 'G:\IMG Class Database\'; % Classroom folder
FACE_FOLDER = 'G:\MPI Face Database\'; % Face folder
COMPOSITE_FOLDER = 'G:\Composite Image DatabaseMale\'; % Output folder
CLASSROOM_FILENAMES = dir(CLASSROOM_FOLDER);
FACE_FILENAMES = dir(FACE_FOLDER);
CLASSROOM_FILENAMES = CLASSROOM_FILENAMES(3:end);
FACE_FILENAMES = FACE_FILENAMES(3:end);
numClassrooms = size(CLASSROOM_FILENAMES);
numFaces = size(FACE_FILENAMES);
for currentClassroom = 1:numClassrooms
classroomImage = imread([CLASSROOM_FOLDER CLASSROOM_FILENAMES(currentClassroom).name]);
for currentFace = 1:numFaces
faceImage = imread([FACE_FOLDER FACE_FILENAMES(currentFace).name]);
M_face = size(faceImage,1);
N_face = size(faceImage,2);
compositeImage = classroomImage;
compositeImage((end/2)-(M_face/2):(end/2)+(M_face/2)-1,(end/2)-(N_face/2):(end/2)+(N_face/2)-1,:) = faceImage;
for i=1:size(classroomImage,1)
for j=1:size(classroomImage,2)
if(compositeImage(i,j,1) == 0)
compositeImage(i,j,:) = classroomImage(i,j,:);
end
end
end
% Store composite images to disk
filename = sprintf('Class%d_Face%d.jpg',currentClassroom, currentFace);
fullFilename = [COMPOSITE_FOLDER filename];
disp(fullFilename);
imwrite(compositeImage,fullFilename); % Using imwrite to save the image into compositeImage
end % currentFace
end % currentClassroom
2 Kommentare
Image Analyst
am 9 Mär. 2018
Bearbeitet: Image Analyst
am 9 Mär. 2018
What kind of help do you want, other than how to format your code: http://www.mathworks.com/matlabcentral/answers/13205#answer_18099
KALYAN ACHARJYA
am 18 Mär. 2018
Bearbeitet: KALYAN ACHARJYA
am 18 Mär. 2018
In your question has two parts 1. Call the images and 2. Identify face Male or Female
% Save all images name in a symmetric manner before doing the operation
% names for example im1,im2,im3...
%Save the folder of images in the current directory
path_directory='folder_name'; % 'Folder name'
original_files=dir([path_directory '/*.jpg']); %Note: Image format
for k=1:length(original_files)
filename=[path_directory '/' original_files(k).name];
image_orginal=imread(filename);
% Convert gray
% First Part is done
% Choose only male faces
% Write a code for face identification whether male or female
% For that Image Analyst sir clearly mentioned the link of the website
%http://illusionoftheyear.com/2009/05/the-illusion-of-sex/
% Which mentioned that The Illusion of Sex demonstrates that contrast is an important cue for
%perceiving the sex of a face, with greater contrast appearing feminine, and lesser contrast
%appearing masculine
% measure the contrast of the image (very subjective topic)
% Choose threshold
% if less than threshold male else female
% Save if yes male otherwise discard
end
Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!