[vtkusers] 3D pointcloud visualisation of DICOM Images with VTK in C#

Alexander Mizuk amizuk at uni-osnabrueck.de
Fri Sep 15 04:45:12 EDT 2017


Hello,

my task is to visualize a grayscale pointcloud which I can found in a 
DICOM series. I found this tutorial 
https://pyscience.wordpress.com/2014/09/11/surface-extraction-creating-a-mesh-from-pixel-data-using-python-and-vtk/ 
which shows how to visualize bones in 3D by meching them. I could 
transfer it to c# and it work, but I need just a 3D point cloud where I 
can define the object by thresholding the grayscale. Hope u understand 
what I mean. So I tried this:

    |// read filestringpathDicom
    =@"...\dicomDirectory";vtkDICOMImageReader reader
    =newKitware.VTK.vtkDICOMImageReader();reader.SetDirectoryName(pathDicom);reader.Update();//
    convert HU valuevtkImageShiftScale shiftScale
    =vtkImageShiftScale.New();shiftScale.SetScale(reader.GetRescaleSlope());shiftScale.SetShift(reader.GetRescaleOffset());shiftScale.SetInputConnection(reader.GetOutputPort());shiftScale.Update();//
    VisualizevtkPolyDataMapper mapper
    =vtkPolyDataMapper.New();mapper.SetInputConnection(shiftScale.GetOutputPort());vtkActor
    actor
    =vtkActor.New();actor.SetMapper(mapper);actor.GetProperty().SetPointSize(4);vtkRenderWindow
    renderWindow =renderWindowControl1.RenderWindow;vtkRenderer renderer
    =renderWindow.GetRenderers().GetFirstRenderer();renderer.SetBackground(0.2,0.3,0.4);renderer.AddActor(actor);|

When I start this I alwas get the same error

|vtkStreamingDemandDrivenPipline (09366B85)|

and Visual Studio tell me

|System.AccessViolationException|

It's kind of memory error.

So my question is where is my mistake? During debugging I found out that 
the error begun when I set the mapper for the actor. But I now that this 
code is the normal way to display everything in vtk. I think the problem 
is that I don't really get the points out of the array but the imageData 
should contain all pixels of the series.

Hope u can help me.

Beste Regards

Alexander

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170915/472718d0/attachment.html>


More information about the vtkusers mailing list