Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/133.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 聚类与点关联_C++_Algorithm_Computer Vision - Fatal编程技术网

C++ 聚类与点关联

C++ 聚类与点关联,c++,algorithm,computer-vision,C++,Algorithm,Computer Vision,我正在使用DBScan算法对一组点进行聚类。我有一组点的ID,还有一组簇,每个簇都有一组点。 我想在集群和点ID之间建立关联 例如,我有一组ID{1,2,3,4},现在如果我有两个簇,两个簇有两个点,那么第一个簇的这两个点应该有ID 1,2,第二个簇的ID为3,4。另外,如果我有4个簇,每个簇有一个点,那么这些点的ID应该是1、2、3和4。此外,如果我有两个簇,但一个簇有3个点,另一个簇有一个点,那么第一个簇的点的ID应该是1,2,3,第二个簇的点的ID应该是4 我试图编写代码,但我在计算公式以

我正在使用DBScan算法对一组点进行聚类。我有一组点的ID,还有一组簇,每个簇都有一组点。 我想在集群和点ID之间建立关联

例如,我有一组ID{1,2,3,4},现在如果我有两个簇,两个簇有两个点,那么第一个簇的这两个点应该有ID 1,2,第二个簇的ID为3,4。另外,如果我有4个簇,每个簇有一个点,那么这些点的ID应该是1、2、3和4。此外,如果我有两个簇,但一个簇有3个点,另一个簇有一个点,那么第一个簇的点的ID应该是1,2,3,第二个簇的点的ID应该是4

我试图编写代码,但我在计算公式以实现该场景时停了下来

std::vector<int>_IDs;
 // for each cluster
    for( int j = 0; j<clusters.size();j++ ) 
    {
         // for each point in that cluster
        for ( int i=0; i < clusters[j].m_Points.size(); i++)
        {
  // assign its ID from the _IDs array based and save it in Clusters Vector
            clusters[j].m_IDs.push_back(_IDs[j+ i*clusters[j].m_Points.size()]); 

        }
    }
std::vector\u id;
//对于每个集群

对于(int j=0;j,我会这样写:

std::vector<int>_IDs; // those come in from wherever
std::vector<int>::const_iterator id = _IDs.begin();

// for each cluster
for( int j = 0; j<clusters.size(); ++j ) 
{
     // for each point in that cluster
    for ( int i=0; i < clusters[j].m_Points.size(); i++)
    {
        // some external logic should take care that there are enough ids
        // for all points in clusters. sanity check it here. 
        assert(id != _IDs.end());

        // assign its ID from the _IDs array based and save it in Clusters Vector
        clusters[j].m_IDs.push_back(*id); 
        ++id;
    }
}
std::vector_IDs;//它们来自任何地方
std::vector::const_迭代器id=_id.begin();
//对于每个集群
对于(int j=0;j