Creating an image mosaic in SimpleITK

I’m new to SimpleITK and am looking to create an image mosaic of a large number of grayscale images (probability maps from binary segmentation of blood vessels) through sequential image registration. Since I’m quite new I’m not a hundred percent sure how to do this and I haven’t yet found any examples of combining multiple images into one larger one. Are there any good examples or resources which might be of help to me in going about this (preferably in python)?

Hello @user1,

Welcome to SimpleITK!

I believe what you are looking for is covered in this Jupyter notebook.

As you are new to SimpleITK I recommend:

  1. Invest the time and go through the virtual tutorial.
  2. Skim through the toolkit’s Jupyter notebook repository and short examples on read-the-docs.

Thank you the resources have been most helpful and has gotten me off the ground. However I’ve encountered an issue when trying to create the composite image.

I’m able to register for example image one and two, as well as two and three and resample them such that I can create pairwise “mosaics” however when I try to include all three images the third one always becomes misaligned. This occures both when I use borrowed code from the functions create_images_inshared_coordinate_system() and composite_images_alpha_blending() from the x-ray-panorama notebook you shared, as well as with my own code.

I think this has to do with how understand resample to work as well as my assumption that if I make an composite transform from the transformation between the first and second image and the second and third that should map the third image onto the other two correctly which is does not. Is it clear to you where my misunderstanding lies?

Hello @user1 (nice username by the way),

Several things you need to understand about the various components/steps involved in this process:

  1. Registration: the estimated transformation maps points from the fixed image coordinate system to the moving image coordinate system.
  2. Composite transform: semantics is of a stack, first transform added last applied.
  3. To create a composite image from all the images you will need to select a coordinate system (e.g. the coordinate system of the fourth image out of ten). You then map all of the bounding box points from each of the images to this coordinate system and compute a new bounding box there, this will be the spatial extent of your final composite image (you’ll need to select the pixel spacing which will determine the image size, origin is the min coordinates of the mapped points and image direction is identity). You then resample all of the images to this coordinate system and compose each pixel/voxel into a single value somehow, mean/median/…, (you’ll have multiple values per pixel/voxel in areas of overlap).

For a more comprehensive overview of SimpleITK/ITK fundamental concepts see this read-the-docs page.

2 Likes

Thanks a lot for your fast and useful replies. Turns out my problems were mainly due to the ordering of transforms as well as using the inverse transform inappropriately.

1 Like