Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

ZCA implementation in java

$
0
0
Hello everyone, I'm trying to implement ZCA Whitening algorithm like shown here: http://stackoverflow.com/questions/31528800/how-to-implement-zca-whitening-python/38590790#38590790 with opencv in Scala (using Java api) but I cannot find the most of the functions used there (phython with numpy). So far I tried with this: //Covariance matrix val covar, mean = new Mat() Core.calcCovarMatrix(input, covar, mean, Core.COVAR_NORMAL | Core.COVAR_ROWS) Core.divide(covar, new Scalar(input.rows - 1), covar) //Singular Value Decomposition val w, u, vt = new Mat() Core.SVDecomp(covar, w, u, vt) //#Whitening constant, it prevents division by zero val epsilon = 1e-5 To implement the last trasformation ZCAMatrix = np.dot(U, np.dot(np.diag(1.0/np.sqrt(S + epsilon)), U.T)) I tried with: var ZCAMatrix = new Mat Core.add(w, new Scalar(epsilon), ZCAMatrix) Core.sqrt(ZCAMatrix, ZCAMatrix) Core.divide(1.0, ZCAMatrix, ZCAMatrix) Core.gemm(Mat.diag(ZCAMatrix), u.t, 1, new Mat, 0, ZCAMatrix) Core.gemm(ZCAMatrix, u, 1, new Mat, 0, ZCAMatrix) The result of thei transformation is: ![this](/upfiles/14731727407767715.jpg) which is not exactly what it's supposed to be. Can someone help?

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>