[vtkusers] Cannot open Dicom images

David Cole dlrdave at aol.com
Thu May 23 12:48:46 EDT 2013


-----Original Message-----
From: Max <smapersmaper at gmail.com>
To: vtkusers <vtkusers at vtk.org>
Sent: Thu, May 23, 2013 7:27 am
Subject: Re: [vtkusers] Cannot open Dicom images


I succeeded in showing one image with SetFileName function.
But when i'm trying to use SetDirectoryName function to show all the 
files
in current directory, it shows nothing. the code is:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Kitware.VTK;

namespace AAASimpleDicomReader
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

         private void renderWindowControl1_Load(object sender, EventArgs 
e)
        {

            string folder = @"c:\\DicomPhantom\\A\\";
            string file = "20121203135029687";
            //string folder =
@"c:\DicomImages\VTK_Examples_StandardFormats_Input_DicomTestImages\matla
b\examples\sample_data\DICOM\digest_article\";//Path.Combine(root,
@"Data\DicomTestImages");
            vtkDICOMImageReader reader1 = vtkDICOMImageReader.New();
            //reader1.SetFileName(folder + file);
            reader1.SetDirectoryName(folder);
            reader1.Update();


           vtkLookupTable  VTKtable = vtkLookupTable.New();
           //VTKtable.SetNumberOfTableValues(1000);
           //VTKtable.SetTableRange(0,1000);
           //VTKtable.SetSaturationRange(0,1);
           //VTKtable.SetHueRange(0,1);
           //VTKtable.SetValueRange(0,1);
           //VTKtable.SetAlphaRange(0,1);
           //VTKtable.Build();

           vtkTexture  VTKtexture = vtkTexture.New();
           VTKtexture.SetInput(reader1.GetOutput());
          // VTKtexture.InterpolateOn();
           //VTKtexture.SetLookupTable(VTKtable);

           vtkPlaneSource  VTKplane = vtkPlaneSource.New();
           //VTKplane.SetOrigin( -0.5, -0.5, 0.0);
           //VTKplane.SetPoint1(  0.5, -0.5, 0.0);
           //VTKplane.SetPoint2(-0.5, 0.5, 0.0);

           vtkPolyDataMapper  VTKplaneMapper = vtkPolyDataMapper.New();
           VTKplaneMapper.SetInput(VTKplane.GetOutput());

           vtkActor  VTKplaneActor = vtkActor.New();
           VTKplaneActor.SetTexture(VTKtexture);
           VTKplaneActor.SetMapper(VTKplaneMapper);
           //VTKplaneActor.PickableOn();

           vtkRenderer ren = vtkRenderer.New();
           vtkRenderWindow renwin = renderWindowControl1.RenderWindow;
           renwin.AddRenderer(ren);
           vtkRenderWindowInteractor  iren =
vtkRenderWindowInteractor.New();
           iren.SetRenderWindow(renwin);
           ren.AddActor(VTKplaneActor);
           //ren.SetBackground(0,0,0.5);

           ren.ResetCamera();
           ren.Render();
         //  iren.Start();

           //reader.Delete();
           //VTKtable.Delete();
           //VTKtexture.Delete();
           //VTKplane.Delete();
           //VTKplaneMapper.Delete();
           //VTKplaneActor.Delete();
           //ren.Delete();
           //renwin.Delete();
           //iren.Delete();



        }


    }
}

Do you know maybe what might be the problem?

Thank you,
Max




--
View this message in context: 
http://vtk.1045678.n5.nabble.com/Cannot-open-Dicom-images-tp5720907p5720915.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by 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




Hi Max,

When you use the vtkDICOMImageReader to read a single slice file, the 
result is a 2D vtkImageData object. When you use it to read a whole 
directory of slices, the result is a 3D vtkImageData object.

You can't use a 3D image data as input to a vtkTexture like that. 
You'll have to use just a slice of the 3D image if you want to use it 
as input to a texture.

Or you can render it as a volume, or an iso-surface, or perhaps as 
three 2-D slice planes that slice into it along the main axes...

The Qt-based C++ example in VTK/Examples/GUI/Qt/FourPaneViewer actually 
gives you a little four-views-in-one-window app that displays a DICOM 
directory using vtkResliceImageViewer and vtkImagePlaneWidget classes. 
(May not be the best example for a beginner, but it does show one way 
to view a 3D DICOM...)


Hope this helps,
David C.




More information about the vtkusers mailing list