MCPcopy Create free account
hub / github.com/city-super/Scaffold-GS / buildGraphAlphaExp

Method buildGraphAlphaExp

SIBR_viewers/src/core/imgproc/MRFSolver.cpp:140–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 }
139
140 void MRFSolver::buildGraphAlphaExp(int label_iteration_id)
141 {
142 double infty = 1 << 25;
143 int num_nodes = (int)_neighborMap->size();
144 int n_nodes_estimation = num_nodes;
145 int n_edges_estimation = num_nodes * 4;
146
147 _graph = new GraphType(n_nodes_estimation, n_edges_estimation);
148
149 //add nodes associated to pixels
150 int node_id = 0;
151 for (int p = 0; p < num_nodes; p++) {
152 _graph->add_node();
153
154 if (_labels[p] == label_iteration_id) {
155 _graph->add_tweights(node_id, unaryTotal(p, label_iteration_id), infty);
156 } else {
157 _graph->add_tweights(node_id, unaryTotal(p, label_iteration_id), unaryTotal(p, _labels[p]));
158 }
159 ++node_id;
160 }
161
162 //add nodes associated to connexions between pixels
163 for (int p = 0; p < num_nodes; p++) {
164
165 std::vector<int> & neighors = (*_neighborMap)[p];
166 for (int q_id = 0; q_id < (int)neighors.size(); q_id++) {
167
168 int q = neighors[q_id];
169
170 if (p == q) { std::cerr << "!"; }
171 if (q < p) { continue; }
172
173 if (_labels[p] != _labels[q]) {
174 //extra node associated to edge {p,q}
175 _graph->add_node();
176
177 _graph->add_tweights(node_id, 0, pairwiseTotal(q, p, _labels[q], _labels[p]));
178
179 double pairwise_q_a = pairwiseTotal(q, p, _labels[q], label_iteration_id);
180 _graph->add_edge(q, node_id, pairwise_q_a, pairwise_q_a);
181
182 double pairwise_p_a = pairwiseTotal(q, p, label_iteration_id, _labels[p]);
183 _graph->add_edge(p, node_id, pairwise_p_a, pairwise_p_a);
184
185 ++node_id;
186 }
187 else
188 {
189 double pairwise_p_q = pairwiseTotal(q, p, _labels[q], label_iteration_id);
190 _graph->add_edge(q, p, pairwise_p_q, pairwise_p_q);
191 }
192 }
193 }
194
195 }
196
197 void MRFSolver::solveBinaryLabels(void)

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected