# Landmark Image Registration of Images with different Resolutions

**URL:** https://discourse.itk.org/t/landmark-image-registration-of-images-with-different-resolutions/6573
**Category:** Beginner Questions
**Tags:** registration, python, simpleitk
**Created:** [April 15, 2024, 7:54am UTC](https://discourse.itk.org/t/landmark-image-registration-of-images-with-different-resolutions/6573 "2024-04-15T07:54:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![luviku](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/e47c2d/32.png) [@luviku](https://discourse.itk.org/u/luviku)
#### Post date: [April 15, 2024, 7:54am UTC](https://discourse.itk.org/t/landmark-image-registration-of-images-with-different-resolutions/6573/1 "2024-04-15T07:54:30Z")

</div>

Hello everyone,

I am a beginner so please forgive me if this is a basic question. I am working on registering Spectralis SLO images with OCT-A images. I am using landmarks to identify points on vessels, which correlate in both scans. I suppose since both scans have different resolutions (1536x1536 vs. 1024x1024) the registration fails and produces an image like shown below. Is it possible to deal with different resolutions without having to crop the “bigger” image?

This is my code for image registration:

```auto
def register_images(self):
        if not self.fixed_image_path or not self.moving_image_path:
            return

        fixed_image = sitk.ReadImage(self.fixed_image_path)
        moving_image = sitk.ReadImage(self.moving_image_path)
       
        landmark_initializer = sitk.LandmarkBasedTransformInitializerFilter()

        fixed_landmarks = [coord for point in self.fixed_points for coord in point]
        moving_landmarks = [coord for point in self.moving_points for coord in point]

        landmark_initializer.SetFixedLandmarks(fixed_landmarks)
        landmark_initializer.SetMovingLandmarks(moving_landmarks)

        transform = sitk.AffineTransform(2)

        output_transform = landmark_initializer.Execute(transform)
  
        print(output_transform)

        output_image = sitk.Resample(moving_image, referenceImage=fixed_image, transform=output_transform)
        
        sitk.WriteImage(output_image, "landmark_example.tiff")
 
        sitk.WriteTransform(output_transform, "landmark_transform.tfm")

```

Here the resulting transformation:  
[landmark\_example.tiff](https://discourse.itk.org/uploads/short-url/fD26LxywlftuHFz8av1wkW7NWtj.tiff) (2.3 MB)

Thank you for any help!

EDIT: I noticed that the pixel spacing of the fixed and moving image are different (1.0 and 0.24 respectively). I will try to compensate for that discrepancy.

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [April 15, 2024, 1:11pm UTC](https://discourse.itk.org/t/landmark-image-registration-of-images-with-different-resolutions/6573/2 "2024-04-15T13:11:21Z")

</div>

Hello @luviku,

In ITK/SimpleITK registration is done in physical space, so the two images can have different sizes (number of pixels per dimension) and spacing (physical size of pixel/voxel in mm). For a better understanding of the fundamentals of the toolkit please see the [fundamental concepts page](https://simpleitk.readthedocs.io/en/master/fundamentalConcepts.html) and [registration overview page](https://simpleitk.readthedocs.io/en/master/registrationOverview.html).

Possibly also look at the [registration initialization notebook](https://github.com/InsightSoftwareConsortium/SimpleITK-Notebooks/blob/master/Python/63_Registration_Initialization.ipynb), section titled **Register using manual initialization**. You will need to modify it slightly to accommodate for the different data dimension and transform type `VersorRigid3DTransform` to `AffineTransform(2)` etc.

---

<div class="post-metadata">

### Author: ![luviku](https://discourse.itk.org/letter_avatar_proxy/v4/letter/l/e47c2d/32.png) [@luviku](https://discourse.itk.org/u/luviku)
#### Post date: [April 16, 2024, 7:16am UTC](https://discourse.itk.org/t/landmark-image-registration-of-images-with-different-resolutions/6573/3 "2024-04-16T07:16:24Z")

</div>

Hello @zivy ,

thanks for the response. I read through your suggestions, unfortunately I could not find a solution to my problem in the documents. What I failed to mention above, is that the two images don’t look alike. The fixed image is a photo of the eye fundus where there are barely vessels visible. The moving image is an angiography with lots of vessels visible. That is why I can only use the landmarks for registering them.

Anyway setting the spacing of the moving image to (1,1) resolved the problem, even though I am not sure if it is the right way to so.
