[vtkusers] MIP help
    Michele Marco 
    michelegr at alice.it
       
    Mon Oct  2 09:37:30 EDT 2006
    
    
  
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!!!!!!!!!!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061002/5c47dc8c/attachment.htm>
    
    
More information about the vtkusers
mailing list