<jupyter_start><jupyter_text>ElastixThis notebooks show very basic image registration examples with on-the-fly generated binary images.<jupyter_code>import itk
import numpy as np
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Image generators<jupyter_code>def image_generator(x1, x2, y1, y2):
    image = np.zeros([100, 100], np.float32)
    image[y1:y2, x1:x2] = 1
    image = itk.image_view_from_array(image)
    return image<jupyter_output><empty_output><jupyter_text>Affine Test<jupyter_code># Create test images
fixed_image_affine = image_generator(25,75,25,75)
moving_image_affine = image_generator(1,71,1,91)

# Import Default Parameter Map
parameter_object = itk.ParameterObject.New()
default_affine_parameter_map = parameter_object.GetDefaultParameterMap('affine',4)
default_affine_parameter_map['FinalBSplineInterpolationOrder'] = ['0']
parameter_object.AddParameterMap(default_affine_parameter_map)
# Call registration function
result_image_affine, result_transform_parameters = itk.elastix_registration_method(
    fixed_image_affine, moving_image_affine,
    parameter_object=parameter_object,
    log_to_console=True)<jupyter_output><empty_output><jupyter_text>Visualization Affine Test<jupyter_code>%matplotlib inline

# Plot images
fig, axs = plt.subplots(1,3, sharey=True, figsize=[30,30])
plt.figsize=[100,100]
axs[0].imshow(result_image_affine)
axs[0].set_title('Result', fontsize=30)
axs[1].imshow(fixed_image_affine)
axs[1].set_title('Fixed', fontsize=30)
axs[2].imshow(moving_image_affine)
axs[2].set_title('Moving', fontsize=30)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10925925925925926, 'fraction_numerical': 0.03518518518518519, 'mean_word_length': 9.664473684210526, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '229682', 'license': 'Apache-2.0', 'n_tokens_mistral': 614, 'n_tokens_neox': 586, 'n_words': 88, 'path': 'examples/ITK_UnitTestExample2_AffineRegistration.ipynb', 'repo_name': 'NHPatterson/ITKElastix', 'size': '1620'}