Skip to main content
gamedev.net
🔒 Locked

Convolution and entropy

Started by trancemission 2 replies 1.1k views
Original Post
trancemission
trancemission
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.
Jason Z
Jason Z
I'm not sure I completely understand what the issue that you are describing is. If you want to do a convolution of the 3D voxels with a 3D kernel, then why not do the convolution in the spatial domain instead of the frequency domain? Or is the kernel defined in the frequency domain already?

Perhaps I don't properly understand what you are trying to do...
Jason Zink :: DirectX MVP   Direct3D 11 engine on CodePlex: Hieroglyph 3 Direct3D Books: 
KulSeran
KulSeran
Not sure it would save you much, but you could compute a list of all of voxel indices inside a sphere of size X centered at 0,0,0. Then for each grid coordinate, you could then use your computed list offset by the current grid coordinate. Though this keeps you from having to compute "is this in the sphere" you'd still have to do all the checks "is xyz + x'y'z' in my grid?".
trancemission
trancemission
Thanks for your replies. I am working in the spatial domain only. KulSeran, I am precomputing the spherical indices just as you suggested. Indeed, it does help a bit.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.