import itk
import numpy as np
import imageio
from itkwidgets import view, compare, checkerboard
Images as NumPy arrays can be registered.
Convert them to floating point arrays for registration.
fixed = imageio.imread('data/CT_2D_head_fixed.mha')
fixed = np.asarray(fixed).astype(np.float32)
type(fixed)
numpy.ndarray
moving = imageio.imread('data/CT_2D_head_moving.mha')
moving = np.asarray(moving).astype(np.float32)
type(moving)
numpy.ndarray
compare(fixed, moving, ui_collapsed=True)
AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=False, description='cmap'), Checkbox(v…
Before registration, the moving image is not aligned with the fixed image.
checkerboard(fixed, moving, pattern=10)
VBox(children=(Viewer(annotations=False, interpolation=False, rendered_image=<itk.itkImagePython.itkImageF2; p…
# Register!
registered, parameters = itk.elastix_registration_method(fixed, moving)
type(registered)
itk.itkPyBufferPython.NDArrayITKBase
compare(fixed, registered, ui_collapsed=True)
AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=False, description='cmap'), Checkbox(v…
The registered moving image is aligned with the fixed image
checkerboard(fixed, registered, pattern=10)
VBox(children=(Viewer(annotations=False, interpolation=False, rendered_image=<itk.itkImagePython.itkImageF2; p…