Skip to content

Trim stitched tiles when the overlap is zero along one axis - #195

Open
aaronkanzer wants to merge 1 commit into
micro-manager:mainfrom
aaronkanzer:fix/stitch-overlap-one-axis
Open

aaronkanzer wants to merge 1 commit into
micro-manager:mainfrom
aaronkanzer:fix/stitch-overlap-one-axis

Conversation

@aaronkanzer

Copy link
Copy Markdown

as_array(stitched=True) gives the wrong array when the grid overlap is zero in one direction. For a 2x2 grid of 64x80 tiles:

GridPixelOverlap (Y, X) dask shape computed shape
(10, 10) (108, 140) (108, 140)
(0, 10) (128, 140) (128, 160)
(10, 0) (108, 160) (108, 0)

In _read_one_image_for_large_array the overlap is removed only if np.any(overlap[0] > 0), which tests the Y overlap alone, so tiles with only X overlap are not trimmed and the result no longer matches the dask chunk shape. When the Y overlap is nonzero, tile[min:-max] with max_index == 0 on the X axis is tile[:, 0:0], an empty slice.

The fix tests np.any(overlap > 0) and slices up to tile.shape - max_index.

Tested: test_stitched_overlap writes a 2x2 grid with overlaps (10, 10), (0, 10), (10, 0), (1, 3) and (0, 0), stitches it and compares shape and pixels with the expected layout.

The overlap was removed only when the Y overlap was nonzero, and with
tile[a:-b] a zero overlap on one axis gives an empty slice. A grid with
only X overlap was not trimmed, so the computed array did not match the
dask shape, and a grid with only Y overlap stitched to zero width.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant