Tiled inference

Tiled inference#

Tiled inference can be used to run image processing filters, segmentation, or detection algorithms tile-by-tile instead of on the whole input image at once. The processed tiles are progressively assembled to form the final result.

By default, this functionality is disabled; you can enable it by setting tileable=True when defining an algorithm.

When running an algiorithm tile-by-tile, you can adjust the tile size in pixels, the amount of overlap between tiles, and the order in which tiles are processed (random or not).

Try it in Napari#

Consider this simple threshold algorithm:

import imaging_server_kit as sk

@sk.algorithm(tileable=True)  # <- Set tileable=True
def threshold_algo(image, threshold=128):
    mask = image > threshold
    return sk.Mask(mask)

viewer = sk.to_napari(threshold_algo)

import skimage.data
viewer.add_image(skimage.data.coins())

Before running the algorithm in Napari, you can expand the Tiled inference menu and activate the tiling functionality form the user interface.

Summary#

  • You can enable running an algorithm tile-by-tile by setting tileable=True in the algorithm definition.

Next steps#

In the next section, you will see how to serve your algorithm as an API.