[vtkusers] Volume Rendering
Lisa S. Avila
lisa.avila at kitware.com
Thu Oct 18 09:57:21 EDT 2001
Hi Massimiliano,
You need to set the scalar type that you are reading. I suspect it defaults
to unsigned char and you have unsigned short - hence you seem to have two
copies of the data (the upper 8 bits and the lower 8 bits).
Lisa
At 09:49 AM 10/18/2001, lappadj at libero.it wrote:
>Hi john,
>thank for your help,but i think that the problem is different,i try to
>visualize only one slice with this simple code:
>
>
>#include"vtkImageReader.h"
>#include"vtkImageViewer.h"
>#include"SaveViewerImage.h"
>#include"vtkBMPReader.h"
>
>
>void main(int argc, char*argv[])
>{
>
>
>vtkImageReader *reader = vtkImageReader::New();
> reader->SetDataByteOrderToLittleEndian();
> reader->SetDataExtent(0,255,0,255,1,64);
> reader->SetFilePrefix("c:/vtkdata/patnum/pat");
> reader->SetDataOrigin(-127.5, -127.5, -32);
>
>
> reader->SetDataMask(0x7fff);
> reader->Update();
>
>
>vtkImageViewer *viewer = vtkImageViewer::New();
> viewer->SetInput(reader->GetOutput());
> viewer->SetZSlice(3);
> viewer->SetColorWindow(65536);
> viewer->SetColorLevel(32768);
>
>viewer->Render();
>
> SAVEVIEWERIMAGE (viewer);
>
>
>char dummy = '\0';
> cin >> dummy;
>
>
>reader->Delete();
>viewer->Delete();
>
>}
>and the result is the same:two image in the render window!At this time
>i enclose one image.
>Thanks for any suggestion!
>
>Massimiliano La Paglia
>
>
>
> > Massimiliano,
> >
> > Perhaps if you posted an image of the render window on a website
>somewhere (I
> > don't think you can attach and image to the users group mailing list)
>someone
> > could spot the problem. Its hard to tell what your problem could be
>from the
> > code. You may also want to run your volume read from bmp (imagein)
>through
> > vtkImageLuminance. That helped when I got an ugly render trying to
>work with bmp
> > images...I think I was trying to render the indexed color values
>instead of the
> > intensity. Hope this helps, john
> >
> >
> >
> > Internet Mail Message
> > Received from host: public.kitware.com
> > [208.136.18.25]
> >
> >
> >
> > From: "lappadj at libero.it" <lappadj at libero.it>@public.kitware.com on
>10/12/2001
> > 10:38 PM ZE2
> >
>
> > "lappadj at libero.it" To:
>"vtkusers"
> > <lappadj at libero.it>@public.kitware.com
><vtkusers at public.kitware.com>
> > Cc: (bcc: John
>Anast-JM/PGI)
> > Subject: [vtkusers]
>Volume Rendering
> > Sent
>by:
> > vtkusers-
>admin at public.kitware.com
>
> > 10/12/2001 04:38
>PM
> >
>
> >
>
> >
> >
> >
> >
> > Hi,
> > i utilize this code for rendering one volume of Bmp slices from MRI
> > scan,but the effect of the rendering is not good,the resultant image
> > appear split in two half,is possible to be one error on the slices
> > format,because i convert dicom images into bmp images?Can you help me?
> > Thanks a lot
> >
> > Massimiliano La Paglia
> >
> > #include "vtkRenderer.h"
> > #include "vtkRenderWindow.h"
> > #include "vtkRenderWindowInteractor.h"
> > #include "vtkStructuredPointsReader.h"
> > #include "vtkPiecewiseFunction.h"
> > #include "vtkVolumeProperty.h"
> > #include "vtkVolumeRayCastCompositeFunction.h"
> > #include "vtkVolumeRayCastMapper.h"
> > #include "vtkVolume.h"
> > #include "vtkBMPReader.h"
> >
> > #include "SaveImage.h"
> >
> > void main( int argc, char *argv[] )
> > {
> > // Create the renderer, render window, and interactor
> > vtkRenderer *ren1 = vtkRenderer::New();
> > vtkRenderWindow *renWin = vtkRenderWindow::New();
> > renWin->AddRenderer(ren1);
> > vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> > iren->SetRenderWindow(renWin);
> >
> > //Legge bmp file
> > vtkBMPReader *imagein=vtkBMPReader::New();
> > imagein->SetFilePrefix ("C:/vtkdata/knee/pat");
> > imagein->SetDataExtent(0, 255, 0, 255,1,64);
> >
> >
> > // Create a transfer function mapping scalar value to opacity
> > vtkPiecewiseFunction *oTFun = vtkPiecewiseFunction::New();
> > oTFun->AddSegment(80, 0.0, 255, 1.0);
> >
> > // Create a transfer function mapping scalar value to color (grey)
> > vtkPiecewiseFunction *cTFun = vtkPiecewiseFunction::New();
> > cTFun->AddSegment(0, 1.0, 255, 1.0);
> >
> > // Create a property for the volume and set the transfer functions.
> > // Turn shading on and use trilinear interpolation
> > vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
> > volumeProperty->SetColor(cTFun);
> > volumeProperty->SetScalarOpacity(oTFun);
> > volumeProperty->SetInterpolationTypeToLinear();
> > volumeProperty->ShadeOn();
> >
> > // Create a ray function - this is a compositing ray function
> > vtkVolumeRayCastCompositeFunction *compositeFunction =
> > vtkVolumeRayCastCompositeFunction::New();
> >
> > // Create the volume mapper and set the ray function and scalar
>input
> > vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New
>();
> > volumeMapper->SetInput(imagein->GetOutput());
> > volumeMapper->SetVolumeRayCastFunction(compositeFunction);
> >
> > // Create the volume and set the mapper and property
> > vtkVolume *volume = vtkVolume::New();
> > volume->SetMapper(volumeMapper);
> > volume->SetProperty(volumeProperty);
> >
> > // Add this volume to the renderer and get a closer look
> > ren1->AddVolume(volume);
> > ren1->GetActiveCamera()->Azimuth(20.0);
> > ren1->GetActiveCamera()->Dolly(1.60);
> > ren1->ResetCameraClippingRange();
> >
> > renWin->SetSize(300,300);
> >
> > renWin->Render();
> >
> > SAVEIMAGE( renWin );
> >
> > // Interact with the data at 3 frames per second
> > iren->SetDesiredUpdateRate(1.0);
> > iren->SetStillUpdateRate(0.001);
> > iren->Start();
> >
> > // Clean up
> > ren1->Delete();
> > renWin->Delete();
> > iren->Delete();
> > imagein->Delete();
> > oTFun->Delete();
> > cTFun->Delete();
> > volumeProperty->Delete();
> > compositeFunction->Delete();
> > volumeMapper->Delete();
> > volume->Delete();
> > }
> >
> >
> >
> >
> >
> > _______________________________________________
> > 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
> >
> >
> >
> > _______________________________________________
> > 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
> >
More information about the vtkusers
mailing list