InsightSoftwareConsortium / InsightSoftwareConsortium/ITKElastix

Histology image registration

Open
#252 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
281
Forks
29
Avg merge
16h 28m
Merged PRs (30d)
8

Description

Hey!

I'm interested in registering some histology images and I was wondering if Elastix could be used for this purpose. I tried to register some demo images, which were cropped from the same tissue section and I introduced a 30° rotation to one of them. As the images are almost identical, in theory it should not be a difficult task but I can't get any meaningful results.

![image](https://github.com/InsightSoftwareConsortium/ITKElastix/assets/68016418/23190062-3e41-42b3-8620-fe5723954c85)

Demo images can be downloaded from here: https://drive.google.com/file/d/1iSplSMc6WaANrDq7UilynyVLgrvr4Jpt/view?usp=sharing

```python

import itk
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt

# open and convert images to grayscale
moving_image = Image.open("demo_1.png").convert('L')
moving_image = np.array(moving_image).astype(np.float32)
moving_image /= 255.0
moving_image = itk.image_view_from_array(moving_image)

fixed_image = Image.open("demo_2.png").convert('L')
fixed_image = np.array(fixed_image, np.float32)
fixed_image /= 255.0
fixed_image = itk.image_view_from_array(fixed_image)

# initialize Elastix with affine transform
parameter_object = itk.ParameterObject.New()
default_affine_parameter_map = parameter_object.GetDefaultParameterMap('affine')
default_affine_parameter_map['FinalBSplineInterpolationOrder'] = ['0']
parameter_object.AddParameterMap(default_affine_parameter_map)

result_image_affine, result_transform_parameters = itk.elastix_registration_method(fixed_image,
moving_image,
parameter_object=parameter_object,
log_to_console=True)

# plot the results
im = np.zeros((fixed_image.shape[0], fixed_image.shape[1], 3))
im[:, :, 0] = fixed_image
im[:, :, 1] = result_image_affine

fig, axs = plt.subplots(1, 4, sharey=True, figsize=[15, 5])
axs[0].imshow(result_image_affine)
axs[0].set_title('Result', fontsize=30)
axs[1].imshow(fixed_image)
axs[1].set_title('Fixed', fontsize=30)
axs[2].imshow(moving_image)
axs[2].set_title('Moving', fontsize=30)
axs[3].imshow(im)
axs[3].set_title('Overlap', fontsize=30)
plt.show()
```
I don't see any improvements in the error metric when looking at the output.

These are the results :

![image](https://github.com/InsightSoftwareConsortium/ITKElastix/assets/68016418/f0eaf649-2e5e-45d3-be04-3586f8b60e92)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.