[vtkusers] Fills Black to Empty Spaces

circass circass at gmail.com
Wed Dec 23 10:48:24 EST 2009


Hi all, i m trying to render a volume from a dicom serie and mostly i did but
at volume display section the empty areas are Black and not transparent so i
cant see the 3D volume as i want.
What can cause this ?
How can i fix this ?
Thanx



My Code is here


        typedef itk::Image<unsigned char,3> ImageNDType;

        typedef itk::ImageSeriesReader<ImageNDType> ReaderType;

        ReaderType::Pointer reader = ReaderType::New();

        itk::DICOMImageIO2::Pointer io = itk::DICOMImageIO2::New();

        // Get the DICOM filenames from the directory

        itk::DICOMSeriesFileNames::Pointer names =
itk::DICOMSeriesFileNames::New();

        names->SetDirectory(directoryPath);//directoryPath is the directory
path

        reader->SetFileNames(names->GetFileNames());

        reader->SetImageIO(io);

        std::cout << names;

    reader->Update();

    //reader->GetOutput()->Print(std::cout);

        typedef itk::VTKImageExport< ImageNDType>  ExportFilterType;

    ExportFilterType::Pointer itkExporter = ExportFilterType::New();

    itkExporter->SetInput( reader->GetOutput() );

    vtkImageImport* vtkImporter = vtkImageImport::New();  

    ConnectPipelines(itkExporter, vtkImporter);
   
    typedef itk::VTKImageImport< ImageNDType > ImportFilterType;

    ImportFilterType::Pointer itkImporter = ImportFilterType::New();
   
    vtkImageExport* vtkExporter = vtkImageExport::New();  

    ConnectPipelines(vtkExporter, itkImporter);

    vtkPiecewiseFunction *opacityTransferFunction =
vtkPiecewiseFunction::New();

    vtkExporter->SetInput(vtkImporter->GetOutput());

        vtkVolume* volume = vtkVolume::New();

        vtkVolumeProperty* volumeProperty = vtkVolumeProperty::New();

        vtkVolumeTextureMapper3D* volumeMapper =
vtkVolumeTextureMapper3D::New();

        vtkFixedPointVolumeRayCastMapper* volumeMapperSoftware =
vtkFixedPointVolumeRayCastMapper::New();

        opacityTransferFunction->Crop();

        opacityTransferFunction->AddSegment(0.1,0.4,0.7,0.2);

        volumeProperty->SetScalarOpacity(opacityTransferFunction);

        volumeProperty->SetInterpolationTypeToLinear();

        // i tried that but changed nothing..
        //volumeProperty->ShadeOff();

        volume->SetProperty(volumeProperty);

        volumeMapper->SetInput(vtkImporter->GetOutput());
       
        volumeMapper->CroppingOn();

        volumeMapperSoftware->SetInput(vtkImporter->GetOutput());

        volume->SetMapper(volumeMapperSoftware);

        vtkInteractorStyleTrackballCamera * interactorStyle =
vtkInteractorStyleTrackballCamera::New();

        vtkRenderer* renderer = vtkRenderer::New();

    vtkRenderWindow* renWin = vtkRenderWindow::New();

    vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();

        volume->SetVisibility(4);

        renderer->AddVolume(volume);

    renWin->SetSize(500, 500);

    renWin->AddRenderer(renderer);
       
    iren->SetRenderWindow(renWin);

    iren->SetInteractorStyle( interactorStyle );

    renderer->SetBackground(0.4392, 0.5020, 0.5647);
   
        renWin->Render();
   
        iren->Start(); 
-- 
View this message in context: http://old.nabble.com/Fills-Black-to-Empty-Spaces-tp26903095p26903095.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list