MeVisLab Scripting Reference
|
MeVisLab supports implementing ML image processing modules using Python. Although the performance of a scripted image processing module is slow compared to C++, this allows implementing image processing modules without the hassle of needing a C++ compiler and with immediate module reloading without restart.
The following classes are available when scripting your own Python image processing modules:
This allows to do the following:
Apart from this, it is also possible to access the ML images via the MLABField::image() API, which allows to call MLPagedImageWrapper::getTile() from Python. This can be used to create modules that do slice-by-slice calculation on their input images.
MeVisLab contains several example Python image processing modules at MeVisLab/Standard/Modules/Examples/PythonImageProcessing. Have a look at the following example modules in MeVisLab:
A simple example that just generates test pattern stripes is shown below. For more details, please have a look at the more elaborated example modules listed above. NOTE: ML pages are typically 6 dimensional and NumPy handles the dimensions in a different ordering than the ML convention. The NumPy ndarray.shape returns a tuple of (u,t,c,z,y,x) dimensions, while the ML methods expect/return (x,y,z,c,t,u) tuples. So if you use indexing in NumPy, keep in mind that you have to either do ndarray.squeeze() to get rid of the dimensions that are 1 or you need to write N leading zeros to fill up all 6 dimensions. The example below uses squeeze and [y,x] indexing.