PythonImage¶
-
MLModule
¶ author MeVis Medical Solutions AG
package MeVisLab/Standard
dll MLPythonImageProcessing
definition PythonImage.def keywords numpy
,ndarray
,tile
,global
Purpose¶
The module PythonImage
allows to set a numpy.ndarray as the output ML image of the module using Python scripting.
Usage¶
The typical usage is to do get the module via ctx.module() and call getInterface on it to get access to its scripting API.
The returned interface supports:
setImage(image, minMaxValues, voxelSize = None, pageSize = None, voxelToWorldMatrix = None)
to set the image and:
unsetImage()
to unset the image again.
Details¶
Here is an example that generates a test pattern:
import numpy as np
import math
interface = ctx.module("PythonImage").call("getInterface")
tile = np.ndarray((64,128,256), np.float32)
# fill tile with some data...
for z in range(0,64):
zFactor = math.cos(z/64. * math.pi)
for y in range(0, 128):
yFactor = math.sin(y/32. * math.pi)
for x in range(0, 256):
tile[z,y,x] = math.cos(x/32. * math.pi) * yFactor * zFactor
interface.setImage(tile, minMaxValues = (-1, 1))
Tips¶
Have a look at the PythonImageExample example module for a typical usage inside a MacroModule.