Original Post
Hi all, I have an issue that I've worked on for a while, but seems I can't get it done on my own. Here's the problem. I have a 3D matrix of uint8s (essentially a grayscale 3D image). This can be very large (as in 512x256x256 voxels,32 MB). I would like to compute the convolution of this image with a spherical mask of arbitrary size (range 4-24 pixels radius). I know this can be done using FFT, in a distributed way to avoid using enormous amounts of memory. But the FFT does not help me with computing the entropy within the spherical mask. Namely, to compute the entropy, I need the histogram of grayscale levels of the voxels within the sphere (of desired radius) centered at the current voxel (where the current voxel runs through all the voxels in the image). It seems to me there is no way to get around computing the indices of the voxels located in the sphere centered at the current voxel. Storing these indices requires huge amounts of space (I need the 3D convolution and 3D entropy for multiple images), even with some overlap-save method along largest dimension. Notice that I cannot store 3 indices as uint8 (image dimensions run >255) so it's better to store as linearized index with type uint32. When sphere radius is 24 and with no overlap-save, I would store 57777 such triplets, that is 231108 bytes. But if I want to do this for each voxel the amount of space is ~7 Tb :) (obviously impossible). But the reason is there is huge redundancy. So not sure how to get rid of it. Any suggestions on efficiently implementing this are appreciated. Thank you.