LDA training opencv c++

asked 2018-12-17 07:10:30 -0600

manef gravatar image

I'm working with retinal images and i' have to use LDA classifier with 2 classes. I have a data Base to train my classifier. For this i had to extract feautures from each image (done) but i couldn't find the way how to trained the classifier with all images in my Data Base and i wanna ask in lda.project i could use my features extracted or no?! and could someone show me how to train LDA with my Data Base ?! DiaretDB 1 in my case ans i have her ground truth. I found this lines in tutorials but i couldn't know how to use it

LDA lda(num_components); // retain N elements (e.g. numClasses-1)
lda.compute(trainData, trainLabels); // compute eigenvectors
Mat projected = lda.project(feature_row); // project feature vecs, then compare in lda-space
edit retag flag offensive close merge delete

Comments

for a 1st attempt, you could try with the example here

then, going from ~10000 features to a single number via LDA is probably a bad idea, mostly a PCA compression (before that) is used

berak gravatar imageberak ( 2018-12-17 08:10:45 -0600 )edit

i saw this example before but i couldn't understand do i have to resize all my image ? and for the trainig i have to put all the images in one Mat ? or i have to apply the same methode used by him for every image ?! sorry for the question but this is my first time with classification. and i have exctrated 1320 features from each image ( i follow a the instraction of paper to implemente)

manef gravatar imagemanef ( 2018-12-17 08:15:56 -0600 )edit

idk, how you get your features, but you have to make a single row of those (using reshape()) and stack all the features into a single Mat for training. you also need a labels mat with 1 number (class label) per feature

berak gravatar imageberak ( 2018-12-17 08:19:15 -0600 )edit

@break trainLabels it's my groundtruth ? that's mean if that pixel belong to the ROI pixels ? 1 or 0 ?! because i'm working in lesion detection. and i have the ground truth of my data Base

manef gravatar imagemanef ( 2018-12-19 04:47:11 -0600 )edit

it sounds like it is so, but look at your question, again, you're very vague about anything you do.

berak gravatar imageberak ( 2018-12-19 04:48:53 -0600 )edit

yeah because I'm new in opencv andm dealing with classification for the first time sorry. so i have to put all images of the groundtruth in a vector "trainlabels" with row equal to 1 is that right ? thanks for answering and sorry if my questions are bad or blur

manef gravatar imagemanef ( 2018-12-19 04:53:43 -0600 )edit
1

if your train features are 1320 numbers per image, you need a data mat with nImages rows and 1320 colums, and a labels mat with nImages rows and1 column (the class id for the resp. image / feature)

berak gravatar imageberak ( 2018-12-19 05:15:03 -0600 )edit

@break please i want to repeat the training process 10 time. It's possible to put the training code in loop 10 time or he will squash the information get by the first training saved ?!

manef gravatar imagemanef ( 2018-12-20 03:36:17 -0600 )edit

why do you want to do this ? (it does not make any sense, and no, you can't continuously "update" it)

i don't think it is even "prepared" for that case.

or did you mean: like a "crossfold validation" ? imho, you have to use a new LDA object for each run here

berak gravatar imageberak ( 2018-12-20 03:45:03 -0600 )edit
1

probably a link to some article / paper would be required now.

berak gravatar imageberak ( 2018-12-20 03:49:56 -0600 )edit