| 208 | } |
| 209 | } |
| 210 | MatrixXf DenseCRF::inference ( int n_iterations ) const { |
| 211 | MatrixXf Q( M_, N_ ), tmp1, unary( M_, N_ ), tmp2; |
| 212 | unary.fill(0); |
| 213 | if( unary_ ) |
| 214 | unary = unary_->get(); |
| 215 | expAndNormalize( Q, -unary ); |
| 216 | |
| 217 | for( int it=0; it<n_iterations; it++ ) { |
| 218 | tmp1 = -unary; |
| 219 | for( unsigned int k=0; k<pairwise_.size(); k++ ) { |
| 220 | pairwise_[k]->apply( tmp2, Q ); |
| 221 | tmp1 -= tmp2; |
| 222 | } |
| 223 | expAndNormalize( Q, tmp1 ); |
| 224 | } |
| 225 | return Q; |
| 226 | } |
| 227 | VectorXs DenseCRF::map ( int n_iterations ) const { |
| 228 | // Run inference |
| 229 | MatrixXf Q = inference( n_iterations ); |