[vtkusers] How to do 3D reconstruction by a series of DICOM Files?

Liu_tj tjlp at netease.com
Fri Mar 18 03:20:21 EDT 2016


Possibly the memory is not enough. I get similar errors before and I turn to 64bit vtk.



在2016-03-18,"陳鼎元" <r.chen.dk at gmail.com> 写道: -----原始邮件-----
发件人:"陳鼎元" <r.chen.dk at gmail.com>
发送时间:2016年03月18日 星期五
收件人:"vtkusers" <vtkusers at vtk.org>
主题:[vtkusers] How to do 3D reconstruction by a series of DICOM Files?


Hello Everyone:

    I am a Beginner using VTK for DICOM Image application, I successfully read the DICOM Image by vtkDICOMReader, I tried to find out the 3D rendering methods: MarchingCubes, I just copy the codes on the example and change the Directory Folder to in which my DICOM Files are saved, and it ended up to an error(as the snapshot_1), here is my code:


    I really want to realize where the error comes from, since it's similar as the least one, is there some knowledge I should take care before using VTK libraries? Also do you recommend the other 3D reconstruction methods?



#include <vtkVersion.h>
#include <vtkSmartPointer.h>
#include <vtkMarchingCubes.h>
#include <vtkVoxelModeller.h>
#include <vtkSphereSource.h>
#include <vtkImageData.h>
#include <vtkDICOMImageReader.h>
#include <vtkActor.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>


#include <vtkAutoInit.h>
#include <vtkInteractionStyleModule.h>
#include <vtkInteractionStyleObjectFactory.h>
#include <vtkRenderingOpenGL2Module.h>
#include <vtkRenderingOpenGL2ObjectFactory.h>
#include <vtkInteractionStyleModule.h>
#include <vtkInteractionStyleObjectFactory.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkRenderingFreeType);
VTK_MODULE_INIT(vtkInteractionStyle);


int main(int argc, char *argv[])
{
vtkSmartPointer<vtkImageData> volume =
vtkSmartPointer<vtkImageData>::New();
double isoValue;


vtkSmartPointer<vtkDICOMImageReader> reader =
vtkSmartPointer<vtkDICOMImageReader>::New();
reader->SetDirectoryName("D:/Ralf/VTK/DICOM/case2009.04.15.12.07.26/MR");
reader->Update();
volume->DeepCopy(reader->GetOutput());
isoValue = atof(argv[2]);


vtkSmartPointer<vtkMarchingCubes> surface =
vtkSmartPointer<vtkMarchingCubes>::New();


#if VTK_MAJOR_VERSION <= 5
surface->SetInput(volume);
#else
surface->SetInputData(volume);
#endif
surface->ComputeNormalsOn();
surface->SetValue(0, isoValue);


vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->SetBackground(.1, .2, .3);


vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);


vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(surface->GetOutputPort());
mapper->ScalarVisibilityOff();


vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);


renderer->AddActor(actor);


renderWindow->Render();
interactor->Start();
return EXIT_SUCCESS;
}


                                                              Sincerely, Ralf.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160318/d54e0aff/attachment.html>


More information about the vtkusers mailing list