Skip to content

Commit 3e2d6a1

Browse files
timtreisclaude
andcommitted
Skip label2rgb when only rendering outline
Move the label2rgb call below the seg_boundaries early return so it is not computed when only the outline ring is needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7dcccf0 commit 3e2d6a1

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/spatialdata_plot/pl/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,14 +1200,6 @@ def _map_color_seg(
12001200
if seg_erosionpx is not None:
12011201
val_im[val_im == erosion(val_im, footprint_rectangle((seg_erosionpx, seg_erosionpx)))] = 0
12021202

1203-
seg_im: ArrayLike = label2rgb(
1204-
label=val_im,
1205-
colors=cols,
1206-
bg_label=0,
1207-
bg_color=(1, 1, 1), # transparency doesn't really work
1208-
image_alpha=0,
1209-
)
1210-
12111203
if seg_boundaries:
12121204
outline_rgba = colors.to_rgba(outline_color.get_hex_with_alpha() if outline_color is not None else "black")
12131205

@@ -1218,6 +1210,14 @@ def _map_color_seg(
12181210
rgba[outline_mask, 3] = outline_rgba[3]
12191211
return rgba
12201212

1213+
seg_im: ArrayLike = label2rgb(
1214+
label=val_im,
1215+
colors=cols,
1216+
bg_label=0,
1217+
bg_color=(1, 1, 1), # transparency doesn't really work
1218+
image_alpha=0,
1219+
)
1220+
12211221
if len(val_im.shape) != len(seg_im.shape):
12221222
val_im = np.expand_dims((val_im > 0).astype(int), axis=-1)
12231223
return np.dstack((seg_im, val_im))

0 commit comments

Comments
 (0)