gpt4 book ai didi

c++ - 用 dft 粗略估计质心

转载 作者:行者123 更新时间:2023-11-28 06:40:15 25 4
gpt4 key购买 nike

我想要质心的坐标并且我已经计算了 DFT(用于不同的目的)。我看过一些幻灯片,暗示可以通过查看矩阵的第一个值来粗略估计质心。代码基于:http://docs.opencv.org/doc/tutorials/core/discrete_fourier_transform/discrete_fourier_transform.html

cv::dft(complexI, complexI);
// compute the magnitude and switch to logarithmic scale
// => log(1 + sqrt(Re(DFT(I))^2 + Im(DFT(I))^2))
cv::split(complexI, planes); // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
double x = (double)planes[0].at<int>(0,0)/INT_MAX;
double y = ABS(((double)planes[1].at<int>(0,0)/INT_MAX));

但是每次 y 值变为 0 时。x 值似乎是正确的。我错过了什么吗?

最佳答案

这通常使用 moments 来完成.

关于c++ - 用 dft 粗略估计质心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26102432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com