[vtkusers] Re: 5. Desperate need of help with vtkImageReslice !! (Naoko TAKAYA)
Audrius Stundzia
audrius at adv-biologic.com
Mon Sep 16 02:30:11 EDT 2002
Dear Naoko,
Great to hear from you!
Here's a quick reply to your last question:
> 5. Desperate need of help with vtkImageReslice !! (Naoko TAKAYA)
>
>Message: 5
>Date: Mon, 16 Sep 2002 08:48:20 +0900
>From: Naoko TAKAYA <takaya at cv.cs.ritsumei.ac.jp>
>To: VTK <vtkusers at public.kitware.com>
>Subject: [vtkusers] Desperate need of help with vtkImageReslice !!
>
>Dear VTK-users!!
>
>I'm trying to extract slice from volume but it's not
>working...
>
>Please tell me what I'm missing out ?
>
>Also, I don't exactly know what SetResliceAxesOrigin
>and SetOutputOrigin does...
>
>My brief code is as follows;
>------------------------------------------------------------
>vtkUnsignedCharArray *vScalars = vtkUnsignedCharArray::New();
>vtkRendererer *vRenderer = vtkRenderer::New();
>vtkStructuredPoints *vVol = vtkStructuredPoitns::New(); //----- This line didn't compile did it? vtkStructuredPoitns -> vtkStructuredPoints
//-----Before setting the scalars you have to tell vtk that they are scalars and that they are of type VTK_FLOAT, etc.
vVol->SetScalarType( VTK_FLOAT);
vVol->SetNumberOfScalarComponents( 1);
vVol->AllocateScalars();
> vVol -> SetDimensions( 512, 512, 300);
> vVol -> SetSpacing(1, 1, 1);
//-----Specify the origin of the image volume in the lower left hand corner of the volume
//-----The choice below will put (0.0, 0.0, 0.0) in the centre of vVol.
vVol -> SetOrigin( -256.0 , -256.0, -150.0);
> vVol -> GetPointData()->SetScalars(vScalars);
> vVol -> Update();
>vtkImageReslice *vReslice = vtkImageReslice::New();
> vReslice -> SetInput(vVol);
//-----Some additional specs
vReslice->WrapOff();
vReslice->MirrorOff();
vReslice->SetInterpolationModeToLinear();
vReslice->OptimizationOn();
vReslice->ReleaseDataFlagOn();
vReslice->SetBackgroundColor( 0.0, 0.0, 0.0, 0.0 );
//-----Translation: This set the origin of the slicing plane. I've put in an arbitrary location - in the centre of the volume
vReslice -> SetResliceAxesOrigin( 0.0, 0.0, 0.0);
//-----Rotation: This sets the orientation of the slicing plane
vReslice -> SetResliceAxesDirectionCosines( 1.0, 0.0, 0.0, 0.0, 1.0 ,0.0, 0.0, 0.0, 1.0 );
//-----512 voxels -> extent is 0 to 511, etc.
vReslice -> SetOutputExtent( 0, 511, 0,0, 0, 299 );
> vReslice -> SetOutputSpacing( 1.0, 1.0, 1.0);
//-----Origin of the 2D relice output
vReslice -> SetOutputOrigin( -256.0 , 0.0, -150.0)
>vtkImageMapper *vImgMapper = vtkImageMapper::New();
> vImgMapper -> SetInput(vReslice->GetOutput());
> vImgMapper -> SetColorWindow(255);
> vImgMapper -> SetColorLevel(127.5);
>vtkActor2D *vActor2D = vtkActor2D::New();
> vActor2D -> SetMapper(vImgMapper);
>vRenderer -> AddActor2D(vActor2D);
I've also added an example. I hope that all of this is of some help.
>
>Please give me advice!!
>(and please excuse my English....)
No worries. Your English is great and you South African accent is beautiful! ;-)
Dewa mata ;-)
Audrius-yori
______________________________________________
Galileo: Advancing Medicine Through Science
Audrius Stundzia, Ph.D.
CEO
Advanced Biologic Corporation
245 Dixon Road, Suite 152
Toronto, Ontario M9P 2M4
Canada
Tel: 416 247 7986
Fax: 416 247 0881
Net: audrius at adv-biologic.com
______________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: advImageResliceExample.cpp
Type: application/octet-stream
Size: 3122 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20020916/2a44a4e2/attachment.obj>
More information about the vtkusers
mailing list