How to remove this error in this code? This code is for face recognition using principal component analysis
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
function T = CreateDatabase(TrainDatabasePath)
% Align a set of face images (the training set T1, T2, ... , TM )
%
% Description: This function reshapes all 2D images of the training database
% into 1D column vectors. Then, it puts these 1D column vectors in a row to
% construct 2D matrix 'T'.
% Argument: TrainDatabasePath - Path of the training database
% Returns: T - A 2D matrix, containing all 1D image vectors.
% Suppose all P images in the training database
% have the same size of MxN. So the length of 1D
% column vectors is MN and 'T' will be a MNxP 2D
% See also: STRCMP, STRCAT, RESHAPE
% Original version by Amir Hossein Omidvarnia, October 2007
% File management
TrainFiles = dir(TrainDatabasePath);
Train_Number = 0;
for i = 1:size(TrainFiles,1)
if not(strcmp(TrainFiles(i).name,'.')|strcmp(TrainFiles(i).name,'..')|strcmp(TrainFiles(i).name,'Thumbs.db'))
Train_Number = Train_Number + 1; % Number of all images in the training database
end
end
if true
end
% Construction of 2D matrix from 1D image vectors
T = [];
for i = 1 : Train_Number
% I have chosen the name of each image in databases as a corresponding
% number. However, it is not mandatory!
str = int2str(i);
str = strcat('\',str,'.jpg');
str = strcat(TrainDatabasePath,str);
img = imread(str);
img = rgb2gray(img);
[irow icol] = size(img);
temp = reshape(img',irow*icol,1); % Reshaping 2D images into 1D image vectors
T = [T temp]; % 'T' grows after each turn
end
Error in CreateDatabase (line 2)
functions T = CreateDatabase(TrainDatabasePath)
>> CreateDatabase
Error using CreateDatabase (line 23)
Not enough input arguments.
Please help me in this code..Thanks in advance
2 Commenti
surya surya
il 16 Set 2017
Modificato: Walter Roberson
il 17 Set 2017
CreateDatabase('C:\Prgram Files\MATLAB\R2009b\work\face recognition');
use in this format instead of that
Rakesh Kashyap
il 3 Nov 2017
How to give the path of image as an argument to createdatabase function?
Risposte (1)
Image Analyst
il 17 Set 2017
Well, eveidently it wants another input argument. Why don't you just simply supply all the input arguments that it requires? You can't do this:
>> CreateDatabase
Error using CreateDatabase (line 23)
Not enough input arguments.
Look at the definition. CreateDatabase() requires a string that is a folder as an input. You did not supply that -- you just called it without supplying ANY arguments. Why didn't you supply the folder that it wants???
2 Commenti
Sindhuja Chaduvula
il 7 Giu 2021
function T = CreateDatabase(TrainDatabasePath)
% Align a set of face images (the training set T1, T2, ... , TM )
%
% Description: This function reshapes all 2D images of the training database
% into 1D column vectors. Then, it puts these 1D column vectors in a row to
% construct 2D matrix 'T'.
%
%
% Argument: TrainDatabasePath - Path of the training database
%
% Returns: T - A 2D matrix, containing all 1D image vectors.
% Suppose all P images in the training database
% have the same size of MxN. So the length of 1D
% column vectors is MN and 'T' will be a MNxP 2D matrix.
%
% See also: STRCMP, STRCAT, RESHAPE
% Original version by Amir Hossein Omidvarnia, October 2007
% Email: aomidvar@ece.ut.ac.ir
%%%%%%%%%%%%%%%%%%%%%%%% File management
TrainFiles = dir('\Users\prasanth\Downloads\MATLAB code 3\database2\');
Train_Number = 0;
for i = 1:size(TrainFiles,1)
if not(strcmp(TrainFiles(i).name,'.')|strcmp(TrainFiles(i).name,'..')|strcmp(TrainFiles(i).name,'Thumbs.db'))
Train_Number = Train_Number + 1; % Number of all images in the training database
end
end
%%%%%%%%%%%%%%%%%%%%%%%% Construction of 2D matrix from 1D image vectors
T = [];
%disp(Train_Number);
for i = 1 : Train_Number-1
% I have chosen the name of each image in databases as a corresponding
% number. However, it is not mandatory!
str = int2str(i);
str = strcat(char(str),'.jpg');
str = strcat(TrainDatabasePath,str);
% display(str);
img = imread(str);
img = im2gray(img);
[irow, icol] = size(img);
temp = reshape(img',irow*icol,1); % Reshaping 2D images into 1D image vectors
T = [T temp]; % 'T' grows after each turn
end
end
>> CreateDatabase
ans =
[]
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!