Overview

imfusion.imagemath - Bindings for ImageMath Operations

This module provides element-wise arithmetic operations for SharedImage and SharedImageSet. You can apply these imagemath functionalities directly to objects of SharedImage and SharedImageSet with eager evaluation. Alternatively, the module offers lazy evaluation functionality through the submodule lazy. You can create wrapper expressions using the Expression provided by lazy.

See Expression for details.

Example for eager evaluation:

>>> from imfusion import _bindings.imagemath as imagemath

Add si1 and si2, which are SharedImage instances:

>>> res = si1 + si2

res is a SharedImage instance.

>>> print(res)
imfusion.SharedImage(FLOAT width: 512 height: 512)

Example for lazy evaluation:

>>> from imfusion import _bindings.imagemath as imagemath

Create expressions from SharedImage instances:

>>> expr1 = imagemath.lazy.Expression(si1)
>>> expr2 = imagemath.lazy.Expression(si2)

Add expr1 and expr2:

>>> expr3 = expr1 + expr2

Alternatively, you could add expr1 and si2 or si1 and expr2. Any expression containing an instance of Expression will be converted to lazy evaluation expression.

>>> expr3 = expr1 + si2

Find the result with lazy evaluation:

>>> res = expr3.evaluate()

res is a SharedImage instance similar to eager evaluation case.

>>> print(res)
imfusion.SharedImage(FLOAT width: 512 height: 512)