From aaaf10a90fc21f450107734f36c302d04ad0cbbb Mon Sep 17 00:00:00 2001 From: ErinWeisbart <54687786+ErinWeisbart@users.noreply.github.com> Date: Wed, 21 May 2025 10:04:36 -0700 Subject: [PATCH 1/2] bugfix convertoutlinestoobjects Co-authored-by: bethac07 --- .../convertoutlinestoobjects.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) rename {unmaintained_plugins/CellProfiler4_autoconverted => active_plugins}/convertoutlinestoobjects.py (84%) diff --git a/unmaintained_plugins/CellProfiler4_autoconverted/convertoutlinestoobjects.py b/active_plugins/convertoutlinestoobjects.py similarity index 84% rename from unmaintained_plugins/CellProfiler4_autoconverted/convertoutlinestoobjects.py rename to active_plugins/convertoutlinestoobjects.py index 3bc4325c..482b2819 100644 --- a/unmaintained_plugins/CellProfiler4_autoconverted/convertoutlinestoobjects.py +++ b/active_plugins/convertoutlinestoobjects.py @@ -66,6 +66,7 @@ def run(self, workspace): def convert_outlines_to_objects(outlines, diameter): + # turn everything into a label matrix labels = skimage.measure.label( outlines > 0, background=True, @@ -96,6 +97,17 @@ def convert_outlines_to_objects(outlines, diameter): background_indexes = numpy.unique(labels)[is_background] + # set the background to 0 labels[numpy.isin(labels, background_indexes)] = 0 + # reindex everything to be consecutive + indexes = numpy.unique(labels) + new_object_count = len(indexes) + max_label = numpy.max(labels) + label_indexes = numpy.zeros((max_label + 1,), int) + label_indexes[indexes] = numpy.arange(0, new_object_count) + + #target_labels[target_labels > max_label] = 0 + labels = label_indexes[labels] + return labels From bf9f27153b29f438aa58650f8007b41d8eaa980e Mon Sep 17 00:00:00 2001 From: ErinWeisbart <54687786+ErinWeisbart@users.noreply.github.com> Date: Wed, 21 May 2025 10:06:19 -0700 Subject: [PATCH 2/2] cleanup --- active_plugins/convertoutlinestoobjects.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/active_plugins/convertoutlinestoobjects.py b/active_plugins/convertoutlinestoobjects.py index 482b2819..a5c7d2e9 100644 --- a/active_plugins/convertoutlinestoobjects.py +++ b/active_plugins/convertoutlinestoobjects.py @@ -106,8 +106,6 @@ def convert_outlines_to_objects(outlines, diameter): max_label = numpy.max(labels) label_indexes = numpy.zeros((max_label + 1,), int) label_indexes[indexes] = numpy.arange(0, new_object_count) - - #target_labels[target_labels > max_label] = 0 labels = label_indexes[labels] return labels