POV-Ray : Newsgroups : povray.newusers : isosurface rendering of volume data : Re: isosurface rendering of volume data Server Time
28 Jul 2024 12:25:41 EDT (-0400)
  Re: isosurface rendering of volume data  
From: Alain
Date: 30 Jun 2009 10:58:56
Message: <4a4a2830@news.povray.org>

> Alain <aze### [at] qwertyorg> wrote:

>>> I have a stack of binary images i.e each image is a 2D array and all such images
>>> combined to give a 3D array.
>>> I had previously used MATLAB's isosurface,isocaps and patch functions to
>>> get the visualisation of the volume data, but its too slow.
>>> Is there a way by which I can import such a 3D volume data from matlab to POV
>>> ray and then extract the isosurfaces from that data and render it ?
>>>
>>>
>> Convert those image into the TGA format and use a tga to 3df combiner to
>> combine them in a single 3FD file.
>>
>> That file can then be used to generate an isosurface or as a density
>> pattern for a media.
>>
>> Alain
> 
> I combined all my tga images into a .df3 file format
> then i m doing this
> 
> #declare DENSFUNC=function
> {
>     pattern
>     {
>         density_file df3 "imoil.df3"
>         interpolate 3
>     }
> }
> isosurface {function { .2 - DENSFUNC(x,y,z) } }
> 
> but just a blank screen is rendered.
> is my coding incorrect or do I need to alter the cam/light/threshold values ?
> 
> 
> 

Your isosurface need some pigment otherwise, it use the default one that 
is black.
Sample texture for the isosurface (add between the "} }":

texture{pigment{rgb<1,1,1>}finish{specular 0.5 roughness 0.001}}
//A simple shiny white texture.

You also need a light_source.
Sample light_source:

light_source{<0.9,0.7,-10> rgb<1,1,1>}

If you don't define a camera, the default one is at the origin and look 
toward +z. You can create a camera or translate the isosurface in front 
of the camera.
Sample camera looking at the center of the untransformed isosurface:

camera{location<0,0,-2> look_at<0.5,0.5,0.5>}

You may need to translate and scale the isosurface as the function is 
deffined in a cube going from <0,0,0> to <1,1,1>. Deffining the 
container as:
box{0,1}
can improve the rendering speed as you don't sample undeffined regions.
Add after the function and before the texture:

contained_by{box{0,1}}

interpolate 3 is NOT valid. The only valid values are 0, 2 and 4.
interpolate 0 is no interpolation. It gives a blocky aspect and causes 
the max_gradient to be extremely large.
interpolate 2 is bi-linear interpolation. Nice smooth shape. 
max_gradient down to a reasonable range. You should use that value most 
of the time.
interpolate 4 is bicubic interpolation and is buggy. Used properly, it 
gives the best results. Will gives horible result if there are abrupt 
changes to zero or the maximum value.
A value other than 2 or 4 is interpreted as 0.

If you want to use interpolate 4, you need to make sure that the values 
of the DF3 never reatch the extreeme values. Low values should be 1s or 
2s. High values should be 253s or 254s (if using 1 byte per voxel).

Do a test render and look at the report for a mention about the 
max_gradient. Add: max_gradient [a little less than the value reported] 
after the function. (if the value found is 1250, a value of 1200 should 
be acceptable)
Do another render.


Alain


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.