MCPcopy Create free account
hub / github.com/davisking/dlib / brute_force_potts_grid_problem

Function brute_force_potts_grid_problem

dlib/test/graph_cuts.cpp:858–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

856
857 template <typename prob_type>
858 void brute_force_potts_grid_problem(
859 const prob_type& prob,
860 array2d<unsigned char>& labels
861 )
862 {
863 const unsigned long num = (unsigned long)std::pow(2.0, (double)prob.nr()*prob.nc());
864
865 array2d<unsigned char> temp(prob.nr(), prob.nc());
866 unsigned char* data = &temp[0][0];
867
868 double best_score = -std::numeric_limits<double>::infinity();
869 for (unsigned long i = 0; i < num; ++i)
870 {
871 for (unsigned long j = 0; j < temp.size(); ++j)
872 {
873 unsigned long T = (1)<<j;
874 T = (T&i);
875 if (T != 0)
876 *(data + j) = SINK_CUT;
877 else
878 *(data + j) = SOURCE_CUT;
879 }
880
881
882 double score = potts_model_score(prob, temp);
883 if (score > best_score)
884 {
885 best_score = score;
886 assign_image(labels, temp);
887 }
888 }
889 }
890
891 void test_inf()
892 {

Callers 1

perform_testMethod · 0.85

Calls 5

potts_model_scoreFunction · 0.85
assign_imageFunction · 0.50
nrMethod · 0.45
ncMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected