[vtkusers] 3d reconstruction
Cameron Burnett
w_e_b_m_a_s_t_e_r_6_9 at hotmail.com
Wed May 21 17:54:44 EDT 2008
Well, I'd say there would definately be an error because you called your vtkVolumeProperty "property" when that is a reserved name (it is blue text).
Also, if you're having problems with your colours or opacity try this....
vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();
opacityTransferFunction->AddPoint( 70.0, 0.0 );
opacityTransferFunction->AddPoint( 100.0, 0.2 );
opacityTransferFunction->AddPoint( 50000.0, 0.2 );
opacityTransferFunction->AddPoint( 50005.0, 0.0 );
vtkColorTransferFunction* colorTransferFunction = vtkColorTransferFunction::New();
colorTransferFunction->AddRGBPoint( 0.0, 1.0, 0.0, 0.0 );
colorTransferFunction->AddRGBPoint( 300.0, 1.0, 1.0, 0.0 );
colorTransferFunction->AddRGBPoint( 600.0, 0.0, 1.0, 0.0 );
colorTransferFunction->AddRGBPoint( 900.0, 1.0, 1.0, 1.0 );
colorTransferFunction->AddRGBPoint( 1200.0, 0.0, 0.0, 1.0 );
colorTransferFunction->AddRGBPoint( 1500.0, 1.0, 0.0, 1.0 );
colorTransferFunction->AddRGBPoint( 1800.0, 0.0, 0.0, 0.0 );
I have absolutely NO idea how to obtain these points, but I guess it works fine. Maybe try changing the numbers to see what it does.
From: cocorim at hotmail.fr
To: ahs at cfdrc.com
Date: Wed, 21 May 2008 23:39:41 +0200
CC: vtkusers at vtk.org
Subject: Re: [vtkusers] 3d reconstruction
Hi again !
Sorry to bother you again, but I have one problem remaining with the vtkRendererWindow.
Here's my code :
//code
vtkVolumeRayCastMapper *mapper = vtkVolumeRayCastMapper::New();
mapper->SetInput(connector->GetOutput());
vtkVolume *volume = vtkVolume::New();
volume->SetMapper(mapper);
vtkColorTransferFunction *colors = vtkColorTransferFunction::New();
colors->SetAlpha(1.0);
vtkPiecewiseFunction *opacities = vtkPiecewiseFunction::New();
opacities->SetMaximumNumberOfPieces(-1);
vtkVolumeProperty *property = volume->GetProperty();
property->SetColor(colors);
property->SetScalarOpacity(opacities);
vtkRenderer *ren = vtkRenderer::New();
ren->AddViewProp(volume);
vtkRenderWindow *triDView = vtkRenderWindow::New();
triDView->AddRenderer(ren);
triDView->Render();
//end code
And the problems comes when the vtkRendere is added to the windows. VC++ throws an writing violation exception at a memory bloc. I don't understand why it's doing that.
Maybe, my use of the window is incorrect. I'm waiting for my User's Guide book, but i'd like to have a 3d visualisation of my dicom before :).
Tranks
> Date: Wed, 21 May 2008 11:21:38 -0500
> From: ahs at cfdrc.com
> To: cocorim at hotmail.fr
> CC: vtkusers at vtk.org
> Subject: Re: [vtkusers] 3d reconstruction
>
> 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
>
>
Tous vos amis discutent sur Messenger, et vous ? Téléchargez Messenger, c'est gratuit !
_________________________________________________________________
It's simple! Sell your car for just $30 at CarPoint.com.au
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080522/59040b4c/attachment.htm>
More information about the vtkusers
mailing list