Skip to content

Stitch Prediction

Source

Tiled prediction stitching utilities.

group_tiles_by_key(tiles, key)

Sort tiles by key.

Parameters:

  • tiles (list of ImageRegionData) –

    List of tiles to sort.

  • key ((data_idx, sample_idx), default: 'data_idx' ) –

    Key to group tiles by.

Returns:

  • {int: list of ImageRegionData}

    Dictionary mapping data indices to lists of tiles.

stitch_prediction(tiles, restore_shape=False)

Stitch tiles back together to form full images.

Tiles are of dimensions SC(Z)YX, where C is the number of channels and can be a singleton dimension.

Parameters:

  • tiles (list of ImageRegionData) –

    Cropped tiles and their respective stitching coordinates. Can contain tiles from multiple images.

  • restore_shape (bool, default: False ) –

    If True, restore predictions to their original shape and dimension order.

Returns:

  • list of numpy.ndarray

    Full images, may be a single image.

  • list of str

    List of sources, one per output.

stitch_single_prediction(tiles, restore_shape=False)

Stitch tiles back together to form a full image.

Tiles are of dimensions C(Z)YX, where C is the number of channels and can be a singleton dimension.

Parameters:

  • tiles (list of ImageRegionData) –

    Cropped tiles and their respective stitching coordinates.

  • restore_shape (bool, default: False ) –

    If True, restore prediction to its original shape and dimension order.

Returns:

  • ndarray

    Full image, with dimensions SC(Z)YX.

stitch_single_sample(tiles)

Stitch tiles back together to form a full sample.

Tiles are of dimensions C(Z)YX, where C is the number of channels and can be a singleton dimension.

Parameters:

  • tiles (list of ImageRegionData) –

    Cropped tiles and their respective stitching coordinates.

Returns:

  • ndarray

    Full sample, with dimensions C(Z)YX.