<div>Hi, VTK guys,<br><br>I use vtkResliceImageViewer to display DICOM series. But the 2 cross hairs are not displayed. How to
show it? The reslice mode to axis-aligned. The GreyToColors()
function adds LookupTable for the image viewer.<br><br>My code below:<br><br> private void Display2(vtkRenderWindow aRenderWindow, vtkImageData aData)<br> {<br> if (aData == null)<br> return;<br><br> m_imageViewer = vtkResliceImageViewer.New();<br> <br> vtkRenderWindowInteractor interactor = aRenderWindow.GetInteractor();<br><br> m_renderer = aRenderWindow.GetRenderers().GetFirstRenderer();<br> m_renderer.SetBackground(0.0, 0.0, 0.0);<br><br> m_imageViewer.SetRenderWindow(aRenderWindow);<br><br> m_imageViewer.SetupInteractor(interactor);<br> m_imageViewer.SetRenderer(m_renderer);<br> //aRenderWindow.GetRenderers().InitTraversal();<br><br> m_imageViewer.SetInputData(aData);<br> m_imageViewer.SliceScrollOnMouseWheelOn();<br> m_imageViewer.SetResliceModeToAxisAligned();<br> //m_imageViewer.SetResliceModeToOblique();<br>
vtkResliceCursorLineRepresentation rep =
vtkResliceCursorLineRepresentation.SafeDownCast(m_imageViewer.GetResliceCursorWidget().GetRepresentation());<br> rep.GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal((int)m_sliceDirection);<br> switch (m_sliceDirection)<br> {<br> case Direction.AXIAL:<br> m_imageViewer.SetSliceOrientationToXY();<br> break;<br> case Direction.CORONAL:<br> m_imageViewer.SetSliceOrientationToYZ();<br> break;<br> case Direction.SAGITTAL:<br> m_imageViewer.SetSliceOrientationToXZ();<br> break;<br> default:<br> break;<br> }<br> m_imageViewer.SetThickMode(1);<br> m_imageViewer.GetSliceRange(ref m_minSliceNumber, ref m_maxSliceNumber);<br> m_currentSlice = m_minSliceNumber + (m_maxSliceNumber - m_minSliceNumber) / 2;<br> m_imageViewer.SetSlice(m_currentSlice);<br><br> m_scalarrange = new double[2];<br> m_scalarrange = m_imageViewer.GetInput().GetScalarRange();<br><br> if (!m_initialized)<br> {<br> m_threshold = new Segament_Threshold();<br> m_threshold.Min_Threshold = 0;<br> m_threshold.Max_Threshold = m_scalarrange[1];<br> }<br> GrayToColors(m_threshold);<br> m_initialized = true;<br> }<br><br> private void GrayToColors( Segament_Threshold threshold)<br> {<br> vtkLookupTable colormap = vtkLookupTable.New();<br><br> double validmin = System.Math.Max(m_scalarrange[0], threshold.Min_Threshold);<br> double validmax = System.Math.Min(m_scalarrange[1], threshold.Max_Threshold);<br> int number = (int)(m_scalarrange[1] - m_scalarrange[0] + 1);<br> colormap.SetRange(m_scalarrange[0], m_scalarrange[1]);<br> colormap.SetNumberOfTableValues(number);<br> colormap.Build();<br><br> //for (int i = (int)(scalarrange[0]); i < (int)(threshhold[0]); i++)<br> //{<br> // colormap.SetTableValue(i - (int)scalarrange[0], 0.0, 0.0, 0.0, 0.0);<br> //}<br> for (int i = (int)(validmin); i <= (int)(validmax); i++)<br> {<br>
colormap.SetTableValue(i - (int)m_scalarrange[0],
RenderingColor.RENDERING_RED, RenderingColor.RENDERING_GREEN,
RenderingColor.RENDERING_BLUE, 1.0);<br> }<br> for (int i = (int)(threshold.Max_Threshold) + 1; i < (int)(m_scalarrange[1]); i++)<br> {<br> colormap.SetTableValue(i - (int)m_scalarrange[0], 0.0, 0.0, 0.0, 0.0);<br> }<br><br> //vtkImageMapToColors colormapper = vtkImageMapToColors.New();<br> //colormapper.SetInputConnection(data);<br> vtkImageMapToWindowLevelColors colormapper = m_imageViewer.GetWindowLevel();<br> colormapper.SetOutputFormatToRGB();<br> colormapper.SetLookupTable(colormap);<br> colormapper.Update();<br><br> if (!m_initialized)<br> m_colormapActor = vtkImageActor.New();<br> m_colormapActor.SetInputData(colormapper.GetOutput());<br> if (!m_initialized)<br> m_renderer.AddActor(m_colormapActor); <br> m_renderer.ResetCamera();<br> m_renderer.Modified();<br> m_imageViewer.Render();<br> }<br><br>Thanks<br>Liu Peng<br><br></div><br><br><span title="neteasefooter"><p> </p></span>