k3d.factory.mip(volume, color_map=None, opacity_function=None, color_range=[], samples=512.0, gradient_step=0.005, name=None, group=None, custom_data=None, compression_level=0, **kwargs)[source]#

Create a MIP drawable for 3D volumetric data.

By default, the volume are a grid inscribed in the -0.5 < x, y, z < 0.5 cube regardless of the passed voxel array shape, like aspect ratio.

Different grid size, shape and rotation can be obtained using kwargs

  • mip(..., bounds=[0, 300, 0, 400, 0, 500])

  • mip(..., scaling=[scale_x, scale_y, scale_z])

  • volume (ndarray) – 3D array of float.

  • color_map (list, optional) – List of float quadruplets (attribute value, R, G, B) sorted by attribute value, by default None. The first quadruplet should have value 0.0, the last 1.0; R, G, B are RGB color components in the range 0.0 to 1.0.

  • opacity_function (list, optional) – float tuples (attribute value, opacity) sorted by attribute value, by default []. The first tuples should have value 0.0, the last 1.0; opacity is in the range 0.0 to 1.0.

  • color_range (list, optional) – [min_value, max_value] pair determining the levels of color attribute mapped to 0 and 1 in the colormap, by default [].

  • samples (float, optional) – Number of iteration per 1 unit of space, by default 512.0.

  • gradient_step (float, optional) – Gradient light step, by default 0.005.

  • name (str, optional) – Object name, by default None.

  • group (str, optional) – Name of a group, by default None.

  • custom_data (dict) – A object with custom data attached to object.

  • compression_level (int, optional) – Level of data compression [-1, 9], by default 0.

  • **kwargs – For other keyword-only arguments, see process_transform_arguments.


MIP Drawable.

Return type


See also


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_mip = k3d.mip(img.astype(np.float32))

plot = k3d.plot()
plot += plt_mip