[vtkusers] 3d reconstruction
Amy Squillacote
ahs at cfdrc.com
Wed May 21 12:21:38 EDT 2008
Create a vtkVolume
(http://www.vtk.org/doc/nightly/html/classvtkVolume.html); this is the
volume rendering equivalent of a vtkActor. Set the mapper on the
vtkVolume, and add the volume to the render window. You will also need
to set up color and opacity transfer functions (see
http://www.vtk.org/doc/nightly/html/classvtkColorTransferFunction.html
and http://www.vtk.org/doc/nightly/html/classvtkPiecewiseFunction.html)
indicating how values in your dataset map to color and opacity for
rendering. In c++, do something like the following.
vtkVolumeRayCastMapper *mapper = vtkVolumeRayCastMapper::New();
...
vtkColorTransferFunction *colors = vtkColorTransferFunction::New();
...
vtkPiecewiseFunction *opacities = vtkPiecewiseFunction::New();
...
vtkVolume *volume = vtkVolume::New();
volume->SetMapper(mapper);
vtkVolumeProperty *property = volume->GetProperty();
property->SetColor(colors);
property->SetScalarOpacity(opacities);
vtkRenderer *ren = new vtkRenderer();
ren->AddViewProp(volume);
- Amy
Alosha [Dread_Lord] wrote:
> Thanks, it works properly now.
>
> Now I have my vtkVolumeRayCastMapper and I have put the vtkImageData
> as input.
>
> So have I my 3D object or am I dreaming :P ?
>
> I know I'm not far, but there are some last steps I don't understand yet.
>
> Do you or anyone knows how to display it in my 3D View ?
>
> I must admit that I'm new in VTK and I don't understand well all this
> stuff yet.
> I don't know for example if vtkVolumeRayCastMapper gerate a 3D model
> that I can display.
>
> If my questions seem stupid, forgive me.
>
> There's the function I've made and at the end, I have my vtkImageData
> in my vtkVolumeRayCastMapper. Still, I don't know what to do with it
> to display a 3D model.
>
> //code
>
> typedef signed short PixelType;
> const unsigned int Dimension = 3;
> typedef itk::Image< PixelType, Dimension > ImageType;
> typedef itk::ImageToVTKImageFilter< ImageType > ConnectorType;
> typedef itk::ImageSeriesReader< ImageType > ReaderType;
>
> ReaderType::Pointer reader = ReaderType::New();
>
> typedef itk::GDCMImageIO ImageIOType;
>
> ImageIOType::Pointer dicomIO = ImageIOType::New();
> reader->SetImageIO( dicomIO );
>
> typedef itk::GDCMSeriesFileNames NamesGeneratorType;
>
> NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
> nameGenerator->SetUseSeriesDetails( true );
> nameGenerator->SetDirectory("C:/Dicoms/PHENIX/dicoms/OS/");
>
> typedef std::vector< std::string > SeriesIdContainer;
>
> const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
> SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
> SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
>
> while( seriesItr != seriesEnd )
> {
> std::cout << seriesItr->c_str() << "caca" << std::endl;
> seriesItr++;
> }
>
> std::string seriesIdentifier;
> seriesIdentifier = seriesUID.begin()->c_str();
> typedef std::vector< std::string > FileNamesContainer;
>
> FileNamesContainer fileNames;
> fileNames = nameGenerator->GetFileNames( seriesIdentifier );
> reader->SetFileNames( fileNames );
>
> cout << "updating the reader" << endl;
>
> try
> {
> reader->Update();
> }
> catch (itk::ExceptionObject &ex)
> {
> std::cout << ex << std::endl;
> }
>
> ConnectorType::Pointer connector = ConnectorType::New();
>
> vtkVolumeRayCastMapper *mapper = vtkVolumeRayCastMapper::New();
> mapper->SetInput(connector->GetOutput());
>
> //end code
>
>
>
>
> ------------------------------------------------------------------------
>
> > Date: Wed, 21 May 2008 10:20:08 -0500
> > From: ahs at cfdrc.com
> > To: cocorim at hotmail.fr
> > CC: vtkusers at vtk.org
> > Subject: Re: [vtkusers] 3d reconstruction
> >
> > Are you linking against the vtkVolumeRendering library? You would need
> > to do that in order to use vtkVolumeRayCastMapper (or any other volume
> > rendering mapper).
> >
> > - Amy
> >
> > Alosha [Dread_Lord] wrote:
> > >
> > > Thank you for your answer.
> > >
> > > The vtkDicomImageReader actually works, but I have some LINK error
> > > while instantiating vtkVolumeRayCastMapper.
> > >
> > > ( vtkVolumeRayCastMapper *mapper = vtkVolumeRayCastMapper::New() )
> > >
> > > Anyway, is the vtkDicomImageReader build a 3D mesh using the 2D dicom
> > > serie, or just generate a data set ?
> > >
> > > In this last case, how can I display it in my igstk::View3D ? I
> > > suppose I have to build a mesh with it ?
> > >
> > > I guess there is a VTK class which takes a volume VTK data set and
> > > build a mesh with it, but I don't know which class :S.
> > >
> > > Anyway, thanks for your answer, and I'm all ears if anyone knows how
> > > to generate a 3D object from my 2D Dicom series for displaying in a
> > > igstk::View3D
> > >
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > From: w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
> > > To: cocorim at hotmail.fr
> > > CC: vtkusers at vtk.org
> > > Subject: RE: [vtkusers] 3d reconstruction
> > > Date: Thu, 22 May 2008 00:44:50 +1000
> > >
> > > You can actually read in a DICOM file as a 3D object just using VTK.
> > >
> > > vtkDICOMImageReader *dicomReader = vtkDICOMImageReader::New();
> > > dicomReader->SetDirectoryName( "C:\\dicomfolder\\");
> > >
> > > Have a look at Ray Cast Mapping as well (vtkVolumeRayCastMapper).
> > > I'm not sure if there is a better way though. With this approach,
> > > the image has to reduce its image quality (goes a bit blurry)
> > > while you move the camera. Then once you are finished moving
> > > around it will return to its original quality.
> > >
> > > Alternatively you can read it in using ITK, and then convert it
> > > back to VTK. I haven't tried this, so maybe someone can let you
> > > know the best way to do it.
> > >
> > > Regards,
> > > Cameron.
> > >
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > From: cocorim at hotmail.fr
> > > To: vtkusers at vtk.org
> > > Date: Wed, 21 May 2008 13:48:12 +0200
> > > Subject: [vtkusers] 3d reconstruction
> > >
> > > Hi all !
> > >
> > > Maybe the problem has already been exposed, and I'm sorry if
> > > it was.
> > >
> > > I've managed to made a basic DICOM Viewer. It has 4 views ; 3
> > > views to axial, coronal ans sagittal orientation, and a
> > > tridimentionnal view for 3d reconstruction.
> > >
> > > I'm using igstk::View2D and igstk::View3D.
> > >
> > > I instantiate a CTImageSpatialObject in which I put the CT
> > > Image from the CTImageReader.
> > > Then I put the CTImageSpatialObject into a
> > > CTImageSpatialObjectRepresentation and I give it to the
> > > igstk::View2D.
> > >
> > > It's working properly and I can navigate into slides in the
> > > three 2D views.
> > >
> > > My problems is now how to perform a 3D reconstruction of the
> > > DICOM and display it in the 3D View.
> > >
> > > I've search on the net and on the mailing list for some help,
> > > but all this is still a little unclear to me.
> > > I just know that ITK and VTK has to be used, but I have no
> > > idea of how.
> > >
> > > If you can help me on that or at least show me the way for
> > > begin, I would be very greatfull.
> > >
> > > Thanks a lot !
> > >
> > >
> ------------------------------------------------------------------------
> > > Discutez gratuitement avec vos amis en vidéo ! Téléchargez
> > > Messenger, c'est gratuit ! <http://www.windowslive.fr/messenger/>
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > Click here Search for local singles online @ Lavalife.
> > >
> <http://a.ninemsn.com.au/b.aspx?URL=http://lavalife9.ninemsn.com.au/clickthru/clickthru.act?id%3Dninemsn%26context%3Dan99%26locale%3Den_AU%26a%3D30290&_t=764581033&_r=email_taglines_Search_OCT07&_m=EXT>
> > >
> > >
> > >
> > >
> ------------------------------------------------------------------------
> > > Centralisez tous vos comptes mails dans Hotmail ! Créez un compte
> > > Hotmail, c'est gratuit ! <http://www.windowslive.fr/hotmail/>
> > >
> ------------------------------------------------------------------------
> > >
> > > _______________________________________________
> > > 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
> > >
> >
> > --
> > Amy Squillacote Phone: (256) 726-4839
> > Computer Scientist Fax: (256) 726-4806
> > CFD Research Corporation Web: http://www.cfdrc.com
> > 215 Wynn Drive, Suite 501
> > Huntsville, AL 35805
> >
> >
>
>
> ------------------------------------------------------------------------
> Avec Windows Live Messenger restez en contact avec tous vos amis !
> Téléchargez Messenger, c'est gratuit !
> <http://www.windowslive.fr/messenger/>
--
Amy Squillacote Phone: (256) 726-4839
Computer Scientist Fax: (256) 726-4806
CFD Research Corporation Web: http://www.cfdrc.com
215 Wynn Drive, Suite 501
Huntsville, AL 35805
More information about the vtkusers
mailing list