A binary image of size `sl1`.shape() extend by `nslices`+2 along the new
dimension `dim`. The border slices are the original slices `sl1` and `sl2`.
dt1 = distance_transform_edt(~sl1.astype(numpy.bool))
dt2 = distance_transform_edt(~sl2.astype(numpy.bool))
slicer = [slice(None)] * dt1.ndim
slicer = slicer[:dim] + [numpy.newaxis] + slicer[dim:]
out = numpy.concatenate((dt1[slicer], dt2[slicer]), axis=dim)
zoom_factors = [1] * dt1.ndim
zoom_factors = zoom_factors[:dim] + [(nslices + 2)/2.] + zoom_factors[dim:]
out = zoom(out, zoom_factors, order=order)
return out <= .5
After Change
A binary image of size `sl1`.shape() extend by `nslices`+2 along the new
dimension `dim`. The border slices are the original slices `sl1` and `sl2`.
sl1 = sl1.astype(numpy.bool)
sl2 = sl2.astype(numpy.bool)
dt1 = distance_transform_edt(~sl1) - distance_transform_edt(sl1)
dt2 = distance_transform_edt(~sl2) - distance_transform_edt(sl2)
slicer = [slice(None)] * dt1.ndim
slicer = slicer[:dim] + [numpy.newaxis] + slicer[dim:]
out = numpy.concatenate((dt1[slicer], dt2[slicer]), axis=dim)
zoom_factors = [1] * dt1.ndim
zoom_factors = zoom_factors[:dim] + [(nslices + 2)/2.] + zoom_factors[dim:]
out = zoom(out, zoom_factors, order=order)
return out <= 0