[vtkusers] 3D MRI Volume.

anast.jm at pg.com anast.jm at pg.com
Thu Apr 17 11:05:05 EDT 2003


Yasser,

I think your data spacing needs to be corrected to the actual spacing of 
the MRI data. I doubt that with 15 slices that the x=y=z spacing. I 
suspect z is 5-10 times larger
Reader->SetDataSpacing(1,1,1);
maybe something like
Reader->SetDataSpacing(0.8,0.8,4.0); 

Also where you commented out
//volProperty->SetOpacity(oTFun);

try

volProperty->SetScalarOpacity(oTFun);

Finally, I've not seen piecewisefunction used to create the color transfer 
function....you might want to try something like this from the examples 
(VTK/Examples/VolumeRendering/Python/SimpleRayCast.py in Python but its 
easily transfered to C++)

# Create transfer mapping scalar value to color
colorTransferFunction = vtk.vtkColorTransferFunction()
colorTransferFunction.AddRGBPoint(0.0, 0.0, 0.0, 0.0)
colorTransferFunction.AddRGBPoint(64.0, 1.0, 0.0, 0.0)
colorTransferFunction.AddRGBPoint(128.0, 0.0, 0.0, 1.0)
colorTransferFunction.AddRGBPoint(192.0, 0.0, 1.0, 0.0)
colorTransferFunction.AddRGBPoint(255.0, 0.0, 0.2, 0.0)


...john



Internet Mail Message
Received from host:     public.kitware.com [24.97.130.19]



yasser salman <yass at uscx.net>
Sent by: vtkusers-admin at public.kitware.com
04/17/2003 07:52 AM
Please respond to yass

 
        To:     vtk users <vtkusers at public.kitware.com>
        cc:     (bcc: John Anast-JM/PGI)
        Subject:        [vtkusers] 3D MRI Volume.


hi all..,
 there is my code to render a 3D Volume of MRI slice., 
it works good but  it displayed in a worng way (contrast is too bad and 
also it seems not fit in the slice it self like the data was overlaped 
each other)
i think the problem in reading the files(or may be in Opacity..).
here is my code:..( i changed the opacity,color but no effect..).. can any 
one help me to find 
where is the problem here?



vtkRenderer *aRenderer = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
    renWin->AddRenderer(aRenderer);
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
    iren->SetRenderWindow(renWin);

 
                 vtkTIFFReader *Reader = vtkTIFFReader::New();
    Reader->SetFilePrefix ("D:/tiff/TIFF/MRI"); //Location of slices
    Reader->SetFilePattern("%s%.4d.tif");
    Reader->SetDataExtent (0,255,0,255,1,15); //No.of slices
                 Reader->SetDataSpacing(1,1,1);
                 Reader->Update();
 
                 vtkPiecewiseFunction *oTFun =vtkPiecewiseFunction::New();
                 oTFun->AddSegment(80,0.0,255,1.0);
                 vtkPiecewiseFunction *gTFun =vtkPiecewiseFunction::New();
                 gTFun->AddSegment(0,1.0,255,1.0);
                 vtkVolumeProperty *volProperty = 
vtkVolumeProperty::New();
                 volProperty->SetColor(gTFun);
 
                 //volProperty->SetOpacity(oTFun);
                 volProperty->SetInterpolationTypeToLinear();
                 volProperty->ShadeOn();

                 vtkVolumeRayCastCompositeFunction *compositeFunction= 
vtkVolumeRayCastCompositeFunction::New();
vtkVolumeRayCastMapper *volMapper = vtkVolumeRayCastMapper::New();
                 volMapper->SetInput(Reader->GetOutput()); 
                 volMapper->SetVolumeRayCastFunction(compositeFunction);

                 vtkVolume *vol=vtkVolume::New();
                 vol->SetMapper(volMapper); 
                 vol->SetProperty(volProperty); 
                 aRenderer->AddVolume(vol);
                 aRenderer->SetBackground(1,1,1);
 
                 vtkCamera *aCamera = vtkCamera::New();
    aCamera->SetViewUp (0, 0, -1);
    aCamera->SetPosition (0, 1, 0);
    aCamera->SetFocalPoint (0, 0, 0);
    aCamera->ComputeViewPlaneNormal();
                  aRenderer->SetActiveCamera(aCamera);
                  aRenderer->ResetCamera ();
                  aCamera->Dolly(1.5);
 
                  renWin->SetSize(640, 480);
                 iren->SetDesiredUpdateRate(3.0);
                 iren->Initialize();
                 iren->Start(); 

thanx.. yasser

_____________________________________________________________
Your own email, free website, free software and services at 

http://www.uscomputer.net/portal.htm 
- courtesy of U.S. Computer Corporation -

_____________________________________________________________
Select your own custom email address for FREE! Get you at yourchoice.com w/No 
Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag
_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: 
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20030417/76b0c938/attachment.htm>


More information about the vtkusers mailing list