Exemplo n.º 1
0
void Descriptor::rotate( size_t i)
{
    // we will rotate and duplicate the i-th histogram. i generally is 0 ~ 2;
    Matrixf* pm = new Matrixf(*m_vHistPtr[i] );
    pm->clone();
    pm->rshrows( size_z() );
    m_vHistPtr.push_back( pm ); //k = 1
    for( size_t k = 2; k < size_a(); ++k ){
        Matrixf* pm = new Matrixf( *m_vHistPtr.back() );
        pm->clone();
        pm->rshrows( size_z() );
        m_vHistPtr.push_back( pm );
    }
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
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());
}
Exemplo n.º 4
0
void Descriptor::hFlip(bool duplicate)
{
    Matrixf *pm = m_vHistPtr[0];
    if( duplicate ){
        pm = new Matrixf( *m_vHistPtr[0] );
        pm->clone();
        m_vHistPtr.push_back(pm);
    }
    for( size_t z = 0; z < size_z(); ++z){
        for( size_t a = 0; a < size_a()/2; ++a){
            pm->swaprows(a * size_z() + z, ( size_a() - a -1 )* size_z() + z);
        }
    }
}