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

Function main

dependency/densecrf/examples/my_dense_inference.cpp:106–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106int main( int argc, char* argv[]){
107 if (argc<5){
108 printf("Usage: %s param image probability output\n", argv[0] );
109 return 1;
110 }
111 float w1, alpha, beta, w2, gamma;
112 int iter;
113 // read parameters from file
114 ifstream paramfile(argv[1]);
115 if(paramfile.is_open())
116 {
117 paramfile>>w1>>alpha>>beta>>w2>>gamma>>iter;
118 paramfile.close();
119 }
120 else{
121 cout<<"unable to open param file: "<<argv[1]<<endl;
122 return 0;
123 }
124 cout<<"params"<<endl;
125 cout<<"w1 "<<w1 <<endl;
126 cout<<"alpha "<<alpha<<endl;
127 cout<<"beta "<<beta <<endl;
128 cout<<"w2 "<<w2 <<endl;
129 cout<<"gamma "<<gamma<<endl;
130 cout<<"iter "<<iter<<endl;
131
132 // Number of labels
133 const int M = 2;
134 // Load the color image and some crude annotations (which are used in a simple classifier)
135 int W, H, GW, GH;
136 unsigned char * im = readPNG(argv[2], W, H, LCT_RGB);
137 if (!im){
138 printf("Failed to load image!\n");
139 return 1;
140 }
141 unsigned char * anno = readPNG( argv[3], GW, GH, LCT_GREY );
142 if (!anno){
143 printf("Failed to load annotations!\n");
144 return 1;
145 }
146 if (W!=GW || H!=GH){
147 printf("Annotation size doesn't match image!\n");
148 return 1;
149 }
150
151 /////////// Put your own unary classifier here! ///////////
152// MatrixXf unary = computeUnary( getLabeling( anno, W*H, M ), M );
153 MatrixXf unary = computeUnary(anno,W, H);
154 ///////////////////////////////////////////////////////////
155
156 // Setup the CRF model
157 DenseCRF2D crf(W, H, M);
158 // Specify the unary potential as an array of size W*H*(#classes)
159 // packing order: x0y0l0 x0y0l1 x0y0l2 .. x1y0l0 x1y0l1 ...
160 crf.setUnaryEnergy( unary );
161
162 // add a color dependent term (feature = xyrgb)
163 // x_stddev = 60

Callers

nothing calls this directly

Calls 10

readPNGFunction · 0.85
colorizeFunction · 0.85
encodeFunction · 0.85
lodepng_error_textFunction · 0.85
computeUnaryFunction · 0.70
setUnaryEnergyMethod · 0.45
addPairwiseBilateralMethod · 0.45
addPairwiseGaussianMethod · 0.45
mapMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected