animation with bspline registration

Please I would like to make an animation suitable in gif format to see the different stages the registration does.
I am using the example from here
please how can I do this?

Thank you

We have done something similar for the SimpleITK notebooks:

You can find the script that was used to generate it here:

You should be able to adapt is to your particular registration method easily enough.

2 Likes (6.6 KB)

please I still get some errors
RuntimeError: Exception thrown in SimpleITK ImageRegistrationMethod_Execute: C:\d\VS14-Win64-pkg\SimpleITK\Wrapping\Python\sitkPyCommand.cxx:135:
sitk::ERROR: There was an error executing the Python Callable.

You will need to add try-except inside you Python callable used in the events to get the error encountered. It may even be a syntax error the callables can be skittle tricky to debug and get right.

The error is with the save_plot function. It says tuple index out of range. Please any ideas on how I can fix this?

central_index = round((f.GetSize())[2] / 2)

IndexError: tuple index out of range

Perhaps len(f) is only 2?

I have not looked closely at your script ( or the original for a while), maybe your image is a different dimension that what is expected?

The files used in the example has .mha extension like training_001_mr_T1.mha but I am testing with .png files.
Do you think this is the problem?

Have you inspect the original image and your images? Do you know their dimensions, sizes, pixel types?

The size of my image is 256 by 256 and it is a gray scale image

yeah that is the problem. The test image has width, height and color values, but my image just have width and height. Is there a way I can make it work without the color values?


@henrisco82 ,
The original script dealt with 3D scalar images, no color values. The blended slices are combined and converted to color by repeating the scalar value in all channels (see the line saying "convert grayscale image to color (r,g,b)). As you are working in 2D you will have to modify the code to deal with it (e.g. you don’t need all of the slice extraction, see references to central_index in the script).

The need for using color is because we wanted the similarity metric graph to be in color, so the alpha blended grayscale extracted slices were also converted to color.

 hope this clarifies things