Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions active_plugins/enforceobjectsonetoone.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,18 @@ def run(self, workspace):
workspace.display_data.statistics = []

pre_primary = workspace.object_set.get_objects(self.x_name.value)

pre_primary_seg = pre_primary.segmented

pre_secondary = workspace.object_set.get_objects(self.y_name.value)

pre_secondary_seg = pre_secondary.segmented

primary_seg = self.enforce_unique(pre_primary_seg, pre_secondary_seg, erode_excess=True)

secondary_seg = self.enforce_unique(pre_secondary_seg, primary_seg)
if pre_secondary.count == 0:
primary_seg = secondary_seg = pre_secondary_seg
elif pre_primary.count == 0:
secondary_seg = primary_seg = pre_primary_seg
else:
primary_seg = self.enforce_unique(pre_primary_seg, pre_secondary_seg, erode_excess=True)
secondary_seg = self.enforce_unique(pre_secondary_seg, primary_seg)

if not numpy.array_equal(numpy.unique(primary_seg),numpy.unique(secondary_seg)):
raise RuntimeError(f"Something is wrong, there are {numpy.unique(primary_seg).shape[0]-1} primary objects (highest value: {numpy.unique(primary_seg)[-1]}) and {numpy.unique(secondary_seg).shape[0]-1} secondary objects (highest value: {numpy.unique(secondary_seg)[-1]})")
Expand Down
Loading