volume#

k3d.factory.volume(volume: List | ndarray | Tuple, color_map: List[List[float]] | Dict[str, Any] | ndarray | None = None, opacity_function: List[float] | None = None, color_range: List[float] = None, samples: float = 512.0, alpha_coef: float = 50.0, gradient_step: float = 0.005, shadow: str = 'off', interpolation: bool = True, shadow_delay: int = 500, shadow_res: int = 128, focal_length: float = 0.0, focal_plane: float = 100.0, ray_samples_count: int = 16, mask: List | ndarray | Tuple = None, mask_opacities: List | ndarray | Tuple = None, name: str | None = None, group: str | None = None, custom_data: Dict[str, Any] | None = None, compression_level: int = 0, **kwargs: Any) Volume[source]#

See also

Examples#

Render mhd volumetric data#

heart.mhd heart.zraw

import k3d
import numpy as np
import SimpleITK as sitk

im_sitk = sitk.ReadImage('heart.mhd')
img = sitk.GetArrayFromImage(im_sitk)

plt_volume = k3d.volume(img.astype(np.float32))

plot = k3d.plot()
plot += plt_volume
plot.display()