[vtkusers] Segmentation for 3D ultrasound data set

shinaji t_shinaji at chiba-u.jp
Thu Nov 29 02:18:39 EST 2012


Hi,

Take try vtkFixedPointVolumeRayCastMapper, it's better than
vtkVolumeRayCastMapper.
The vtkImageThresh worked  in the following code.

See also 
http://vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/VolumeRendering/Cxx/FixedPointVolumeRayCastMapperCT.cxx

        
        double opacityWindow = 4096;
	double opacityLevel = 2048;
	int clip = 0;
	double frameRate = 10.0;

	vtkSmartPointer< vtkDICOMImageReader > reader =
		vtkSmartPointer< vtkDICOMImageReader >::New();
	reader->SetDataByteOrderToLittleEndian();
	reader->SetDirectoryName("E:/DD2319/");
	reader->Update();

	vtkSmartPointer<vtkImageThreshold> thresh =
		vtkSmartPointer<vtkImageThreshold>::New();

	thresh->SetInput(reader->GetOutput());
	thresh->SetInValue(32768);
	thresh->ThresholdBetween(0, 200);

	vtkPiecewiseFunction* opacityFunction =
		vtkPiecewiseFunction::New();
	vtkColorTransferFunction* colorTransferFunction =
		vtkColorTransferFunction::New();

	vtkSmartPointer< vtkVolumeProperty > volumeProperty = 
		vtkSmartPointer <vtkVolumeProperty >::New();
	volumeProperty->SetColor(colorTransferFunction);
	volumeProperty->SetScalarOpacity(opacityFunction);
	volumeProperty->ShadeOn();
	volumeProperty->SetInterpolationTypeToLinear();

	vtkSmartPointer< vtkFixedPointVolumeRayCastMapper > volumeMapper =
		vtkSmartPointer< vtkFixedPointVolumeRayCastMapper >::New();
	volumeMapper->SetInput(thresh->GetOutput());

	vtkSmartPointer< vtkVolume > volume =
		vtkSmartPointer< vtkVolume >::New();
	volume->SetMapper(volumeMapper);
	volume->SetProperty(volumeProperty);


	colorTransferFunction->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0,
1.0 );
	opacityFunction->AddSegment( opacityLevel - 0.5*opacityWindow, 0.0,
		opacityLevel + 0.5*opacityWindow, 1.0 );
	volumeMapper->SetBlendModeToComposite();
	volumeProperty->ShadeOn();


	vtkSmartPointer< vtkRenderer > renderer =
		vtkSmartPointer< vtkRenderer >::New();
	renderer->AddVolume(volume);
	renderer->ResetCamera();

	vtkSmartPointer<vtkRenderWindow> renWin = 
		vtkSmartPointer<vtkRenderWindow>::New();
	
	// Add the volume to the scene
	renderer->AddVolume( volume );
	renderer->ResetCamera();
	renWin->AddRenderer(renderer);

	// Set the default window size
	renWin->SetSize(600,600);
	renWin->Render();

	vtkSmartPointer<vtkRenderWindowInteractor> iren = 
		vtkSmartPointer<vtkRenderWindowInteractor>::New();
	iren->SetRenderWindow(renWin);
	iren->SetDesiredUpdateRate(frameRate / (1+clip) );
	iren->GetInteractorStyle()->SetDefaultRenderer(renderer);
	iren->Start();

	vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter = 
		vtkSmartPointer<vtkWindowToImageFilter>::New();
	windowToImageFilter->SetInput(renWin);
	windowToImageFilter->SetInputBufferTypeToRGBA();
	windowToImageFilter->Update();

Shinaji



--
View this message in context: http://vtk.1045678.n5.nabble.com/Segmentation-for-3D-ultrasound-data-set-tp5717312p5717333.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list