[Insight-users] visualization of the 3d segmentation result
Popa Teo
popateodoru at yahoo.com
Tue Nov 15 12:23:03 EST 2005
One of the options to visualize your 3d data is to use volume representation
Here I show you some code that use VTK for the visualisation.
VTK has several options for composite (means you use color) volume visualisation:
-vtkVolumeTextureMapper2D
-vtkVolumeTextureMapper3D
-vtkVolumeRayCastMapper
-vtkVolumeProMapper
The c++ partial code,you still need to create additional classes like vtkRenderer ,vtkRenderWindow,,vtkRenderWindowInterator also you have to copy the files itkImageToVTKImageFilter.txx and .h in your project:
#include "vtkVolumeProperty.h"
#include "vtkPiecewiseFunction.h"
#include "vtkVolume.h"
#include "vtkColorTransferFunction.h"
#include "itkImageToVTKImageFilter.h"
#include "vtkVolumeTextureMapper2D.h"
/*Pass the data to vtk from a itk class ( file_reader in this example)*/
typedef itk::ImageToVTKImageFilter< ImageType > ConnectorFilterType;
ConnectorFilterType::Pointer connector = ConnectorFilterType::New();
connector->GetExporter()->SetInput( file_reader->GetOutput() );
connector->GetImporter()->Update();
connector->Update();
/*Select the volume method*/
vtkVolumeTextureMapper2D* VolumeMapper = vtkVolumeTextureMapper2D::New();
VolumeMapper->SetInput(Reader->GetOutput());
/*Define the functions that will map your density values fromm your data to color and opacity i.e all the voxels with value 0 will have color 0,0,0 or black*/
vtkPiecewiseFunction* OpacityTransferFunction=vtkPiecewiseFunction::New();
vtkColorTransferFunction* ColorTransferFunction=vtkColorTransferFunction::New();
OpacityTransferFunction->AddPoint(0, 0.0);
OpacityTransferFunction->AddPoint(2048, 0.1);
OpacityTransferFunction->AddPoint(2048+1, 0.0);
ColorTransferFunction->AddRGBPoint(0 0.0, 0.0, 0.0);
ColorTransferFunction->AddRGBPoint(2048/4, 1, 0, 0);
ColorTransferFunction->AddRGBPoint(2048/2, 0, 0, 1);
ColorTransferFunction->AddRGBPoint(2048/4*3, 0, 1, 0);
ColorTransferFunction->AddRGBPoint(2048, 1, 1, 1);
vtkVolumeProperty* VolumeProperty = vtkVolumeProperty::New();
VolumeProperty->SetColor(ColorTransferFunction);
VolumeProperty->SetScalarOpacity(OpacityTransferFunction);
vtkVolume* VolumeActor = vtkVolume::New();
VolumeActor->SetMapper(VolumeMapper);
VolumeActor->SetProperty(VolumeProperty);
Or better in your case you can use Surface Representation instead of Volume.This is much suited for binary data visualization
Here is the c++ partial code:
vtkImageMarchingCubes * marcher = vtkImageMarchingCubes::New();
marcher->SetInput(image);
marcher->SetValue(1,1.0);//Here 1.0 represent the voxel value of your binary data
marcher->Update();
vtkSmoothPolyDataFilter* smoother = vtkSmoothPolyDataFilter::New();
smoother->SetInput(marcher->GetOutput());
smoother->SetNumberOfIterations(5);
smoother->SetFeatureAngle(60);
smoother->SetRelaxationFactor(0.05);
smoother->FeatureEdgeSmoothingOff();
std::cout << "VTK Smoothing mesh finished...." << std::endl;
// render 3D model
vtkPolyDataMapper* isoMapper = vtkPolyDataMapper::New();
isoMapper->SetInput(smoother->GetOutput());
isoMapper->ScalarVisibilityOn();
vtkActor * SurfaceExtractor = vtkActor::New();
SurfaceExtractor->SetMapper(isoMapper);
SurfaceExtractor->GetProperty()->SetDiffuseColor(1,1,0.9412);
Teo
ilker hacýhaliloðlu <hacihaliloglu at gmail.com> wrote:
hi all
i have segmented a 3D image now i wantto visualize it what can i use ?
ilker
_______________________________________________
Insight-users mailing list
Insight-users at itk.org
http://www.itk.org/mailman/listinfo/insight-users
---------------------------------
Yahoo! FareChase - Search multiple travel sites in one click.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20051115/0fac9e66/attachment.htm
More information about the Insight-users
mailing list