Matlab code to select some images from numbers of images in a folder and assign them as testing set while others are assign as training set.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have an image database which consist of 40 folders and in each folder, there are 6 images of individuals. The total images are now 240 images. Now in each folder, i want to select two images, i.e image no 3 and no 4 and assign them as testing set while the remaining four will be assign as training set. This should happen for all the images in the folders in the database at once. How do i do the matlab coding.
This is how my initial code is;
%Load Image
faceDatabase = imageSet('T8ATT','recursive');
%Display Query Image and Database side by side
fprintf('Press Enter to select image')
pause;
[filename,pathname]=uigetfile({'*.jpg'},'Pick an image file');
galleryImage=imread([pathname,filename]);
figure;
for i=1:size(faceDatabase,2)
imageList(i)=faceDatabase(i).ImageLocation(1);
end
subplot(1,2,1);imshow(galleryImage);title('Selected Image');
subplot(1,2,2);montage(imageList);title('Database Image');
pause(0.002)
% diff=zeros(1,5);
%Split Database into Training and Test sets
[training,test]=partition(faceDatabase,[0.6 0.4]);
%Extract and display Histogram of Oriented Gradient (HOG) features for
%single face
[hogFeature,visualization]=......
extractHOGFeatures(galleryImage);
% figure;
% subplot(2,1,1);imshow(galleryImage);title('Input face');
% subplot(2,1,2);plot(visualization);title('HOG Feature');
figure;
imshow(galleryImage);title('Input face');
figure;
plot(visualization);title('HOG Feature');
%Extract HOG Features for Training Set
trainingFeatures=[];
featureCount=1;
for i=1:size(training,2)
for j=1:training(i).Count
trainingFeatures(featureCount,:)=extractHOGFeatures(read(training(i),j));
trainingLabel{featureCount}=training(i).Description;
featureCount=featureCount+1;
end
personIndex{i}=training(i).Description;
end
% Create 40 class classifier using fitcecoc
faceClassifier=fitcecoc(trainingFeatures,trainingLabel);
%Test Images from Test Set
queryFeatures = extractHOGFeatures(galleryImage);
personLabel=predict(faceClassifier,queryFeatures)
Using this my code, i can partition all the image folder into 2 from this statement
%Split Database into Training and Test sets
[training,test]=partition(faceDatabase,[0.6 0.4]);
This partition the image folder into first 4 images for "training" and last 2 images for "testing".
Now, i want to get a code where i can assign the image number 3 and 4 as "Test" and the rest as "Training" or image number number 2 and 4 as "Test" and the rest as "Training".
Help
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Image Processing Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!