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

Function dense_crf_inference

densecrf_python/densecrf_core.cpp:21–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21VectorXs dense_crf_inference(const unsigned char * img, const float * prob, int H, int W, int C, CRFParam param)
22{
23 MatrixXf unary = computeUnary(prob, H, W, C);
24
25 // Setup the CRF model
26 DenseCRF2D crf(W, H, C);
27 // Specify the unary potential as an array of size W*H*(#classes)
28 // packing order: x0y0l0 x0y0l1 x0y0l2 .. x1y0l0 x1y0l1 ...
29 crf.setUnaryEnergy( unary );
30
31 // add a color dependent term (feature = xyrgb)
32 // x_stddev = 60
33 // y_stddev = 60
34 // r_stddev = g_stddev = b_stddev = 20
35 // weight = 10
36 crf.addPairwiseBilateral(param.alpha, param.alpha, param.beta, param.beta, param.beta, img, new PottsCompatibility( param.w1 ) );
37
38 // add a color independent term (feature = pixel location 0..W-1, 0..H-1)
39 // x_stddev = 3
40 // y_stddev = 3
41 // weight = 3
42 crf.addPairwiseGaussian( param.gamma, param.gamma, new PottsCompatibility( param.w2 ) );
43
44 // Do map inference
45 // MatrixXf Q = crf.startInference(), t1, t2;
46 // printf("kl = %f\n", crf.klDivergence(Q) );
47 // for( int it=0; it<5; it++ ) {
48 // crf.stepInference( Q, t1, t2 );
49 // printf("kl = %f\n", crf.klDivergence(Q) );
50 // }
51 // VectorXs map = crf.currentMap(Q);
52 VectorXs map = crf.map(param.iter);
53 return map;
54}

Callers 1

densecrf_wrapperFunction · 0.85

Calls 5

computeUnaryFunction · 0.70
setUnaryEnergyMethod · 0.45
addPairwiseBilateralMethod · 0.45
addPairwiseGaussianMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected