################################################################################ # # # Software for Efficiently Solving Multi-Label MRFs/CRFs # # Version 1.0 # # # # Karteek Alahari Pushmeet Kohli Philip H. S. Torr # # # ################################################################################ EXAMPLE We explain the usage with the stereo computation problem as an example. Tsukuba stereo pair (courtesy of the University of Tsukuba) and the corresponding unary costs are available in images/ a. Write code to initialize the energy parameters (unary and pairwise terms) in image::image(char*, int). See the comments in image.cpp for the variables to be initialised. // Example code to add in image::image(char*, int) int truncation=1, lambda=20; int i, j, k, l, ti, tj; int pair_id; FILE* fp; eng = new Energy(num_labels, truncation); eng->nvar = num_nodes; eng->npair= 2*width*height - (width+height); eng->allocateMemory(); fp = fopen("images/datacost.txt", "r"); for(k=0; kunaryCost[i*width+j][k])); } fclose(fp); pair_id = 0; for(i=0; ipairCost[pair_id] = lambda; eng->pairIndex[pair_id][0] = k; eng->pairIndex[pair_id][1] = k-1; pair_id++; } for(i=1; ipairCost[pair_id] = lambda; eng->pairIndex[pair_id][0] = k; eng->pairIndex[pair_id][1] = k-width; pair_id++; } b. Create an image object using a ppm file: image* Image = image("file.ppm", number_of_labels); pgm files are also supported. Change image::image(char*, int) accordingly. // Example Image = new image("images/tsukuba_l.ppm", num_labels); c. Solve the energy function Image -> kovtun(); // Compute the partially optimal solution only Image -> kovtun(true); // Compute the partially optimal solution and // solve the remaining nodes using alpha expansion. Image -> trw(); // Compute standard TRW/BP solutions. Image -> trw(true); // Compute the partially optimal solution and // solve the remaining nodes using TRW/BP. d. Write your own method to save the result, eg. image::save_disparity(); // Example void image::save_disparity(const char *file) { int i, j; unsigned char lbl; unsigned char disp; for(i=0; i