subsampling a volume

It might be quite obvious to many but I cant seem to resample a volume to a lower resolution. For example, if I have a 512x512x512 volume, how would I resample it to 256x256x256 volume. I would greatly appreciate any help.
thanks a lot,

small[x,y,z] = (
big[2x,2y,2z] +
big[2x,2y,2z+1] +
big[2x,2y+1,2z] +
big[2x,2y+1,2z+1] +
big[2x+1,2y,2z] +
big[2x+1,2y,2z+1] +
big[2x+1,2y+1,2z] +

simple boxfilter… do this for each small[] texel.

i tried this but am getting some weird output. does the volume have to be a regular volume like 512x512x512 or 256^3. My volume is 512x512x256 and i am trying to resample it to 256x256x128. Its looking like each of the 8 components is seperate and i see eight different sections of the volume sort of. Hope that makes some sense. Here is a screenshot to make it easier to understand.
[img]Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos
The central oval is the actual volume.

[This message has been edited by alark (edited 08-26-2003).]

Sounds like you’re not properly compensating for the pixel format of your pixels. Note that the pseudo-code didn’t separate out R, G, B and A; your real code of course has to do that.

Just do the same technique used to resize 2D textures/bitmaps and add one more dimension.