-
Notifications
You must be signed in to change notification settings - Fork 123
/
test_visual_mip.py
46 lines (32 loc) · 1.04 KB
/
test_visual_mip.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import k3d
import numpy as np
import pytest
from .plot_compare import *
import vtk
from vtk.util import numpy_support
def test_mip():
prepare()
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName('./test/assets/volume.vti')
reader.Update()
vti = reader.GetOutput()
x, y, z = vti.GetDimensions()
volume_data = numpy_support.vtk_to_numpy(
vti.GetPointData().GetArray(0)
).reshape(-1, y, x).astype(np.float32)
volume = k3d.mip(volume_data, samples=512)
pytest.plot += volume
compare('mip')
def test_mip_opacity_function():
prepare()
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName('./test/assets/volume.vti')
reader.Update()
vti = reader.GetOutput()
x, y, z = vti.GetDimensions()
volume_data = numpy_support.vtk_to_numpy(
vti.GetPointData().GetArray(0)
).reshape(-1, y, x).astype(np.float32)
volume = k3d.mip(volume_data, opacity_function=[0, 0.0, 0.2, 0.5, 1, 1.0], samples=512)
pytest.plot += volume
compare('mip_opacity_function')