[vtkusers] Volume rendering with png slice images

Joseph D. Wieber Jr. jdwieber at gmail.com
Thu Aug 4 12:01:07 EDT 2011


That's a lot of new classes.

I tried to upgrade but now I get 717 linker errors.  I posted a new 
question regarding this.

On 08/04/2011 08:58 AM, Dženan Zukić wrote:
> True. http://www.vtk.org/Wiki/Improvements_in_VTK_5.6
>
> 2011/8/4 Joseph D. Wieber Jr. <jdwieber at gmail.com 
> <mailto:jdwieber at gmail.com>>
>
>     Thanks for your reply.  Unfortunately, I don't see
>     vtkGPUVolumeRayCastMapper in the version (5.4.2-8ubuntu4) I'm
>     using.  I guess it's time for an upgrade.
>
>
>     On 08/04/2011 05:45 AM, Dženan Zukić wrote:
>>     Have you tried vtkGPUVolumeRayCastMapper?
>>
>>     On Thu, Aug 4, 2011 at 02:59, Joseph D. Wieber Jr.
>>     <jdwieber at gmail.com <mailto:jdwieber at gmail.com>> wrote:
>>
>>         I apologize, I figured it out.  It was the single line in
>>         generateVolume that reads:
>>         spVolumeProperty->IndependentComponentsOff(); When I comment
>>         out this line, and uncomment the lines for linear
>>         interpolation and shading it looks very nice.  However, it's
>>         terribly slow.  I suspect that this version is software
>>         rendered.  Is there a similar hardware accelerated  method?
>>
>>         Thanks
>>
>>
>>         On 08/03/2011 07:18 PM, Joseph D. Wieber Jr. wrote:
>>
>>
>>             Hi all,
>>
>>             I'm trying to do some volume rendering using the below
>>             code, but nothing is showing in the render window.  When
>>             I run the code I see the window and the background color
>>             that I set, but no data.  The code cranks for about 5
>>             seconds before I see the default render window replaced
>>             (the default render window is white, and the volume
>>             render window is gray-ish).  I don't see error messages
>>             in the console either.
>>
>>             I'm using Qt with QVTKWidget to create the GUI.  I'm
>>             obviously doing something wrong, but I don't see what it
>>             is.  Does anyone see what I'm missing?  Thanks.
>>
>>             Regards,
>>
>>             Joseph
>>
>>             void MainWindow::on_actionOpenDirectory_triggered()
>>             {
>>                QString dirname = QFileDialog::getExistingDirectory( this,
>>                                                                  
>>              tr("Select a Directory"),
>>                                                                  
>>              QDir::currentPath() );
>>                if( !dirname.isNull() )
>>                {
>>                    string pattern( dirname.toStdString () );
>>                    pattern += "/%03d.png";
>>                    cerr << "using pattern:<" << pattern << ">\n";
>>
>>                    vtkSmartPointer< vtkVolume > spVolume =
>>             generateVolume ( pattern );
>>
>>                    vtkSmartPointer<vtkRenderWindow> spRenWin =
>>                            vtkSmartPointer<vtkRenderWindow>::New();
>>
>>                    vtkSmartPointer< vtkRenderer> spRen =
>>                            vtkSmartPointer< vtkRenderer >::New();
>>                    spRen->AddViewProp ( spVolume );
>>
>>                    spRenWin->AddRenderer( spRen );
>>                    m_pUi->qvtkWidget->SetRenderWindow ( spRenWin );
>>                    vtkSmartPointer< vtkRenderWindowInteractor > spIren =
>>                            m_pUi->qvtkWidget->GetInteractor ();
>>                    spIren->SetRenderWindow( spRenWin );
>>                    spRen->SetBackground( 0.2, 0.3, 0.4 );
>>                    spRen->ResetCamera ();
>>
>>                    //I tried this in place of ResetCamera, but id
>>             didn't work either
>>                    //        vtkSmartPointer< vtkCamera > spCamera =
>>             spRen->GetActiveCamera();
>>                    //        double* c = spVolume->GetCenter();
>>                    //        spCamera->SetFocalPoint( c[ 0 ], c[ 1 ],
>>             c[ 2 ] );
>>                    //        spCamera->SetPosition( c[ 0 ] + 400, c[
>>             1 ], c[ 2 ] );
>>                    //        spCamera->SetViewUp( 0, 0, -1 );
>>
>>
>>                    spRenWin->Render();
>>                    m_pUi->qvtkWidget->setCursor ( Qt::ArrowCursor );
>>                }
>>                else
>>                {
>>                    //TODO: do something intelligent here!
>>                }
>>             }
>>
>>
>>             //---------------------------------------------------------------------------------------------------------------------------
>>
>>             vtkSmartPointer< vtkVolume > MainWindow::generateVolume(
>>             const std::string& pattern )
>>             {
>>                //m_spReader is a vtkSmartPointer< vtkPNGReader >
>>                m_spReader->SetFilePattern ( pattern.c_str () );
>>                m_spReader->SetFileNameSliceOffset ( 1 );//images
>>             start at 001.png
>>                //TODO: derive these from input
>>                m_spReader->SetDataExtent( 0, 511, 0, 511, 1, 370
>>             );//images go from 1 to 370
>>                m_spReader->SetDataSpacing( 1.0, 1.0, 1.0 ); // mm
>>                m_spReader->SetDataOrigin( 0, 0, 0 );
>>                m_spReader->SetDataScalarTypeToUnsignedChar();
>>                //m_spReader->Update();
>>
>>                vtkSmartPointer< vtkPiecewiseFunction >
>>             spOpacityTransferFunction =
>>                        vtkSmartPointer< vtkPiecewiseFunction >::New();
>>                spOpacityTransferFunction->AddPoint( 0, 0.0 );
>>                spOpacityTransferFunction->AddPoint( 255, 1.0 );
>>
>>                vtkSmartPointer< vtkVolumeProperty > spVolumeProperty =
>>                        vtkSmartPointer< vtkVolumeProperty >::New();
>>                spVolumeProperty->SetScalarOpacity( 0,
>>             spOpacityTransferFunction );
>>                spVolumeProperty->SetScalarOpacity( 1,
>>             spOpacityTransferFunction );
>>                spVolumeProperty->SetScalarOpacity( 2,
>>             spOpacityTransferFunction );
>>                spVolumeProperty->IndependentComponentsOff();
>>                spVolumeProperty->SetInterpolationTypeToLinear();
>>                //spVolumeProperty->ShadeOn();
>>                //spVolumeProperty->SetAmbient( 0.4 );
>>                //spVolumeProperty->SetDiffuse( 0.6 );
>>                //spVolumeProperty->SetSpecular( 0.2 );
>>
>>                vtkSmartPointer< vtkFixedPointVolumeRayCastMapper >
>>             spVolumeMapper =
>>                        vtkSmartPointer<
>>             vtkFixedPointVolumeRayCastMapper >::New();
>>
>>                spVolumeMapper->SetInputConnection(
>>             m_spReader->GetOutputPort() );
>>
>>                vtkSmartPointer< vtkVolume > spVolume =
>>                        vtkSmartPointer< vtkVolume >::New();
>>                spVolume->SetMapper( spVolumeMapper );
>>                spVolume->SetProperty( spVolumeProperty );
>>
>>                return spVolume;
>>             }
>>
>>         _______________________________________________
>>         Powered by www.kitware.com <http://www.kitware.com>
>>
>>         Visit other Kitware open-source projects at
>>         http://www.kitware.com/opensource/opensource.html
>>
>>         Please keep messages on-topic and check the VTK 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/20110804/32e35910/attachment.htm>


More information about the vtkusers mailing list