Skip to content

Commit 2dbaf25

Browse files
author
David Stirling
authored
Label imported objects sequentially (#81)
1 parent fd60f29 commit 2dbaf25

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

cellprofiler_core/modules/namesandtypes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import javabridge
88
import numpy
9+
import skimage.morphology
910

1011
from ..constants.image import C_FRAME
1112
from ..constants.image import C_HEIGHT
@@ -2150,6 +2151,7 @@ def add_objects(self, workspace, name, stack):
21502151
image = provider.provide_image(workspace.image_set)
21512152
o = Objects()
21522153
shape = image.pixel_data.shape
2154+
image.set_image(skimage.morphology.label(image.pixel_data), convert=False)
21532155
if shape[2] == 1:
21542156
o.segmented = image.pixel_data[:, :, 0]
21552157
add_object_location_measurements(

tests/modules/test_namesandtypes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import numpy
1111
import pytest
1212
import six
13+
import skimage.morphology
1314
import zlib
1415

1516
import cellprofiler_core.constants.image
@@ -1911,6 +1912,8 @@ def test_load_objects():
19111912
["ExampleSBSImages"], "Channel2-01-A-01.tif"
19121913
)
19131914
target = bioformats.load_image(path, rescale=False)
1915+
target = skimage.morphology.label(target)
1916+
19141917
with open(path, "rb") as fd:
19151918
md5 = hashlib.md5(fd.read()).hexdigest()
19161919
workspace = run_workspace(
@@ -2038,6 +2041,7 @@ def test_load_single_object():
20382041
["ExampleSBSImages"], "Channel2-01-A-01.tif"
20392042
)
20402043
target = bioformats.load_image(lsi_path, rescale=False)
2044+
target = skimage.morphology.label(target)
20412045
with open(lsi_path, "rb") as fd:
20422046
md5 = hashlib.md5(fd.read()).hexdigest()
20432047
workspace = run_workspace(

0 commit comments

Comments
 (0)