Index exceeds matrix dimensions.
Error in ext_vein (line 381) dist_m = dist2(minutiae(:,1:2), minutiae(:,1:2));
Error in build_db (line 22) traindata{id_train}=ext_vein(X,1);

 Accepted Answer

Walter Roberson
Walter Roberson on 15 Apr 2018
When minu_count is 0 then t_minuae will be left as [] and so will not have columns 1:2 to index into.

6 Comments

second error is
Error using knnclassify (line 96)
The length of GROUP must be equal to the number of rows in TRAINING.
Error in maintotaldemo (line 65)
predictlabel = knnclassify(P_test, P_train, train_label,1,'euclidean','nearest');
I have 20 classes 9 images for P_train class and 3 images for P_test classe. four minutie with 6 columns having x,y,Crossing Number,theta(orientation,flag and permissible minutie extracted from each image so I get P_train i.e 720 X 6 and my train label is 180 X 1, when I use knnclassify group length error occurred, sir is that possible to make group of rows and use index of that group in knnclassify ?
Those four minutiae for any one image: for the purpose of recognition do they need to all be matched, or is it enough to match any one of them?
If they all need to be matched then you should be using 180 x (6*4) rather than 720 x 6.
Sir,is it possible 180 X (6*4) because I have used cell array e.g.
for folder_idx = 1 : 20 % no of classes
for i = 1 : 9 % no of images per class
thisfile = fullfile('train', num2str(folder_idx), [num2str(i) '.bmp ']);
B = imread(thisfile );
X = double(B);
X = imresize(X,[120 120],'bilinear'); %300 250
id_train = id_train+1;
traindata{id_train}=ext_vein(X,1);
end
end
%%size of cell array is 1 X 180 like following
4x6 double 4x6 double....... 4x6 double
is it possible to provide cell array in knnclassify ? if possible then tain_label should be cell array or not
No you cannot give knn cell array. You should reshape it to a row vector, and the 180 samples would become a 180 x 24 array. The label would be 180 long and would be class number associated with the image.
Error using reshape
To RESHAPE the number of elements must not change.
Error in build_db (line 57)
reduced_testdata = reshape(reduced_testdata, 24, 60)
%%Training images
id_test = 0;
id_train = 0;
for folder_idx = 1 : 20 % no of classes
for i = 1 : 9 % no of images per class
thisfile = fullfile('train', num2str(folder_idx), [num2str(i) '.bmp ']);
B = imread(thisfile );
X = double(B);
X = imresize(X,[120 120],'bilinear'); %300 250
id_train = id_train+1;
traindata{id_train}=ext_vein(X,1);
end
end
%%Testing images
d=[];
for folder_idx = 1 : 20 %no of classes
for i = 1 : 3 % no of images per class
thisfile = fullfile('test', num2str(folder_idx), [num2str(i) '.bmp ']);
B = imread(thisfile );
X = double(B);
X = imresize(X,[120 120],'bilinear'); %300 250
id_test = id_test+1;
testdata{id_test}=ext_vein(X,1);
end
end
%%Reduced dimension of rows ( fixed to only 20 rows)
reduced_testdata = cellfun(@(M) M(1:min(end,4), :), testdata, 'uniform', 0);
reduced_traindata = cellfun(@(M) M(1:min(end,4), :), traindata, 'uniform', 0);
%%reshape
% reduced_testdata = reshape(reduced_testdata,1,[]);
reduced_testdata = reshape(reduced_testdata, 60,24);
reduced_traindata = reshape(reduced_traindata, 180,24);
%reduced_traindata = reshape(reduced_traindata,1,[]);
save('db1.mat','reduced_testdata');
save('db2.mat','reduced_traindata');
Sir, I tried a lot but am not able to reshape my cell array into 180 X 24, please help..

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!