[vtkusers] Ray casting process problems?
Chong Zhang
chong.zhang at upf.edu
Fri Dec 15 11:27:15 EST 2006
Dear all,
I am using vtkVolumeRayCastCompositeFunction to perform volume rendering.
But I keep getting strange rendering results (I attached some of the
snapshot images in this email).
My volume data is a phantom with spacing 0.05*0.05*0.05 (mm). With this
data, I was generating a series of snapshot images of the rendered volume
from different viewing positions, by moving the camera (of vtkCamera type)
around the volume data. The code related with the rendering is the
following:
volProperty is an instance of vtkVolumeProperty, ctFunc and otFunc are the
transfer functions from the volume intensity value to the its opacity and
color. Either Nearest or Trilinear interpolation methods were used, stepSize
are related to the volume spacing (I used 1 spacing, means 0.05, and 0.1
spacing, means 0.005).
volProperty->SetColor( ctFunc );
volProperty->SetScalarOpacity( otFunc );
//this->volProperty->SetInterpolationTypeToLinear();
volProperty->SetInterpolationTypeToNearest();
volProperty->SetScalarOpacityUnitDistance( stepSize );
mapper is an instance of vtkVolumeRayCastMapper, sample distance is
depending on the volume spacing as well.
vtkVolumeRayCastCompositeFunction* raycastFunction =
vtkVolumeRayCastCompositeFunction::New();
mapper->SetVolumeRayCastFunction( raycastFunction );
mapper->SetSampleDistance( stepSize );
volume is the phantom data.
volume->SetMapper( mapper );
volume->SetProperty( volProperty );
The following is the usual vtk rendering pipeline stuff and the snapshots.
ren->AddVolume( volume );
renWin->SetSize( 512, 512 );
renWin->AddRenderer( ren );
vtkRenderLargeImage *renLarge = vtkRenderLargeImage::New();
renLarge->SetInput( ren );
renLarge->SetMagnification( 4.0 );
renLarge->Update();
vtkPNGWriter *writer = vtkPNGWriter::New();
writer->SetFileName( imgName );
writer->SetInput( renLarge->GetOutput() );
writer->Write();
writer->Delete();
Most of the snapshot images looks okay, at least visually. But for some
specific viewing position snapshots, the image are distorted, the distortion
effect has different formations, as can be seen from the attached example
images. Why I say it is some specific viewing positions, because the
distorted images were always generated from those viewing positions, no
matter the "stepSize" value. Images number, for example, 018, 024, 032, 034,
035, 068, etc, are the ones that have distorted effects. My phantom is a
fused combination of one bended cylinder, one thinner cylinder, one sphere,
and another smaller sphere. I don't understand why this happens?
Even more weird, sometimes the program just crashed somewhere, but when I
tune a very little bit of the camera position, it worked fine. This
happened, in particular, when I set the interpolation method to be
trilinear, and using stepSize to be 0.005(0.1 spacing of the volume). I
tried to debug the code, the crashed point was at the trilinear
interpolation calculation. It looked as if the stepSize was too small, then
the ray "depth" (sample units) values are too big, and therefore the machine
can not reach it.
Does some of you have any idea about all these? Any suggestion and
discussion are appreciated!
Best,
Chong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061215/56ccf777/attachment.htm>
More information about the vtkusers
mailing list