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 Ansicht (letzte 30 Tage)
[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

Antworten (1)

Kojiro Saito
Kojiro Saito am 3 Dez. 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 Kommentare
Kojiro Saito
Kojiro Saito am 4 Dez. 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.)

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by