Often, some content in the images may not correspond. For example, there may be background content or noisy areas. A mask defined on the fixed and/or moving image can be used to exclude these regions at a pixel level from the similarity metric computations. This improves the robustness of registration.
For more information, see Section 5.4, "Masks" of the Elastix Manual.
import itk
from itkwidgets import view, compare
# Lung SEM slices
# Grothausmann, R., Knudsen, L., Ochs, M., and Mühlfeld, C.: Digital 3D reconstructions
# using histological serial sections of lung tissue including the alveolar
# capillary network. American Journal of Physiology - Lung Cellular and Molecular
# Physiology 312(2), L243–L257 (2017). doi: 10.1152/ajplung.00326.2016
fixed = itk.imread('data/lung_sem/2016_12_02_0101_s00_01.png', itk.F)
moving = itk.imread('data/lung_sem/2016_12_02_0101_s00_02.png', itk.F)
There are inconsistent dirt particles in each slice. Let's exclude these with a mask.
compare(fixed, moving, ui_collapsed=True)
AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=False, description='cmap'), Checkbox(v…
MaskImageType = itk.Image[itk.UC, 2]
fixed_mask = itk.binary_threshold_image_filter(fixed,
lower_threshold=80.0,
inside_value=1,
ttype=(type(fixed), MaskImageType))
compare(fixed, fixed_mask)
AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=False, description='cmap'), Checkbox(v…
moving_mask = itk.binary_threshold_image_filter(moving,
lower_threshold=80.0,
inside_value=1,
ttype=(type(moving), MaskImageType))
compare(moving, moving_mask)
AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=False, description='cmap'), Checkbox(v…
parameters = itk.ParameterObject.New()
parameters.ReadParameterFile('data/lung_sem/ParameterFile.txt')
registered = itk.elastix_registration_method(fixed, moving,
parameter_object=parameters,
fixed_mask=fixed_mask, moving_mask=moving_mask)
compare(fixed, registered, ui_collapsed=True)
AppLayout(children=(HBox(children=(Label(value='Link:'), Checkbox(value=False, description='cmap'), Checkbox(v…