Beispiel #1
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());
}
Beispiel #2
0
float distance(const Descriptor &desc1, const Descriptor &desc2, float (*diff) (float, float) ){
    // assuming they are comparable
 //   float mindiff = inf;
    size_t height = desc1.height();
    size_t width = desc1.width();
    vector<float> sum( desc1.page(), 0.0f);
    for( size_t k = 0; k < desc1.page(); ++k)
    { // k: page # of flipped/rotated descriptors
            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[k] += diff( desc1(i, j, 0), desc2(i,j, k));
            }
      //      mindiff = min( sum[k], mindiff);
    }
    return *std::min_element(sum.begin(), sum.end()) /( desc1.sumWeight()+desc2.sumWeight());
}
Beispiel #3
0
float distance2( const Descriptor & desc1, const Descriptor & desc2, float (*diff) (float, float) ){
        if( is_comparable2( desc1, desc2))
		return -1.0f;
	// check comparability before calling this function;
	size_t ns = min( desc1.width(), desc2.width());
	size_t nl = max( desc1.width(), desc2.width());
	const Descriptor& desc_longer = desc1.width() > desc2.width() ? desc1 : desc2;
	const Descriptor& desc_shorter = desc1.width() > desc2.width() ? desc2 : desc1;
	vector<float> sum( desc1.page(), 0.0f);
//	float mindiff = inf;
	size_t height = desc1.height();
	for( size_t k = 0; k < desc1.page(); ++k)
	{ // k: page # of rotated descriptors
		for( size_t i = 0; i < height; ++i){ //i, iterates all zenith and azimuth angle bins
			size_t j = 0;
			for( ; j < ns; ++j) //j iterates all radius bins
                                sum[k] += diff( desc_longer(i, j, 0), desc_shorter(i,j, k));
			for( ; j < nl; ++j)
                                sum[k] += diff( desc_longer(i, j, 0 ), 0);
		}
        //	mindiff = min( sum[k], mindiff);
	}
        return *std::min_element(sum.begin(), sum.end()) / (desc1.sumWeight() + desc2.sumWeight() );
}