Пример #1
0
float  difference(const Descriptor* desc1, const Descriptor* desc2, Descriptor& desc, float (*diff) (float, float) )
{
    // assuming desc is valid
    if( desc2 == 0){
        desc.clear();
        desc.m_na = desc1->size_a();
        desc.m_nz = desc1->size_z();
        desc.m_nr = desc1->size_r();
        Matrixf *pm = new Matrixf( * desc1->getPage(0)  );
        pm->clone();
        desc.m_vHistPtr.push_back(pm);
        return 0.0f;
    }
    else if( desc1 == desc2 ){
        desc.clear();
        desc.m_na = desc1->size_a();
        desc.m_nz = desc1->size_z();
        desc.m_nr = desc1->size_r();
        Matrixf *pm = new Matrixf( desc.m_na * desc.m_nz, desc.m_nr  );
        pm->setAllZeros();
        desc.m_vHistPtr.push_back(pm);
        return 0.0f;
    }
    else
        return difference(*desc1, *desc2, desc, diff);
}
Пример #2
0
float difference(const Descriptor & desc1, const Descriptor & desc2, Descriptor& desc, float (*diff) (float, float) ){
    size_t idx = 0;
    float mindiff = inf;
    size_t height = desc1.height();
    size_t width = desc1.width();
    float sum;
    for( size_t k = 0; k < desc1.page(); ++k)
    { // k: page # of flipped/rotated descriptors
        sum = 0.0f;
        for( size_t i = 0; i < height; ++i){ //i, iterates all zenith and azimuth angle bins
            for( size_t j = 0; j < width; ++j) //j iterates all radius bins
                sum += diff( desc1(i, j, 0), desc2(i,j, k));
        }
        if( mindiff > sum){
            idx = k;
            mindiff = sum;
        }
    }
    desc.clear();
    Matrixf *pm = new Matrixf( *desc2.getPage( idx ) );
    pm->clone();
    *pm -= *desc1.getPage(0);
  //  pm->getAbsoluteValue();
    desc.m_vHistPtr.push_back( pm );
    desc.m_na = desc1.size_a();
    desc.m_nz = desc1.size_z();
    desc.m_nr = desc1.size_r();
    return mindiff / (desc1.sumWeight() + desc2.sumWeight());
}