Dilate a volumetric mask by a certain number of voxel layers. For each layer, any out-of-mask voxel adjacent to at least one in-mask voxel is added to the mask.
dilate_mask_vol(vol, n_dilate = 1, out_of_mask_val = NA, new_val = 1)The dilated vol. It is the same as vol, but dilated
voxels are replaced with new_val.
The 3D array to dilate. The mask to dilate is defined by all
values not in out_of_mask_val.
The number of layers to dilate the mask by. Default:
1.
A voxel is not included in the mask if and only if its
value is in this vector. Default: NA. If vol is simply a
logical array with TRUE values for in-mask voxels, use
out_of_mask_val=FALSE.
Value for voxels newly added to the mask. Default: 1.
If vol is simply a logical array with TRUE values for
in-mask voxels, use new_val=1.
Diagonal voxels are not considered adjacent, i.e. the voxel at (0,0,0) is not adjacent to the voxels at (1,1,0) or (1,1,1), although it is adjacent to (1,0,0).