diff --git a/extensions/chaeo/annotators.py b/extensions/chaeo/annotators.py index 0c25647e67c8beebaa00c4897dce36a337729c10..10019d2b159978812ec53692e6c36251783f1833 100644 --- a/extensions/chaeo/annotators.py +++ b/extensions/chaeo/annotators.py @@ -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 diff --git a/extensions/chaeo/products.py b/extensions/chaeo/products.py index bab25537286709bae63bbacda4171cf6800eb7b7..fe53dbfb13195eb1bcb06f36373f9eda3536a40d 100644 --- a/extensions/chaeo/products.py +++ b/extensions/chaeo/products.py @@ -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], diff --git a/extensions/chaeo/zmask.py b/extensions/chaeo/zmask.py index f624beec7bf6f201ea164a9bd165e54fa7d2bd9a..ecca8b2f65b428f8c0fd586e622aa74b2b6cd862 100644 --- a/extensions/chaeo/zmask.py +++ b/extensions/chaeo/zmask.py @@ -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,