필터 지우기
필터 지우기

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));

답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by