I have taken a kaggle image dataset which contains star, triangle, circle and square. I have considered some images for training and testing and I have classified them using SVM:

clc;

clear all;

close all;

path1='D:\imagedb\trainimg';

path2='D:\imagedb\testimg';

traindb=imageDatastore(path1,'IncludeSubfolders',true,'LabelSource','foldernames');

testdb=imageDatastore(path2,'IncludeSubfolders',true,'LabelSource','foldernames');

%Training

img=readimage(traindb,1);

CS=[16,16];

[hogfv,hogvis]=extractHogfeatures(img,'cellsize',CS);

hogfeaturesize=length(hogfv);

totaltrainimages=numel(traindb.Files);

trainingfeatures=zeros(totaltrainimages,hogfeaturesize,'single');

for i=1:totaltrainimages

img=readimage(traindb,i);

trainingfeatures(i,:)=extractHogfeatures(img,'cellsize',CS);

end

traininglabels=traindb.Labels;

classifier=fitcecoc(trainingfeatures,traininglabels);

%testing all test images

totaltestimages=numel(testdb.Files);

testfeatures=zeros(totaltestimages,hogfeaturesize,'single');

for i=1:totaltestimages

imgt=readimage(testdb,i);

testfeatures(i,:)=extractHogfeatures(imgt,'cellsize',CS);

end

testlabels=testdb.Labels;

predictedlabels=predict(classifier,testfeatures);

accuracy=(sum(predictedlabels==testlabels)/numel(testlabels))*100

plotconfusion(testlabels,predictedlabels)

In the same manner I want to classify objects like metal pipe, steel box and plastic box buried under the ground. The imaging is done by using ground penetrating radar which actually sends EM pulses into the ground and generates B-scan images but the images not exactly give original images, it will give hyperbola shape only. I have generated some database by varying object sizes, depths and dielectric constants. Imaging is done by imagesc not by imshow. I could not save the image as .jpg or .png etc formats. so that I cannot read by imread or readimage. after plotting I have saved the data in excel '.txt' format and I'm recalling by 'dlmread'. like below

y=dlmread('metal_pipe_er2.6.txt', '\t', 0, 0);

figure,imagesc(X,z_depth,y)

now I want to extract HOG features for my text files as like imaging database and classify using SVM. please help me

More Santhosh kumar Buddepu's questions See All
Similar questions and discussions