Skip to content
Snippets Groups Projects
Commit 61130b78 authored by Christopher Randolph Rhodes's avatar Christopher Randolph Rhodes
Browse files

Corrected slicing mistake that caused error in edge cases

parent aade8740
No related branches found
No related tags found
No related merge requests found
......@@ -63,5 +63,5 @@ def draw_contours_on_patch(patch, contours, linewidth=1):
pilimg = Image.fromarray(patch) # drawing modifies array in-place
draw = ImageDraw.Draw(pilimg)
for co in contours:
draw.line([(p[1], p[0]) for p in co], width=linewidth)
draw.line([(p[1], p[0]) for p in co], width=linewidth, joint='curve')
return np.array(pilimg)
\ No newline at end of file
......@@ -154,10 +154,8 @@ def export_patches_from_zstack(
if kwargs.get('draw_contour'):
mci = kwargs.get('contour_channel', 0)
mask = np.zeros(patch.shape[0:2], dtype=bool)
try:
mask[sp_sl[0:2]] = mi['mask']
except Exception:
a=1
mask[sp_sl[0:2]] = mi['mask']
for zi in range(0, patch.shape[3]):
patch[:, :, mci, zi] = draw_contours_on_patch(
patch[:, :, mci, zi],
......
......@@ -90,9 +90,9 @@ def build_zmask_from_object_mask(
meta = []
for ob in df[df['keeper']].itertuples(name='LabeledObject'):
y0 = max(ob.y0 - ebxy, 0)
y1 = min(ob.y1 + ebxy, h - 1)
y1 = min(ob.y1 + ebxy, h)
x0 = max(ob.x0 - ebxy, 0)
x1 = min(ob.x1 + ebxy, w - 1)
x1 = min(ob.x1 + ebxy, w)
z0 = max(ob.zi - ebz, 0)
z1 = min(ob.zi + ebz, nz)
......@@ -111,6 +111,9 @@ def build_zmask_from_object_mask(
contour = find_contours(obmask)
mask = obmask[ob.y0: ob.y1, ob.x0: ob.x1]
assert rbb['x1'] <= (x1 - x0)
assert rbb['y1'] <= (y1 - y0)
meta.append({
'info': ob,
'slice': sl,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment