Skip to content

Commit

Permalink
Agglomerate an exact copy of a reference segmentation
Browse files Browse the repository at this point in the history
Set the agglomerate threshold to 0, but reject any merger below the
input threshold unless the two parts have the same semantic id, which is
specified by the reference segmentation.
  • Loading branch information
ranlu committed Sep 30, 2024
1 parent 0094286 commit 7852296
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/agg/mean_aggl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,36 +692,36 @@ inline agglomeration_output_t<T> agglomerate_cc(agglomeration_data_t<T, Compare>
continue;
}

if (!comp(e.edge->w, sem_aff_threshold)) {
if (!sem_counts.empty()){
if (!sem_can_merge(sem_counts[v0],sem_counts[v1],sem_params)) {
output.sem_rg_vector.push_back(*(e.edge));
e.edge->w = Limits::min();
continue;
}
}
}

if (!comp(e.edge->w, size_aff_threshold)) {
size_t size0 = seg_size[v0];
size_t size1 = seg_size[v1];
auto p = std::minmax({size0, size1});
if (p.first > size_params.small_voxel_threshold and (size0+size1) > size_params.large_voxel_threshold) {
output.rej_rg_vector.push_back(*(e.edge));
if (!sem_counts.empty()){
if ((!comp(e.edge->w, sem_aff_threshold) and (sem_counts[v0][0] == 0 or sem_counts[v1][0] == 0)) or (sem_counts[v0][0] != sem_counts[v1][0])) {
output.sem_rg_vector.push_back(*(e.edge));
e.edge->w = Limits::min();
continue;
}
}

if (!comp(e.edge->w, backbone_threshold)){
if (sem_counts.empty() or sem_counts[v0][0] == 0 or sem_counts[v1][0] == 0) {
size_t size0 = seg_size[v0];
size_t size1 = seg_size[v1];
auto p = std::minmax({size0, size1});
if ((p.first > twig_params.voxel_threshold) or (e.edge->w.num > twig_params.area_threshold)) {
e.edge->w = Limits::min();
continue;
if (!comp(e.edge->w, size_aff_threshold)) {
if (p.first > size_params.small_voxel_threshold and (size0+size1) > size_params.large_voxel_threshold) {
output.rej_rg_vector.push_back(*(e.edge));
e.edge->w = Limits::min();
continue;
}
}

if (!comp(e.edge->w, backbone_threshold)){
size_t size0 = seg_size[v0];
size_t size1 = seg_size[v1];
auto p = std::minmax({size0, size1});
if ((p.first > twig_params.voxel_threshold) or (e.edge->w.num > twig_params.area_threshold)) {
e.edge->w = Limits::min();
continue;
}
output.twig_rg_vector.push_back(*(e.edge));
}
output.twig_rg_vector.push_back(*(e.edge));
}
#ifdef FINAL
if (incident[v0].size() < incident[v1].size()) {
Expand Down Expand Up @@ -918,7 +918,8 @@ inline void agglomerate(const char * rg_filename, const char * fs_filename, cons
{
Compare comp;

auto th = params.input_aff_threshold - params.twig_params.aff_threshold_delta;
params.sem_params.aff_threshold = params.input_aff_threshold;
auto th = 0.0;

T const final_threshold = T(th,1);

Expand Down

0 comments on commit 7852296

Please sign in to comment.