opencv calculate matrix rank

2020-04-16 18:54发布

I am trying to find rank of a matrix. In matlab this is fairly straight-forward but I am using visual studio 2008 (c++). I recently installed openCV and it works for most of my matrix arithmetic so far except I can't figure out how to use openCV to get rank of a matrix. In my research online I found that apparently cvSVD can give me rank http://www.emgu.com/wiki/files/1.3.0.0/html/55d6f4d2-223d-8c55-2770-2b6a9c6eefa2.htm

But I have no idea how cvSVD will return this particular property. Any ideas on getting matrix rank from openCV???

Thanks.

1条回答
Juvenile、少年°
2楼-- · 2020-04-16 19:31

Read the following

http://en.wikipedia.org/wiki/Singular_value_decomposition#Applications_of_the_SVD

in the section Range, null space and rank it explains how to get the Rank from the singular values. Quoting this page:

As a consequence, the rank of M equals the number of non-zero singular value

So basically you can count the number of non-zero singular values and that is the rank. According to the link you provide in the question, your SVD calculation function in opencv should return you a matrix or vector of singular values - if it is a matrix, the singular values lie on the main diagonal of this matrix. From here you should be ok. There may be a simpler way, but I am not familiar with opencv.

查看更多
登录 后发表回答