When I open a images and add them into a class the db.mat shows only the latest image details and other image details are missing. Can you please explain what I have missed in the code?

1 visualizzazione (ultimi 30 giorni)
[fname path]=uigetfile('.jpg','Open a face as input for training');
fname=fulfile(path,fname);
im=imread(fname);
imshow(im);
title('Input image');
c=input('Enter the Class (Number from 1-10)','s');
%%Feature extraction
F=FeatureStatistical(im);
try
load db;
F = [F c];
db = [db;F];
F = [m s];
save db.mat db
catch
db=[F c]; % 10 12 1
save db.mat db
end
function [F]=FeatureStatistical(im)
im=double(im);
m=mean(im(:));
s=std(im(:));
F=[m s];
end

Risposte (1)

Kojiro Saito
Kojiro Saito il 3 Dic 2018
I think you need to change try-cacth statetments. Leave only load db code. And I guess you need to convert charcter c to double so that concat works fine.
try
load db;
catch
db = [];
end
F = [F str2double(c)];
db = [db;F];
save db.mat db
  4 Commenti
Kojiro Saito
Kojiro Saito il 4 Dic 2018
In my environment, it works with no errors. What the size of F and db?
size(F)
it returns [1 3] ?
And
size(db)
returns [n 3] ? (n is integer such as 1, 2 and so on.)

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by