2016-05-18 10:42:58 -0600 received badge ● Scholar (source) 2016-05-18 10:42:56 -0600 received badge ● Supporter (source) 2016-05-18 10:41:48 -0600 asked a question Getting nan from multiplying cv::Mat 's Hi. I have several images and I transformed them into a cv::Mat matrix and I named it trainingMat (each row represents an image). I have also a diagonal matrix named R. When I multiply trainingMat by R (cv::Mat first = (trainingMat.t() * R);), Everything is fine and I get a dense matrix. But When i try this: cv::Mat first = (trainingMat.t() * R * trainingMat);  I get a matrix full of nan's. I have also tried these multiplications:  cv::Mat first = (R * trainingMat); cv::Mat first = (trainingMat.t() * R); cv::Mat first = (trainingMat.t() * trainingMat);  and in each of these cases I get a dense matrix that looks fine. I also tried to code like this:  cv::Mat first = (trainingMat.t() * R); cv::Mat sec = first * trainingMat;  and again I get a matrix full of nan's. What causes this problem? There is no division by 0 (is there !?) so why should multiplication of two dense matrices be a nan matrix? 2016-05-17 11:32:04 -0600 asked a question Logistic Regression on MNIST dataset In this post you can find a very good tutorial on how to apply SVM classifier to MNIST dataset. I was wondering if I could use logistic regression instead of SVM classifier. So I searhed for Logistic regression in openCV, And I found that the syntax for both classifiers are almost identical. So I guessed that I could just comment out these parts:  cv::Ptr svm = cv::ml::SVM::create(); svm->setType(cv::ml::SVM::C_SVC); svm->setKernel(cv::ml::SVM::POLY);//LINEAR, RBF, SIGMOID, POLY svm->setTermCriteria(cv::TermCriteria(cv::TermCriteria::MAX_ITER, 100, 1e-6)); svm->setGamma(3); svm->setDegree(3); svm->train( trainingMat , cv::ml::ROW_SAMPLE , labelsMat );  and replace it with:  cv::Ptr lr1 = cv::ml::LogisticRegression::create(); lr1->setLearningRate(0.001); lr1->setIterations(10); lr1->setRegularization(cv::ml::LogisticRegression::REG_L2); lr1->setTrainMethod(cv::ml::LogisticRegression::BATCH); lr1->setMiniBatchSize(1); lr1->train( trainingMat, cv::ml::ROW_SAMPLE, labelsMat);  But first I got this error: OpenCV Error: Bad argument(data and labels must be a floating point matrix) Then I changed cv::Mat labelsMat(labels.size(), 1, CV_32S, labelsArray);  to: cv::Mat labelsMat(labels.size(), 1, CV_32F, labelsArray);  And now I get this error: OpenCV Error: bad argument(data should have atleast two classes) I have 10 classes (0,1,...,9) but I don't know why I get this error. My codes are almost identical with the ones in the mentioned tutorial. 2016-04-22 07:40:46 -0600 commented question Contourlet transform in openCV Thats why I love computer vision, it has a pwerful backgroulnd. Well, I think I have to code it from scratch. 2016-04-22 06:50:37 -0600 commented question Contourlet transform in openCV Thank you for your help. Do you know any good source that explains contourlet transform? My problem is that everything that I have found includes lots of mathematics and no algorithm for contourlet transform. 2016-04-22 02:25:10 -0600 received badge ● Student (source) 2016-04-22 02:19:08 -0600 received badge ● Editor (source) 2016-04-22 00:40:48 -0600 asked a question Contourlet transform in openCV In this SO post you can find some good implementations for wavelet transform. I was wondering if there is any code or library for contourlet transform in OpenCV or even an algorithm that shows how to implement contourlet transform. Contourlet is very useful in edge detection problems. Since the mathematics behind contourlet is hard I couldn't implement it myself.