merge_vertical_chunkwise¶

merge_vertical_chunkwise(canvas, count, output_locs_y_, zarr_group, save_path, memory_threshold=80, output_shape=None, *, verbose=True)[source]¶

Merge vertically chunked canvas and count arrays into a single probability map.

This function processes vertically stacked image blocks (canvas) and their associated count arrays to compute normalized probabilities. It handles overlapping regions between chunks by applying seam folding and trimming halos to ensure smooth transitions. If a Zarr group is provided, the result is stored incrementally.

Parameters:
  • canvas (da.Array) – Dask array containing image data split into vertical chunks.

  • count (da.Array) – Dask array containing count data corresponding to the canvas.

  • output_locs_y (np.ndarray) – Array of shape (N, 2) specifying vertical output locations for each chunk, used to compute overlaps.

  • zarr_group (zarr.Group) – Zarr group to store the merged probability dataset.

  • save_path (Path) – Path to save the intermediate output. The intermediate output is saved in a Zarr file.

  • memory_threshold (int) – Memory usage threshold (in percentage) to trigger caching behavior.

  • output_shape (tuple[int, int] | None) – Optional target output shape as (height, width). If provided, merged probabilities are clipped to this shape before being accumulated or written to Zarr.

  • verbose (bool) – Whether to display progress bar.

  • output_locs_y_ (ndarray)

Returns:

A merged Dask array of normalized probabilities, either loaded from Zarr or constructed in memory.

Return type:

da.Array