[vtkusers] MIP help
Jesús Spínola
jspinola at gmail.com
Mon Dec 11 07:47:00 EST 2006
This is my MIP code and it works fine for me. Your problem might be you are
using a vtkColorTransferFunction when another vtkPieceWiseFunction should be
enough. Hope this helps :)
vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();
opacityTransferFunction->AddPoint( 20 , 0.0 );
opacityTransferFunction->AddPoint( 255 , 1.0 );
// Create a transfer function mapping scalar value to color (grey)
vtkPiecewiseFunction *grayTransferFunction =
vtkPiecewiseFunction::New();
grayTransferFunction->AddSegment( 0 , 0.0 , 255 , 1.0 );
// Create a set of properties for mip
vtkVolumeProperty *mipProperty;
mipProperty = vtkVolumeProperty::New();
mipProperty->SetScalarOpacity( opacityTransferFunction );
mipProperty->SetColor( grayTransferFunction );
mipProperty->SetInterpolationTypeToLinear();
// creem la funció del raig MIP, en aquest cas maximitzem
l'opacitat, si fos Scalar value, ho faria pel valor
vtkVolumeRayCastMIPFunction* mipFunction =
vtkVolumeRayCastMIPFunction::New();
mipFunction->SetMaximizeMethodToOpacity();
vtkVolumeRayCastMapper* volumeMapper =
vtkVolumeRayCastMapper::New();
volumeMapper->SetVolumeRayCastFunction( mipFunction );
volumeMapper->SetInput( m_imageCaster->GetOutput() );
vtkVolume* volume = vtkVolume::New();
volume->SetMapper( volumeMapper );
volume->SetProperty( mipProperty );
m_renderer->AddViewProp( volume );
m_renderer->Render();
2006/10/2, Michele Marco <michelegr at alice.it>:
>
> I'm italian Student and i need help for setting MIP in VTK . I use vtk vtkVolumeRayCastMIPFunction
> class to realize MIP but i have some problem to configure "vtkPiecewiseFunction"
> and "vtkColorTransferFunction" .The code is :
>
>
> // Create the renderers, render window, and interactor
>
> vtkRenderWindow *renWin = vtkRenderWindow::New();
>
> vtkRenderer *ren = vtkRenderer::New();
>
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>
> renWin->AddRenderer(ren);
>
>
>
>
>
> vtkInteractorStyleTrackballCamera *aTrackBallCamera =
> vtkInteractorStyleTrackballCamera::New();
>
> iren->SetInteractorStyle(aTrackBallCamera);
>
> iren->SetRenderWindow(renWin);
>
>
>
> vtkDICOMImageReader *reader= vtkDICOMImageReader::New();
>
> reader->SetDirectoryName("C:/tac2");
>
> reader->Update();
>
>
>
> vtkImageCast *cast = vtkImageCast::New();
>
> cast->SetInputConnection(reader->GetOutputPort());
>
> cast->SetOutputScalarTypeToUnsignedChar();
>
>
>
> vtkPiecewiseFunction *opacityTransferFunction =
> vtkPiecewiseFunction::New();
>
>
>
> opacityTransferFunction->AddSegment(0, 0.1, 255, 0.9);
>
>
>
>
>
> vtkColorTransferFunction *colorTransferFunction =
> vtkColorTransferFunction::New();
>
> colorTransferFunction->AddRGBPoint( 0, 1.0, 0.0, 0.0 );
>
> colorTransferFunction->AddRGBPoint( 64, 1.0, 1.0, 0.0 );
>
> colorTransferFunction->AddRGBPoint( 128, 0.0, 1.0, 0.0 );
>
> colorTransferFunction->AddRGBPoint( 192, 0.0, 1.0, 1.0 );
>
> colorTransferFunction->AddRGBPoint( 255, 0.1, 0.5, 1.0 );
>
>
>
>
>
> vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
>
> volumeProperty->SetColor(colorTransferFunction);
>
> volumeProperty->SetScalarOpacity(opacityTransferFunction);
>
> volumeProperty->SetInterpolationTypeToLinear();
>
>
>
>
>
> vtkVolumeRayCastMIPFunction *compositeMipFunction =
> vtkVolumeRayCastMIPFunction::New();
>
> compositeMipFunction->SetMaximizeMethodToScalarValue();
>
>
>
>
>
> vtkVolumeRayCastMapper *volumeRaycastMapper =
> vtkVolumeRayCastMapper::New();
>
>
> volumeRaycastMapper->SetVolumeRayCastFunction(compositeMipFunction);
>
>
> volumeRaycastMapper->SetInputConnection(cast->GetOutputPort());
>
>
>
> vtkVolume *volume = vtkVolume::New();
>
> volume->SetMapper(volumeRaycastMapper);
>
> volume->SetProperty(volumeProperty);
>
> volume->VisibilityOn();
>
> volume->Update();
>
>
>
> ren->AddVolume(volume);
>
> renWin->SetSize(500,500);
>
> ren->ResetCamera();
>
> ren->GetActiveCamera()->Zoom(1.5);
>
>
>
> iren->Initialize();
>
> renWin->Render();
>
> iren->Start();
>
>
>
> HELP ME PLEASE!!!!!!!!!!!
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061211/ca334b2a/attachment.htm>
More information about the vtkusers
mailing list