I have a binary 3D-mask with a core that is completely missing at some slices along the z-dimension. I’d like to interpolate those missing slices so that they get the core shape (and value, but that’s 1 since it’s a binary) at the nearest slice that has a core. Is that possible to do with dask-image? I was looking at the dask_image.ndinterp module but I don’t understand how to use it.

Well, I’m really no expert in interpolation, but is this really one? You’re not trying to map new points to a reference function, but trying to fill huge gaps between 0 and 1, because you expect the 1s to be contiguous over your volume?

Did you already tried some code? How would you do it in Numpy?

You’re right in that I might not use the right terminology for what I wanted to do. In the end, I used unidirectional dilation to accomplish what I wanted.

import dask.array as da
import dask_image.ndmorph as dmorph

z_profile = da.sum(dummy_arr , axis=(1, 2)) # first step for finding longest gap in data
csum = da.cumsum(z_profile) # second step for finding longest gap
bcount = da.bincount(csum) # third step for finding longest gap
longest_gap = da.max(bcount) - 1
iterations = da.ceil(longest_gap / 2) # dilation is done from both directions, so dilate with longest gap / 2
sel = da.zeros((3, 3, 3)) # basis for structuring element
sel[:, 1, 1] = 1 # structuring for dilation in the z-direction only
dummy_arr_filled = dmorph.binary_dilation(dummy_arr, sel, iterations=iterations)