2.54 Beta: How to setup volumetric textures using the Blender Voxel format

Thanks for looking into this bug which i did not know about ! LOL

from what built is this corrected ?
i tested it in 33191 and not working !

and are there other examples of using voxel let say with some particules system?

and are there any good wiki page on theses voxel ?
cause i search wiki and did not find anything

Thanks happy 2.5

Thanks for taking the time, Matt. I’m not really trying to get accurate medical usage out of it, but it is a nice feature for rough visualization :). Not if only I was smart enough to write something that would create a surface render out of slices, I’d be a step closer to where I want to be, but GE, Philips, Vitrea, and others are pretty tight with their algorithms. I’m pretty sure they are using some sort of maximum pixel intensity values or grey scale Hounsfield units that define the density of tissues to define points in space and deriving a mesh out of it, but I have no idea.

well for algos there are some available at ImageJ but not in python
but i guess it might be possible to so some conversion to python if someone has the time!

salutations

Hi ajm, it’s actually not a difficult thing to do, google isosurface rendering - you just step through the volume until you reach a threshold density, then stop, examine the volume nearby to generate a normal, then pass that info off to the rest of the shading engine.

What’s implemented in blender doesn’t have that capability though - its ancient shading system is not designed in a way that allows that sort of integration easily.

That file is a raw binary voxel file, it just contains a grid of volume data all in one big chunk.

I would love to know how to get data to be loadable as 8 bit RAW file format. Say I have a spreadsheet with x,y,z coordinates of stars or densities in a gas volume. How do I make this data usable as voxel data? I tried to download the data file for the plastic skull to find out what the data looks like, but the link is broken.

Thanks!

You can do it pretty easily if you know python - here’s a quick little example script I wrote that makes a 64x64x64 voxel grid, containing a sphere of volume. Can just run it from the console, “python myscript.py”.

You can see that’s storing it in 8bit format, since I’m using ‘B’ to store unsigned bytes, in struct.pack().


import struct

xres = yres = zres = 64

xcent = 0.5
ycent = 0.5
zcent = 0.5
radius = 0.45

filename = "/Users/matt/Desktop/voxelsphere.raw"

file = open(filename, "wb")

for z in range(zres):
    zn = z / float(zres)
    zc = zn - zcent
    		
    for y in range(yres):
        yn = y / float(yres)
        yc = yn - ycent
    			
        for x in range(xres):
            xn = x / float(xres)
            xc = xn - xcent
            
            # formula of sphere
            if xc*xc + yc*yc + zc*zc < radius*radius:
                file.write(struct.pack('B', 255))
            else:
                file.write(struct.pack('B', 0))


file.flush()
file.close()

Thanks for your quick reply, broken! I can’t really say I know python, but I can give the script a try and attempt to modify it as necessary.

sorry, i don’t code, maybe it’s a stupid question:
can we wrote some kind of script that exports an 8 bit raw file from a mesh, to be used as voxel data file? which would be the extension?

thanks in advance.

Yes, it’s quite possible - I wrote an old script for this for 2.49 here: http://mke3.net/projects/bpython/export_object_voxeldata.py which gives the results here: http://vimeo.com/2512028 , http://vimeo.com/2453383

That was a really basic test, but it shouldn’t be difficult for someone to update it to 2.5 and make it more reliable and quicker (no, I don’t have time atm :).

well, thanks a lot for the quick answer! Maybe this is one more excuse to learn python… :smiley:
Thanks again!

This is excellent - thank you.
Can you/do you know how to store multiple frames in one .raw file?

Also - for anyone else using this script - when using this as voxel data in a texture you have to set ‘Still Frame’ and set to frame 1.

hallo volume renderers, here again, i am still dealing with the same frustrating problem : i want (actually really have to) to render that cursed plastic skull which comes in voxel data format from a CT machine. i uploaded again re-created 8bit binary versions of this DICOM data set and also some PNG files i just created with blender v2.57b on 64bit linux. ‘2bit’ means two values, [0 1] or [0 255], while 8bit contains the full range of the plastic density, rescaled to [0-255].

URL :

http://www.pistikem.org/blender/

files :

skull8bit_2bit_0_1_512x512x233.bin.bz2
skull8bit_2bit_0_255_512x512x233.bin.bz2
skull8bit_8bit_0_255_512x512x233.bin.bz2
skull8bit_2.png
skull8bit_3.png
skull_20110612b.blend

so, it seems to me that i am getting something but still the same what Mr. ‘broken’ showed in his picture above. what do i do wrong? please, look at the included BLEND file. i work my self heavily in image processing but here i am truly lost, Blender looks like a black box to me. i simply don’t see the skull in the Preview window for Texture or Material when i start setting up things from scratch (but i get the same skull surface rendering like above with the help of that skull.blend file). obviously does my own rendering not result in any skull shape.

BUT, unfortunately, also the successful rendering’s surface quality is far from anything useful for an IGES-CAD output at the end.

ALTERNATIVE : is there a way to compute this voxel-based skull’s surface and import it as a mesh ?

i truly need this for a neuroscience project very urgently…any help greatly appreciated. thanks!

Hi valaki, I get an “Error 403 - forbidden” for the URL you gave. And I can’t figure out from the rest of the post exactly what the problem is, so I need the pictures. What exactly goes wrong for you when rendering?