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

Method pairwiseEnergy

dependency/densecrf/src/densecrf.cpp:154–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152 return r;
153}
154VectorXf DenseCRF::pairwiseEnergy(const VectorXs & l, int term) {
155 assert( l.cols() == N_ );
156 VectorXf r( N_ );
157 r.fill(0.f);
158
159 if( term == -1 ) {
160 for( unsigned int i=0; i<pairwise_.size(); i++ )
161 r += pairwiseEnergy( l, i );
162 return r;
163 }
164
165 MatrixXf Q( M_, N_ );
166 // Build the current belief [binary assignment]
167 for( int i=0; i<N_; i++ )
168 for( int j=0; j<M_; j++ )
169 Q(j,i) = (l[i] == j);
170 pairwise_[ term ]->apply( Q, Q );
171 for( int i=0; i<N_; i++ )
172 if ( 0 <= l[i] && l[i] < M_ )
173 r[i] =-0.5*Q(l[i],i );
174 else
175 r[i] = 0;
176 return r;
177}
178MatrixXf DenseCRF::startInference() const{
179 MatrixXf Q( M_, N_ );
180 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