saeyslab / napari-sparrow

Other
17 stars 0 forks source link

Tiling correction when image size is not multiple of tile size #113

Closed ArneDefauw closed 1 year ago

ArneDefauw commented 1 year ago

Tiling correction fails when one of the image axes is not a multiple of tile size. This is caused by this code:

        # create the masks for inpainting
        i_mask = (
            np.block(
                [
                    list(tiles[i : i + (ic.shape[1] // tile_size)])
                    for i in range(0, len(tiles), ic.shape[1] // tile_size)
                ]
            ).astype(np.uint16)
            == 0
        )

This could be a problem if user cropped the image before running sparrow.

lopollar commented 1 year ago

go to bigger crop for tiling correction, then takethe crop again to visualize

ArneDefauw commented 1 year ago

It is difficult to implement a satisfactory fix for this.

Won't fix for now, as it seems an edge case scenario, added a check if image dimension is a multiple of tile size, code will now raise a ValueError with a clear error message.