Example #1
0
void BipartiteDenseCRF::map ( int n_iterations, short* result1, short* result2, float relax ) {
	// Run inference
	float * prob[2];
	runInference( n_iterations, prob, relax );
	dense_crfs_[0]->currentMap( result1 );
	dense_crfs_[1]->currentMap( result2 );
}
Example #2
0
void DenseCRF::inference ( int n_iterations, float* result, float relax ) {
	// Run inference
	float * prob = runInference( n_iterations, relax );
	// Copy the result over
	for( int i=0; i<N_; i++ )
		memcpy( result+i*M_, prob+i*M_, M_*sizeof(float) );
}
Example #3
0
///////////////////////
/////  Inference  /////
///////////////////////
void BipartiteDenseCRF::inference ( int n_iterations, float* result1, float* result2, float relax ) {
	// Run inference
	float * prob[2];
	runInference( n_iterations, prob, relax );
	// Copy the result over
	float* r[2] = {result1, result2};
	for( int k=0; k<2; k++ )
		for( int i=0; i<N_[k]; i++ )
			memcpy( r[k]+i*M_, prob[k]+i*M_, M_*sizeof(float) );
}
Example #4
0
void
pcl::DenseCrf::mapInference (int n_iterations, std::vector<int> &result, float relax)
{
  // Start inference
  // Initialize using the unary energies
  expAndNormalize (current_, unary_, -1);

  for (int i = 0; i < n_iterations; i++)
  {
    runInference (relax);
    std::cout << "iteration: " << i+1 << " - DONE" << std::endl;
  }

  // Find the map
  for (int i = 0; i < N_; i++)
  {
    const int prob_idx = i * M_;
    // Find the max
    float p_label = current_[prob_idx];
    int idx = 0;
    for (int j = 1; j < M_; j++) 
    { 
      if (p_label < current_[prob_idx + j])
      {
        p_label = current_[prob_idx + j];
        idx = j;
      }
    }
    result[i] = idx;
  }
  


/*
	for( int i = 0; i < N_; i++ ){
		const float * p = prob + i*M_;
		// Find the max and subtract it so that the exp doesn't explode
		float mx = p[0];
		int imx = 0;
		for( int j=1; j<M_; j++ )
			if( mx < p[j] ){
				mx = p[j];
				imx = j;
			}
    result[i] = imx
  }
*/

}
Example #5
0
void
pcl::DenseCrf::inference (int n_iterations, std::vector<float> &result, float relax)
{
  // Start inference
  // Initialize using the unary energies
  expAndNormalize (current_, unary_, -1);

  for (int i = 0; i < n_iterations; i++)
  {
    runInference (relax);
    std::cout << "iteration: " << i+1 << " - DONE" << std::endl;
  }
  
  // Copy the data into the result vector
  result = current_;
}
void DenseCRF::map ( int n_iterations, short* result, float relax ) {
	// Run inference
	prob = runInference( n_iterations, relax );
	
	// Find the map
	for( int i=0; i<N_; i++ ){
		const float * p = prob + i*M_;
		// Find the max probability in all the probability maps and only preserve the 
		float mx = p[0];
		int imx = 0;
		for( int j=1; j<M_; j++ )  
			if( mx < p[j] ){
				mx = p[j];
				imx = j;
			}
		result[i] = imx;
	}
}
Example #7
0
void DenseCRF::map ( int n_iterations, short* result, float relax ) {
	// Run inference
	float * prob = runInference( n_iterations, relax );
	
	// Find the map
	for( int i=0; i<N_; i++ ){
		const float * p = prob + i*M_;
		// Find the max and subtract it so that the exp doesn't explode
		float mx = p[0];
		int imx = 0;
		for( int j=1; j<M_; j++ )
			if( mx < p[j] ){
				mx = p[j];
				imx = j;
			}
		result[i] = imx;
	}
}