OpenCV PCA Compute in Python

前端 未结 2 503
半阙折子戏
半阙折子戏 2020-12-31 14:35

I\'m loading a set of test images via OpenCV (in Python) which are 128x128 in size, reshape them into vectors (1, 128x128) and put them all together in a matrix to calculate

相关标签:
2条回答
  • 2020-12-31 15:07

    You can also put

    cv.PCACompute(matrix_test, mean = np.array([]))
    

    and the function computes the mean.

    0 讨论(0)
  • 2020-12-31 15:22

    I think the problem is with the size of

    np.mean(matrix_test, axis=0)
    

    Its size is (128x128,) and not (1, 128x128). Thus the code below should work

    mean, eigenvectors = cv.PCACompute(matrix_test, np.mean(matrix_test, axis=0).reshape(1,-1))
    
    0 讨论(0)
提交回复
热议问题