public DicomLoader(String directoryPath) { _dicomReader = new vtkDICOMImageReader(); _dicomReader.SetDirectoryName(directoryPath); _dicomReader.Update(); int a = _dicomReader.GetWidth(); int b = _dicomReader.GetHeight(); }
public DicomLoader(String directoryPath) { _dicomReader = new vtkDICOMImageReader(); _dicomReader.SetDirectoryName(directoryPath); _dicomReader.Update(); int a = _dicomReader.GetWidth(); int b = _dicomReader.GetHeight(); }
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(); } }