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
But then I have problems in implementing the last trasformation
ZCAMatrix = np.dot(U, np.dot(np.diag(1.0/np.sqrt(S + epsilon)), U.T))
Can someone help?