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

Function dense_crf_wrapper

densecrf_python/densecrf3d.cpp:13–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13static PyObject *
14dense_crf_wrapper(PyObject *self, PyObject *args)
15{
16 PyObject *I=NULL, *P=NULL, *param=NULL, *BilateralModsStds=NULL;
17 PyArrayObject *arr_I=NULL, *arr_P=NULL;
18
19 if (!PyArg_ParseTuple(args, "OOO", &I, &P, &param)) return NULL;
20
21 arr_I = (PyArrayObject*)PyArray_FROM_OTF(I, NPY_UINT8, NPY_IN_ARRAY);
22 if (arr_I == NULL) return NULL;
23
24 arr_P = (PyArrayObject*)PyArray_FROM_OTF(P, NPY_FLOAT32, NPY_IN_ARRAY);
25 if (arr_P == NULL) return NULL;
26
27
28 /*vv* code that makes use of arguments *vv*/
29
30 int nd_I = PyArray_NDIM(arr_I); //number of dimensions
31 int nd_P = PyArray_NDIM(arr_P);
32 if(nd_I != nd_P)
33 {
34 cerr<<"data dimension "<<nd_I<<" probability dimension "<<nd_P<<" do not match"<<endl;
35 return NULL;
36
37 }
38 npy_intp * shape_I = PyArray_DIMS(arr_I); // npy_intp array of length nd showing length in each dim.
39 npy_intp * shape_P = PyArray_DIMS(arr_P);
40#ifdef DEBUG
41 cout<<"input data shape: ";
42 for(int i=0; i<nd_I; i++)
43 {
44 cout<<shape_I[i]<<" ";
45 }
46 cout<<std::endl;
47 cout<<"input probability shape: ";
48 for(int i=0; i<nd_P; i++)
49 {
50 cout<<shape_P[i]<<" ";
51 }
52 cout<<std::endl;
53#endif
54 for(int i=0; i<nd_I-1; i++)
55 {
56 if(shape_I[i] !=shape_P[i] || shape_I[i]!=shape_P[i])
57 {
58 cerr<<"input shape does not match"<<endl;
59 return NULL;
60 }
61 }
62
63 double MaxIterations = PyFloat_AsDouble(PyDict_GetItemString(param, "MaxIterations"));
64 double PosRStd = PyFloat_AsDouble(PyDict_GetItemString(param, "PosRStd"));
65 double PosCStd = PyFloat_AsDouble(PyDict_GetItemString(param, "PosCStd"));
66 double PosZStd = PyFloat_AsDouble(PyDict_GetItemString(param, "PosZStd"));
67 double PosW = PyFloat_AsDouble(PyDict_GetItemString(param, "PosW"));
68 double BilateralRStd = PyFloat_AsDouble(PyDict_GetItemString(param, "BilateralRStd"));
69 double BilateralCStd = PyFloat_AsDouble(PyDict_GetItemString(param, "BilateralCStd"));
70 double BilateralZStd = PyFloat_AsDouble(PyDict_GetItemString(param, "BilateralZStd"));

Callers

nothing calls this directly

Calls 7

addPairwiseBilateralFunction · 0.85
logFunction · 0.50
resizeMethod · 0.45
setUnaryEnergyMethod · 0.45
addPairwiseGaussianMethod · 0.45
inferenceMethod · 0.45
currentMapMethod · 0.45

Tested by

no test coverage detected