[vtkusers] Help Display Slice of images on 3D ((vtkImageActor))
Hellice
saouli-abdelhak at hotmail.com
Wed Mar 7 11:57:28 EST 2012
Hi Again well afer Hours of reading examples and testing them i comme up
withe some resulte :
This video on youtube shows my work :
http://www.youtube.com/watch?v=74_RJe47-js&feature=youtu.be
http://www.youtube.com/watch?v=74_RJe47-js&feature=youtu.be
As you can see i did not get he rendring right , i just used a simple ray
cast and applide on Dicom slices
please if you just have some idea to get it done just tell me.
here is my code
--------------------------------------------------------------------------------------------
*
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkPiecewiseFunction.h"
#include "vtkThreshold.h"
#include "vtkRenderer.h"
#include "vtkVolumeProperty.h"
#include "vtkRenderWindowInteractor.h"
#include <vtkDICOMImageReader.h>
#include <vtkDataSetTriangleFilter.h>
#include <vtkVolumeRayCastMapper.h>
#include <vtkImageData.h>
#include "vtkColorTransferFunction.h"
#include <vtkVolumeRayCastCompositeFunction.h>
#include <vtkVolume.h>
#include <vtkDICOMImageReader.h>
using namespace std;
int main()
{
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
renWin->AddRenderer( ren1 );
iren->SetRenderWindow( renWin );
vtkDICOMImageReader *reader = vtkDICOMImageReader::New();
reader->SetDirectoryName("Data");
reader->Update();
vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();
opacityTransferFunction->AddPoint(20.0,0.0);
opacityTransferFunction->AddPoint(255.0,2.0);
vtkColorTransferFunction *colorTransferFunction =
vtkColorTransferFunction::New();
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,1.0);
colorTransferFunction->AddRGBPoint(192.0,1.0,0.0,0.0);
colorTransferFunction->AddRGBPoint(255.0,0.0,0.2,0.0);
vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
volumeProperty->SetColor( colorTransferFunction );
volumeProperty->SetScalarOpacity( opacityTransferFunction );
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationTypeToLinear();
vtkVolumeRayCastCompositeFunction *compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
vtkVolumeRayCastMapper *volumeMapper = vtkVolumeRayCastMapper::New();
volumeMapper->SetVolumeRayCastFunction( compositeFunction );
volumeMapper->SetInputConnection ( reader->GetOutputPort() );
vtkVolume *volume = vtkVolume::New();
volume->SetMapper( volumeMapper ) ;
volume->SetProperty ( volumeProperty );
ren1->AddVolume( volume );
ren1->SetBackground(0.1,0.21,0.31);
renWin->SetWindowName("Volume");
renWin->SetSize(500,500);
renWin->Render();
iren->Start();
return 0;
}
*
20 mn of your precious for reading and try to figur out the prob and i will
be thankful for eternity ^^
--
View this message in context: http://vtk.1045678.n5.nabble.com/Help-Display-Slice-of-images-on-3D-vtkImageActor-tp5533571p5544760.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list