static void Backward(int t, int layers) { _ImageViewer.SetColorLevel(_BlackLevel); _ImageViewer.Render(); Down(_period, 10 * layers); System.Threading.Thread.Sleep(5000); Forward(_period, 9 * layers); System.Threading.Thread.Sleep(5000); // delay _ImageViewer.SetColorLevel(_ColorLevel); _ImageViewer.Render(); }
/// <summary> /// move forward to next slice /// </summary> private void MoveForwardSlice() { Debug.WriteLine(_Slice.ToString()); if (_Slice < _MaxSlice) { _Slice += 1; _ImageViewer.SetSlice(_Slice); _SliceStatusMapper.SetInput("Slice No " + (_Slice + 1).ToString() + "/" + (_MaxSlice + 1).ToString()); _ImageViewer.Render(); } }
public void sliceY(float slicePosition) { this.slicePosition = slicePosition; widget = vtkImagePlaneWidget.New(); widget.SetInput(dicomReader.GetOutput()); widget.SetPlaneOrientationToYAxes(); widget.SetSliceIndex((int)slicePosition); widget.SetWindowLevel(this.windowWidth, this.windowLevel, 1); viewer.SetInput(widget.GetResliceOutput()); viewer.Render(); window.Update(); window.RenderWindow.Render(); }
public static int Main(string[] args) { string filename = args[0]; vtkGDCMImageReader reader = vtkGDCMImageReader.New(); vtkStringArray array = vtkStringArray.New(); array.InsertNextValue(filename); reader.SetFileNames(array); reader.Update(); //System.Console.Write(reader.GetOutput()); vtkRenderWindowInteractor iren = vtkRenderWindowInteractor.New(); vtkImageViewer2 viewer = vtkImageViewer2.New(); viewer.SetInput(reader.GetOutput()); viewer.SetupInteractor(iren); viewer.SetSize(600, 600); viewer.Render(); iren.Initialize(); iren.Start(); return(0); }
/// <summary> /// Refresh viewer and window. /// </summary> private void UpdateViewer() { _viewer.SetColorWindow(_windowWidth); _viewer.SetColorLevel(_windowLevel); _viewer.Render(); _window.Update(); _window.RenderWindow.Render(); }
public static void UpdateImageView() { if (ImageViewer != null) { ImageViewer.SetInput(SectionImageData); ImageViewer.Render(); } }
/// <summary> /// Creating the 2D visualization window. /// </summary> /// <param name="window">Orginal window component. </param> public Visualization2D(RenderWindowControl window) { _window = window; vtkInteractorStyleImage imageStyle = vtkInteractorStyleImage.New(); _viewer = vtkImageViewer2.New(); _viewer.OffScreenRenderingOn(); _window.RenderWindow.AddRenderer(_viewer.GetRenderer()); _window.RenderWindow.GetInteractor().SetInteractorStyle(imageStyle); _viewer.Render(); }
static void ReadSupport(string Spath) { vtkJPEGReader reader = vtkJPEGReader.New(); reader.SetFileName(Spath); reader.Update(); // Visualize _ImageViewer = vtkImageViewer2.New(); _ImageViewer.SetInputConnection(reader.GetOutputPort()); _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(_SupportSlice); iren = vtkRenderWindowInteractor.New(); iren.SetRenderWindow(renderWindow); renderWindow.Render(); _ColorLevel = 60; _ImageViewer.SetColorLevel(_BlackLevel); _ImageViewer.Render(); Down(_period, 170); Backward(_period, 1); for (int i = 0; i < _SupportLayers; i++) { System.Threading.Thread.Sleep(_layertime); // delay Backward(_period, 1); } _ImageViewer.SetColorLevel(_BlackLevel); _ImageViewer.Render(); Forward(_period, _MovedLayers); Console.WriteLine(_MovedLayers); 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(); } }
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(); } }
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(); }
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"); 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(); 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(); }