Why does SimpleITK crash during ResampleImageFilter execution?

200 views Asked by At

On Ubuntu 18.04 LTS I try to change the voxel spacing of a 3D image like in this example. The image is pretty large with around 500x500x300 voxels and uses around 100MB. When the line resampler.Execute() is reached the shell stops executing the python3 script. I think this is because of a lack of memory, but which memory? Harddisk? RAM? Does anyone know why this might happen and if there is any workaround?

1

There are 1 answers

2
Dave Chen On

You're running out of RAM. You volume is 75 million voxels, but that resampling example code is using 32-bit floating point numbers. So that's 300 megabytes of memory. And then there's memory of the output volume. So who knows how much memory you're needing in total.

Try setting the output pixel type to something smaller, like a signed short or an unsigned char.