rockverse.voxel_image.VoxelImage.combine#
- VoxelImage.combine(image, op, *, mask=None, segmentation=None, phases=None, region=None)[source]#
Combine another voxel image by element-wise math operations.
This method applies math operations for each voxel in the images. Optional parameters allow for selective setting based on mask, segmentation, and phases.
- Parameters:
image (VoxelImage) –
The voxel image to be used in the operation. Must have shape, voxel origin, voxel length and voxel unit equal to the ones in the original array.
Note
There is no internal check for the correct data type of
a. Ensure that theaprovided is compatible with the image data type.op (str) –
The operation to be performed. Let \(voxel1\) represent each voxel in the original image and \(voxel2\) represent each voxel in
image. Valid values foropare:Operations# opOperation
’copy’
\(voxel1 = voxel2\)
’add’
\(voxel1 = voxel1 + voxel2\)
’subtract’
\(voxel1 = voxel1 - voxel2\)
’multiply’
\(voxel1 = voxel1 voxel2\)
’divide’
\(voxel1 = voxel1 / voxel2\)
’logical and’
\(voxel1 = voxel1 \land voxel2\)
’logical or’
\(voxel1 = voxel1 \lor voxel2\)
’logical xor’
\(voxel1 = voxel1 \oplus voxel2\) (exclusive OR)
’min’
\(voxel1 = \min(voxel1, voxel2)\)
’max’
\(voxel1 = \max(voxel1, voxel2)\)
’average’
\(voxel1 = (voxel1 + voxel2)/2\)
’absolute difference’
\(voxel1 = |voxel1 - voxel2|\)
mask (VoxelImage, optional) – Boolean voxel image. If provided, the operation will ignore masked voxels (i.e., where mask is True).
segmentation (VoxelImage, optional) – Unsigned integer voxel image. If provided, only voxels where the segmentation phase is in
phaseswill be set to the specified value.phases (iterable of int, optional) – Any iterable with non negative integers representing the segmentation phases. Used together with
segmentation. Segmentation phases not inphaseswill be ignored by the operation.region (Region, optional) – A region specification. If provided, only voxels within the specified region will be set to the specified value.