[vtkusers] RE: Ray casting process problems?
Chong Zhang
chong.zhang at upf.edu
Mon Dec 18 07:19:14 EST 2006
Hi all,
It's me again. Maybe my previous question was not clearly explained. I will
try to explain it with a more specific way. Sorry to bother again.
As I mentioned before, I was generating the projection images of a synthetic
data by rotating the camera (vtkCamere type) around the volume. The camera's
position is determined by a transformation matrix (vtkMatrix4x4 type),
computed by 2 rotational angles. The program worked fine, except for some
angles, the projection image looked like: 1) shifted in some pixel
positions; 2) some part of the phantom is truncated; 3) some extra structure
in the projected image. I was trying to tune some parameters, such as using
trilinear interpolation, ray sample size to be 0.1 unit of the volume
spacing (0.05*0.1=0.005), etc. The problem could not be solved by these
trials. I also tried to modify a little bit of the 2 rotational angles, for
example, replace the original angle A (A is in degree unit) by A+0.02, this
results a slight change in camera position. But with this 0.02 degree
changes, the projection data looked correctly projected.
Does anyone have idea of what happened there?
Thanks in advance,
Chong
_____
From: Chong Zhang [mailto:chong.zhang at upf.edu]
Sent: Friday, December 15, 2006 17:27 PM
To: 'vtkusers at vtk.org'
Subject: Ray casting process problems?
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/20061218/1704b25b/attachment.htm>
More information about the vtkusers
mailing list