フィルターのクリア

My score is always zero, please help. I am new to matlab. My code is below

2 ビュー (過去 30 日間)
Zamokuhle Ngubane
Zamokuhle Ngubane 2019 年 7 月 1 日
コメント済み: Shameer Parmar 2019 年 7 月 1 日
trainingDirectory = fullfile(*);
testingDirectory = fullfile(*);
% |imageDatastore| recursively scans the directory tree containing the
% images. Folder names are automatically used as labels for each image.
trainingSet = imageDatastore(trainingDirectory, 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
testingSet = imageDatastore(testingDirectory, 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
%% Extract HOG features from the train set.
numOfTrainImages = numel(trainingSet.Files);
cellSize=[8 8];
trainingFeatures = [];
trainingLabels = [];
for i = 1:numOfTrainImages
img = readimage(trainingSet, i);
img = imbinarize(img);
img = ~bwmorph(img,'thin',Inf);
%[extractFeatures,visuals]= extractHOGFeatures(img);
trainingFeatures(i,:)= extractHOGFeatures(img,'CellSize',cellSize);
end
% Get labels for each image.
trainingLabels = trainingSet.Labels;
classifier = fitcsvm(trainingFeatures, trainingLabels);
%% Extract HOG features from the test set.
setLabels = testingSet.Labels;
numOfTestImages = numel(testingSet.Files);
testingFeatures = [];
for i = 1:numOfTestImages
img = readimage(testingSet, i);
img = imbinarize(img);
img = ~bwmorph(img,'thin',Inf);
%[extractFeatures,visuals]= extractHOGFeatures(img);
testingFeatures(i,:)= extractHOGFeatures(img,'CellSize',cellSize);
end
[label,bothscores] = predict(classifier,trainingFeatures);
score = bothscores(:,1);
msgbox(sprintf('%.6f',score));
  2 件のコメント
darova
darova 2019 年 7 月 1 日
You have a problem or what?
Shameer Parmar
Shameer Parmar 2019 年 7 月 1 日
What is your problem in this code ? Please explain..

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by