Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Digit recognition using MATLAB (Support Vector Machine + HOG)

You can explore more about Digit Classification Using HOG Features from the below link: https://www.mathworks.com/help/vision...

clc;

clear all;

close all;

warning off;

imds=imageDatastore('database','IncludeSubFolders',true,'LabelSource','foldernames');

trainingFeatures=[];

trainingLabels=imds.Labels;      

for i = 1:numel(imds.Files)         % Read images using a for loop

    img = readimage(imds,i);

    trainingFeatures(i,:) = extractHOGFeatures(img,'CellSize',[8 8]);

end

Classifier =fitcecoc(trainingFeatures,trainingLabels);

save Classifier Classifier

 

 

%Testing Code:

clc;

clear all;

close all;

warning off;

load Classifier;

[filename, pathname] = uigetfile('*.*', 'Pick an Image');

filename=strcat(pathname,filename);

imga=imread(filename);

img=imresize(imga,[45 24]);

[Features] = extractHOGFeatures(img,'CellSize',[8 8]);

PredictedClass=predict(Classifier,Features);

PredictedClass=char(PredictedClass);

figure;imshow(imga),title(PredictedClass);

disp(PredictedClass);

 



Join us on Telegram: https://t.me/matlabcastor

No comments

Popular Posts