解释这个算法(比较SURF算法中的点)

Explain this algorithm (Compare points in SURF algorithm)

本文关键字:算法 SURF 比较 解释      更新时间:2023-10-16

我需要知道这个算法是否是已知的:

void getMatches(IpVec &ipts1, IpVec &ipts2, IpPairVec &matches, float ratio) {
    float dist, d1, d2;
    Ipoint *match;
    matches.clear();
    for (unsigned int i = 0; i < ipts1.size(); i++) {
        d1 = d2 = FLT_MAX;
        for (unsigned int j = 0; j < ipts2.size(); j++) {
            dist = ipts1[i] - ipts2[j];
            if (dist < d1) // if this feature matches better than current best
            {
                d2 = d1;
                d1 = dist;
                match = &ipts2[j];
            } else if (dist < d2) // this feature matches better than second best
            {
                d2 = dist;
            }
        }
        // If match has a d1:d2 ratio < 0.65 ipoints are a match
        if (d1 / d2 < ratio) {
            // Store the change in position
            ipts1[i].dx = match->x - ipts1[i].x;
            ipts1[i].dy = match->y - ipts1[i].y;
            matches.push_back(std::make_pair(ipts1[i], *match));
        }
    }
}

class Ipoint {
public:
    //! Destructor
    ~Ipoint() {
    };
    //! Constructor
    Ipoint() : orientation(0) {
    };
    //! Gets the distance in descriptor space between Ipoints
    float operator-(const Ipoint &rhs) {
        float sum = 0.f;
        for (int i = 0; i < 64; ++i) {
            //std::cout << i << "n";
            try {
                sum += (this->descriptor[i] - rhs.descriptor[i])*(this->descriptor[i] - rhs.descriptor[i]);
            } catch (char *str) {
                std::cout << "Caught some other exception: " << str << "n";
            }
        }
        return sqrt(sum);
    };
    //! Coordinates of the detected interest point
    float x, y;
    //! Detected scale
    float scale;
    //! Orientation measured anti-clockwise from +ve x-axis
    float orientation;
    //! Sign of laplacian for fast matching purposes
    int laplacian;
    //! Vector of descriptor components
    float descriptor[64];
    //! Placeholds for point motion (can be used for frame to frame motion analysis)
    float dx, dy;
    //! Used to store cluster index
    int clusterIndex;
};

比较SURF算法的结果。

    这是最近邻算法吗?这看起来就像函数在搜索每个点的最近点。
  1. 我可以做同样的使用四叉树或kd-tree?
  2. 有一个更好的算法来比较图像点,知道它们是相同的还是相似的?
  3. 优选我想将它们存储到mysql中,并构建一个kd-树来比较1图像通过所有图像,这是可能的吗?
  4. RANSAC在这个任务中是有用的吗?
  5. 有办法捕捉假阳性吗?

你问了很多问题,我想我不能回答所有的问题,但这里是我尽可能多地回答你的问题。

  1. 这无疑是一个最近邻算法,其目标是在第一个向量中找到最接近每个点的两个点,然后检查它们的距离之比是否小于某个截止值。

  2. 可以使用四叉树或kd-树来完成此操作,但由于您的点都是一维值,因此使用平衡二叉搜索树可以做得更好。给定这样一棵树,如果您将链表贯穿节点,您可以通过查找二叉搜索树中最近的元素p来找到某个测试点p的k个最近邻居,然后在每个方向上遍历(k + 1)步,并取您找到的k个最近点。它的运行时间为O(lgn + k),其中n是点的个数,k如上所述。这比您现在使用的方法要有效得多,因为现在的方法每次查找需要花费O(n)时间。

    如果你的特征向量的维数大于1,但小于20,那么使用kd-trees将是一个非常有效的度量。

    对于高维,您可能希望在应用kd-tree之前使用PCA减少维数,或者使用更具可扩展性的ANN结构,例如位置敏感散列。

  3. SURF最适合场景和目标检测。如果需要确定两个图像是否相同,那么使用全局描述符算法(如GIST)会做得更好。使用全局描述符的优点是,您可以获得整个图像的单个矢量,并且可以使用简单的欧几里德距离进行图像比较。

  4. 你绝对可以用MySQL做这个,因为你不需要一个kd-tree。一个简单的平衡二叉树就足够了。

  5. RANSAC是一种对异常值具有鲁棒性的模型参数估计方法。使用SURF功能将多张照片组合成3D场景非常有用。

  6. 检查误报绝对是一种机器学习练习,我在这方面没有受过很好的训练。你可能会使用监督学习算法(如SVM、增强决策树或神经网络)来做到这一点,但我知道的不够多,无法在这方面给你建议。

希望这对你有帮助!

我只回答5,因为templatetypedef解决了其余的问题。RANSAC是一种参数估计方法(有点像找到一组数据点的最佳拟合线)。所以它不能直接用于最近邻搜索