From: Philipp Wagner Date: Thu, 31 May 2012 20:27:46 +0000 (+0000) Subject: Fixed reconstruction, so that the mean is correctly added to the reconstructed image. X-Git-Tag: accepted/2.0/20130307.220821~479 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0bd287a8f244dda4102530546085b41acaf392ed;p=profile%2Fivi%2Fopencv.git Fixed reconstruction, so that the mean is correctly added to the reconstructed image. --- diff --git a/modules/contrib/src/lda.cpp b/modules/contrib/src/lda.cpp index f37346f..5983530 100644 --- a/modules/contrib/src/lda.cpp +++ b/modules/contrib/src/lda.cpp @@ -185,21 +185,16 @@ Mat subspaceReconstruct(InputArray _W, InputArray _mean, InputArray _src) Mat W = _W.getMat(); Mat mean = _mean.getMat(); Mat src = _src.getMat(); - // get number of samples and dimension + // get number of samples int n = src.rows; - int d = src.cols; // initalize temporary matrices Mat X, Y; // copy data & make sure we are using the correct type src.convertTo(Y, W.type()); // calculate the reconstruction - gemm(Y, - W, - 1.0, - ((size_t)d == mean.total()) ? repeat(mean.reshape(1,1), n, 1) : Mat(), - ((size_t)d == mean.total()) ? 1.0 : 0.0, - X, - GEMM_2_T); + gemm(Y, W, 1.0, Mat(), 0.0, X, GEMM_2_T); + if(mean.total() == (size_t) X.cols) + add(X, repeat(mean.reshape(1,1), n, 1), X); return X; }