MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / pairwiseEnergy

Method pairwiseEnergy

dependency/densecrf3d/src/densecrf.cpp:249–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247 return r;
248}
249VectorXf DenseCRF::pairwiseEnergy(const VectorXs & l, int term) {
250 assert( l.cols() == N_ );
251 VectorXf r( N_ );
252 r.fill(0.f);
253
254 if( term == -1 ) {
255 for( unsigned int i=0; i<pairwise_.size(); i++ )
256 r += pairwiseEnergy( l, i );
257 return r;
258 }
259
260 MatrixXf Q( M_, N_ );
261 // Build the current belief [binary assignment]
262 for( int i=0; i<N_; i++ )
263 for( int j=0; j<M_; j++ )
264 Q(j,i) = (l[i] == j);
265 pairwise_[ term ]->apply( Q, Q );
266 for( int i=0; i<N_; i++ )
267 if ( 0 <= l[i] && l[i] < M_ )
268 r[i] =-0.5*Q(l[i],i );
269 else
270 r[i] = 0;
271 return r;
272}
273MatrixXf DenseCRF::startInference() const{
274 MatrixXf Q( M_, N_ );
275 Q.fill(0);

Callers

nothing calls this directly

Calls 4

colsMethod · 0.45
fillMethod · 0.45
sizeMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected