Support Vector MAchine

asked 2014-09-10 01:36:28 -0500

jamesnzt gravatar image

I am new to SVM. I studied about using SVM from documentaion. and for working with images i refered "using OpenCV and SVM with images".

In documentation i understand the operation of SVM using coding. In "Using OpenCV and SVM with images" working with various image is discussed.

My application is to classify the feature extracted from my image with the image stored in memory. I use basic operations to get my ROI and calculated Hu-moments. is it possible to use SVM for my application as classifier?

edit retag flag offensive close merge delete

Comments

1

sure this is possible (and a valid idea). try to code it, and come back, if you hit an obstacle.

your train-matrix will be N rows, each of them a humoment, your test-matrix will be a singe row(humoment).

berak gravatar imageberak ( 2014-09-10 01:49:54 -0500 )edit

yep that will work. I succeeded in building it for a HSV average value from a region descriptor, so it will work perfectly in your case.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-09-10 04:00:10 -0500 )edit

@jamesnzt, were you using 2.4.9 or 3.0 ?

berak gravatar imageberak ( 2014-09-10 04:02:31 -0500 )edit

@berak 2.4.9

jamesnzt gravatar imagejamesnzt ( 2014-09-10 23:36:19 -0500 )edit

i have a doubt! While training SVM we give the training data (already processed / known image's Hu-moments)and labels for it but where we have to give the Hu-moments i calculated for current image?

jamesnzt gravatar imagejamesnzt ( 2014-09-22 01:09:32 -0500 )edit

you are trying to predict() the class for a current Hu-moment now ?

berak gravatar imageberak ( 2014-09-22 01:13:48 -0500 )edit

yes. whether i have to give its values as Mat to pedict( ) function? @berak

jamesnzt gravatar imagejamesnzt ( 2014-09-22 03:45:40 -0500 )edit
2

yes, do so, please.

    double hu[7]; // from HuMoments()
    Mat query(1,7,CV_64F,hu);

    float r = svm.predict ( query );
    int label = (int)floor(r+0.5); // round
berak gravatar imageberak ( 2014-09-22 04:08:42 -0500 )edit

Like @berak said is completely correct :)

StevenPuttemans gravatar imageStevenPuttemans ( 2014-09-22 05:03:29 -0500 )edit

I tried to write the coding but i stuck with two doubts i have hue moments for 5 data sets. two negative data hue moments. 1. how can i get the 7 data values in a program? 2.. How can i train the SVM with 7 data sets?

jamesnzt gravatar imagejamesnzt ( 2014-10-06 02:08:53 -0500 )edit