INNER CODE UNIT · C++
b
lucasb-eyer/pydensecrf · pydensecrf/densecrf/src/densecrf.cpp:103
b = b.array().exp();
out.col(i) = b / b.array().sum();
}
}
void sumAndNormalize( MatrixXf & out, const MatrixXf & in, const MatrixXf & Q ) {
out.resize( in.rows(), in.cols() );
for( int i=0; i<in.cols(); i++ ){
VectorXf b = in.col(i);
VectorXf q = Q.col(i);
out.col(i) = b.array().sum()*q - b;
}
}
MatrixXf DenseCRF::inference ( int n_iterations ) const {
MatrixXf Q( M_, N_ ), tmp1, unary( M_, N_ ), tmp2;
unary.fill(0);
if( unary_ )
unary = unary_->get();
expAndNormalize( Q, -unary );