Someone Please Help me to save Features into .mat file along with labels

1 回表示 (過去 30 日間)
saeeda saher
saeeda saher 2018 年 6 月 8 日
コメント済み: Walter Roberson 2018 年 6 月 8 日
Here is my code, I am beginner and dont kow how to edit it. I want to save HOG features into .mat file with labels. Please help.
training=imageSet('Training/Fear','recursive'); % folder name of the database
K=1;
%featureMatrix = [];
for i=1:size(training,2 )
for j=1:training(i).Count
Face=read(training(i),j);
Face=imresize(Face, [48 48]);
%Face=rgb2gray(Face); %If color images
% Face = pca(double(Face));
%newFace = LBP(Face);
%imshow(uint8(Face))
HOG_Features= extractHOGFeatures2(Face);
%featureMatrix = [featureMatrix; HOG_Features];
%disp(featureMatrix )
trainingFeatures(K,:)=single(HOG_Features);
% plot(visualization);
traininglabel{K}=training(i).Description;
K=K+1;
end
persons{i}=training(i).Description;
end
traininglabel=traininglabel';
csvwrite('TrainFear4-2.csv', trainingFeatures)

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 6 月 8 日
To save in a .mat file:
save('TrainFear4-2.mat', 'traininglabel', 'trainingFeatures');
If you wanted to save into .csv file like in the existing code:
data_to_write = [traininglabel(:), num2cell(trainingFeatures)];
csvwrite('TrainFear4-2.csv', data_to_write);
Note that this would only work for MS Windows with Excel installed; for other systems different commands would be needed to write the file.
  2 件のコメント
saeeda saher
saeeda saher 2018 年 6 月 8 日
I tried your code but its not saving the labels on right side of mat file after the features in one .mat file.
Walter Roberson
Walter Roberson 2018 年 6 月 8 日
.mat files do not have a left or right side.
Note: it is not possible to create a numeric array that has text labels as part of it. You can have cell arrays that have a mix of numeric and text, and you can have table() objects that have a mix of columns of numeric and columns of text.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by