예제 #1
0
 public void ChangeDirectory(String directoryPath)
 {
     _dicomReader.Dispose();
     _dicomReader = new vtkDICOMImageReader();
     _dicomReader.SetDirectoryName(directoryPath);
     _dicomReader.Update();
 }
 public void ChangeDirectory(String directoryPath)
 {
     _dicomReader.Dispose();
     _dicomReader = new vtkDICOMImageReader();
     _dicomReader.SetDirectoryName(directoryPath);
     _dicomReader.Update();
 }
예제 #3
0
 public DicomLoader(String directoryPath)
 {
     _dicomReader = new vtkDICOMImageReader();
     _dicomReader.SetDirectoryName(directoryPath);
     _dicomReader.Update();
     int a = _dicomReader.GetWidth();
     int b = _dicomReader.GetHeight();
 }
예제 #4
0
        public Form1()
        {
            InitializeComponent();

            dicomReader = vtkDICOMImageReader.New();
            dicomReader.SetDirectoryName(directoryName);
            dicomReader.Update();
        }
예제 #5
0
        public Form1()
        {
            InitializeComponent();

            dicomReader = vtkDICOMImageReader.New();
            dicomReader.SetDirectoryName(directoryName);
            dicomReader.Update();
        }
 public DicomLoader(String directoryPath)
 {
     _dicomReader = new vtkDICOMImageReader();
     _dicomReader.SetDirectoryName(directoryPath);
     _dicomReader.Update();
     int a = _dicomReader.GetWidth();
     int b = _dicomReader.GetHeight();
 }
예제 #7
0
파일: Form1.cs 프로젝트: sjdmirzaei/dicom3d
        public void Render3D(string folder)
        {
            reader3D = vtkDICOMImageReader.New();
            reader3D.SetDirectoryName(folder);
            reader3D.Update();

            renderer3D     = vtkRenderer.New();
            renderWindow3D = vtkRenderWindow.New();

            renderWindowControl.Dock = DockStyle.Fill;
            panel1.Controls.Add(renderWindowControl);

            renderWindow3D = renderWindowControl.RenderWindow;
            renderWindow3D.AddRenderer(renderer3D);


            Coloring();
        }
 public DicomLoader(String directoryPath)
 {
     _dicomReader = new vtkDICOMImageReader();
     _dicomReader.SetDirectoryName(directoryPath);
     _dicomReader.Update();
 }
        static void PrintImage(string Ipath)
        {
            vtkDICOMImageReader reader = vtkDICOMImageReader.New();

            reader.SetDirectoryName(Ipath);
            reader.Update();
            X = reader.GetWidth();
            Y = reader.GetHeight();
            Z = reader.GetPixelSpacing();
            Console.WriteLine(X * Z[0]);
            Console.WriteLine(Y * Z[1]);
            Console.WriteLine(Z[2]);

            // Visualize
            _ImageViewer = vtkImageViewer2.New();
            _ImageViewer.SetInputConnection(reader.GetOutputPort());

            // Get range of slices (min is the first index, max is the last index)
            _ImageViewer.GetSliceRange(ref _MinSlice, ref _MaxSlice);
            Console.WriteLine(_MinSlice);
            Console.WriteLine(_MaxSlice);

            _SliceStatusMapper = vtkTextMapper.New();
            _SliceStatusMapper.SetInputConnection(reader.GetOutputPort());

            vtkActor2D sliceStatusActor = vtkActor2D.New();

            sliceStatusActor.SetMapper(_SliceStatusMapper);

            vtkRenderWindow renderWindow = vtkRenderWindow.New();

            //Display in full screen
            renderWindow.SetFullScreen(1);

            vtkInteractorStyleImage interactorStyle = vtkInteractorStyleImage.New();

            renderWindow.GetRenderers().InitTraversal();
            vtkRenderer ren;

            while ((ren = renderWindow.GetRenderers().GetNextItem()) != null)
            {
                renderWindow.AddRenderer(ren);
            }

            _ImageViewer.SetRenderWindow(renderWindow);
            _ImageViewer.GetRenderer().AddActor2D(sliceStatusActor);
            _ImageViewer.SetSlice(_Slice);
            _ColorLevel = 500;
            _ImageViewer.SetColorLevel(_BlackLevel);
            _ImageViewer.Render();
            Down(_period, 62);
            Backward(_period, 1);

            _ImageViewer.SetColorLevel(_ColorLevel);
            _ImageViewer.Render();
            System.Threading.Thread.Sleep(_layertime);  // delay

            iren = vtkRenderWindowInteractor.New();
            iren.SetRenderWindow(renderWindow);
            renderWindow.Render();

            //Start Timer
            InitTimer();
            iren.Start();

            if (reader != null)
            {
                reader.Dispose();
            }
            if (_ImageViewer != null)
            {
                _ImageViewer.Dispose();
            }
            if (_SliceStatusMapper != null)
            {
                _SliceStatusMapper.Dispose();
            }
            if (sliceStatusActor != null)
            {
                sliceStatusActor.Dispose();
            }
            if (renderWindow != null)
            {
                renderWindow.Dispose();
            }
            if (interactorStyle != null)
            {
                interactorStyle.Dispose();
            }
            if (ren != null)
            {
                ren.Dispose();
            }
            if (iren != null)
            {
                iren.Dispose();
            }
        }
예제 #10
0
 public DicomLoader(String directoryPath)
 {
     _dicomReader = new vtkDICOMImageReader();
     _dicomReader.SetDirectoryName(directoryPath);
     _dicomReader.Update();
 }
예제 #11
0
        private void ReadDICOMSeries()
        {
            // Path to vtk data must be set as an environment variable
            // VTK_DATA_ROOT = "C:\VTK\vtkdata-5.8.0"
            vtkTesting test = vtkTesting.New();
            string     root = test.GetDataRoot();
            // Read all the DICOM files in the specified directory.
            // Caution: folder "DicomTestImages" don't exists by default in the standard vtk data folder
            // sample data are available at http://www.vtk.org/Wiki/images/1/12/VTK_Examples_StandardFormats_Input_DicomTestImages.zip

            //string folder = Path.Combine(root, @"Data\DicomTestImages");
            string folder = @"provaDicom/" + studyUID;

            Console.WriteLine(folder);
            vtkDICOMImageReader reader = vtkDICOMImageReader.New();

            reader.SetDirectoryName(folder);
            reader.Update();
            // Visualize
            _ImageViewer = vtkImageViewer2.New();
            _ImageViewer.SetInputConnection(reader.GetOutputPort());
            // get range of slices (min is the first index, max is the last index)
            _ImageViewer.GetSliceRange(ref _MinSlice, ref _MaxSlice);
            Debug.WriteLine("slices range from : " + _MinSlice.ToString() + " to " + _MaxSlice.ToString());

            // slice status message
            vtkTextProperty sliceTextProp = vtkTextProperty.New();

            sliceTextProp.SetFontFamilyToCourier();
            sliceTextProp.SetFontSize(20);
            sliceTextProp.SetVerticalJustificationToBottom();
            sliceTextProp.SetJustificationToLeft();

            _SliceStatusMapper = vtkTextMapper.New();
            _SliceStatusMapper.SetInput("Slice No " + (_Slice + 1).ToString() + "/" + (_MaxSlice + 1).ToString());
            _SliceStatusMapper.SetTextProperty(sliceTextProp);

            vtkActor2D sliceStatusActor = vtkActor2D.New();

            sliceStatusActor.SetMapper(_SliceStatusMapper);
            sliceStatusActor.SetPosition(15, 10);
            // usage hint message
            vtkTextProperty usageTextProp = vtkTextProperty.New();

            usageTextProp.SetFontFamilyToCourier();
            usageTextProp.SetFontSize(14);
            usageTextProp.SetVerticalJustificationToTop();
            usageTextProp.SetJustificationToLeft();

            vtkTextMapper usageTextMapper = vtkTextMapper.New();

            usageTextMapper.SetInput("Slice with mouse wheel\nor Up/Down-Key");
            usageTextMapper.SetTextProperty(usageTextProp);

            vtkActor2D usageTextActor = vtkActor2D.New();

            usageTextActor.SetMapper(usageTextMapper);
            usageTextActor.GetPositionCoordinate().SetCoordinateSystemToNormalizedDisplay();
            usageTextActor.GetPositionCoordinate().SetValue(0.05, 0.95);

            vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow;

            vtkInteractorStyleImage interactorStyle = vtkInteractorStyleImage.New();

            // NOTA:non funziona la rotellina del mouse per cambiare slice <--------------------------------------
            // l'errore è causato dalla funzione DicomCFindRequest(della sorgente di FellowOak)
            //in QueryFellowOak.cs, in particolare dal costruttore
            // DicomCFindRequest(DicomQueryRetrieveLevel level)

            // interactorStyle.MouseWheelForwardEvt += new vtkObject.vtkObjectEventHandler(interactor_MouseWheelForwardEvt);
            //  interactorStyle.MouseWheelBackwardEvt += new vtkObject.vtkObjectEventHandler(interactor_MouseWheelBackwardEvt);

            renderWindow.GetInteractor().SetInteractorStyle(interactorStyle);
            renderWindow.GetRenderers().InitTraversal();
            vtkRenderer ren;

            while ((ren = renderWindow.GetRenderers().GetNextItem()) != null)
            {
                ren.SetBackground(0.0, 0.0, 0.0);
            }

            _ImageViewer.SetRenderWindow(renderWindow);
            _ImageViewer.GetRenderer().AddActor2D(sliceStatusActor);
            _ImageViewer.GetRenderer().AddActor2D(usageTextActor);
            _ImageViewer.SetSlice(_MinSlice);
            _ImageViewer.Render();
        }