VintaSoft Imaging .NET SDK v8.8 for .NET Framework
In This Topic
    View DICOM multiplanar reconstruction in WPF
    In This Topic

    1. Parameters of DICOM MPR slice visualization

    WpfMprSliceVisualizer class allows to define parameters of visualization for DICOM MPR slice in image viewer. The class allows to define colors and marker point of slice.



    2. Visualization and transformation of DICOM MPR slice in WPF image viewer

    The SDK provides 2 visual tools for visualization and transformation of DICOM MPR slice in WPF image viewer.

    2.1. WpfMprImageTool visual tool

    The visual tool WpfMprImageTool is intended for visualization and transformation of DICOM MPR slice in WPF image viewer. The following operations are supported:

    By default, this visual tool uses the left mouse button for browsing through DICOM MPR slices (moving a DICOM MPR slice along the perpendicular axis) and uses the right mouse button for panning a DICOM MPR slice (moving a DICOM MPR slice along the horizontal and vertical axis).
    WpfMprImageTool.GetInteractionMode method allows to determine, which operation is assigned to the specified mouse button. WpfMprImageTool.SetInteractionMode method allows to assign an operation to a mouse button.

    The visual tool properties allow to define the quality of MPR slice rendering, get a focused MPR slice, etc.

    Also the WpfMprImageTool visual tool allows to build a new DICOM MPR slice in image viewer. The building of DICOM MPR slice can be started by calling of WpfMprImageTool.AddAndBuildSlice method.

    Here is an example that demonstrates how to display an axial DICOM MPR slice in image viewer.
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging.Dicom.Mpr
    ' - Vintasoft.Imaging.Dicom.Mpr.Wpf.UI
    ' - Vintasoft.Imaging.Wpf.UI
    
    ''' <summary>
    ''' Displays the axial slice in viewer.
    ''' </summary>
    ''' <param name="viewer">The image viewer.</param>
    ''' <param name="mprImage">The MPR image.</param>
    Public Shared Sub DisplayAxialSliceInViewer(viewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer, mprImage As Vintasoft.Imaging.Dicom.Mpr.MprImage)
        ' create the MPR visualization controller
        Dim controller As New Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController(mprImage, viewer)
    
        ' create the axial slice
        Dim axialSlice As Vintasoft.Imaging.Dicom.Mpr.MprPlanarSlice = mprImage.CreateAxialSlice(mprImage.YLength / 2.0)
    
        ' add slice to the MPR visualization controller
        controller.AddSliceVisualization(axialSlice, System.Windows.Media.Colors.Yellow)
    
        ' specify that the slice must be shown in viewer
        controller.ShowSliceInViewer(viewer, axialSlice)
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging.Dicom.Mpr
    // - Vintasoft.Imaging.Dicom.Mpr.Wpf.UI
    // - Vintasoft.Imaging.Wpf.UI
    
    /// <summary>
    /// Displays the axial slice in viewer.
    /// </summary>
    /// <param name="viewer">The image viewer.</param>
    /// <param name="mprImage">The MPR image.</param>
    public static void DisplayAxialSliceInViewer(
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer viewer,
        Vintasoft.Imaging.Dicom.Mpr.MprImage mprImage)
    {            
        // create the MPR visualization controller
       Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController controller =
            new Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController(mprImage, viewer);
    
        // create the axial slice
        Vintasoft.Imaging.Dicom.Mpr.MprPlanarSlice axialSlice =
            mprImage.CreateAxialSlice(mprImage.YLength / 2.0);
    
        // add slice to the MPR visualization controller
        controller.AddSliceVisualization(axialSlice, System.Windows.Media.Colors.Yellow);
    
        // specify that the slice must be shown in viewer
        controller.ShowSliceInViewer(viewer, axialSlice);
    }
                    
    


    Here is screenshot of image viewer, which displays a coronal DICOM MPR slice:
    Screenshot of image viewer, which displays a coronal DICOM MPR slice


    2.2. WpfDicomMprTool visual tool

    WpfDicomMprTool is a composite visual tool that combines the functionality of the following visual tools:
    1. WpfMprImageTool ? used for visualization and transformation of DICOM MPR slices in WinForms image viewer.
    2. WpfDicomViewerTool ? used for scaling of DICOM MPR slices in WinForms image viewer and for applying of VOI LUT to the DICOM MPR slice.
    3. WpfImageMeasureTool ? used for measuring of objects on DICOM MPR slice in image viewer.
    4. WpfTextOverlayTool ? used for displaying of text (metadata) on DICOM MPR slice in image viewer.

    Here is an example that demonstrates how to display a coronal DICOM MPR slice with metadata in image viewer.
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging.Dicom.Mpr
    ' - Vintasoft.Imaging.Dicom.Mpr.Wpf.UI
    ' - Vintasoft.Imaging.Wpf.UI
    
    ''' <summary>
    ''' Displays the coronal slice with metadata in viewer.
    ''' </summary>
    ''' <param name="viewer">The image viewer.</param>
    ''' <param name="mprImage">The MPR image.</param>
    Public Shared Sub DisplayCoronalSliceWithMetadataInViewer(viewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer, mprImage As Vintasoft.Imaging.Dicom.Mpr.MprImage)
        ' create the MPR visualization controller
        Dim controller As New Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController(mprImage, viewer)
    
        ' create the coronal slice
        Dim coronalSlice As Vintasoft.Imaging.Dicom.Mpr.MprPlanarSlice = mprImage.CreateCoronalSlice(mprImage.YLength / 2.0)
    
        ' add slice to the MPR visualization controller
        controller.AddSliceVisualization(coronalSlice, System.Windows.Media.Colors.Yellow)
    
        ' specify that the slice must be shown in viewer
        controller.ShowSliceInViewer(viewer, coronalSlice)
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging.Dicom.Mpr
    // - Vintasoft.Imaging.Dicom.Mpr.Wpf.UI
    // - Vintasoft.Imaging.Wpf.UI
    
    /// <summary>
    /// Displays the coronal slice with metadata in viewer.
    /// </summary>
    /// <param name="viewer">The image viewer.</param>
    /// <param name="mprImage">The MPR image.</param>
    public static void DisplayCoronalSliceWithMetadataInViewer(
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer viewer,
        Vintasoft.Imaging.Dicom.Mpr.MprImage mprImage)
    {
        // create the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController controller =
            new Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController(mprImage, viewer);
    
        // create the coronal slice
        Vintasoft.Imaging.Dicom.Mpr.MprPlanarSlice coronalSlice =
            mprImage.CreateCoronalSlice(mprImage.YLength / 2.0);
    
        // add slice to the MPR visualization controller
        controller.AddSliceVisualization(coronalSlice, System.Windows.Media.Colors.Yellow);
    
        // specify that the slice must be shown in viewer
        controller.ShowSliceInViewer(viewer, coronalSlice);
    }
                    
    


    Here is screenshot of image viewer, which displays a coronal DICOM MPR slice with metadata:
    Screenshot of image viewer, which displays a coronal DICOM MPR slice with metadata


    3. Visualization and transformation of several DICOM MPR slices in several WPF image viewers

    WpfMprVisualizationController class allows to control the visualization of several DICOM MPR slices in several WinForms image viewers. For example, it is possible to use 3 image viewers for simultaneous visualization of sagittal, coronal and axial slices of examined object. Or for example, it is possible to use 2 image viewers for simultaneous visualization of sagittal slice and curvilinear slice, which was build on base of the sagittal slice.

    For displaying N slices in N image viewers is necessary to do the following steps:

    Here is an example that demonstrates how to display coronal, sagittal and axial DICOM MPR planar slices in 3 image viewers.
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging.Dicom.Mpr
    ' - Vintasoft.Imaging.Dicom.Mpr.Wpf.UI
    ' - Vintasoft.Imaging.Wpf.UI
    
    ''' <summary>
    ''' Displays the coronal, sagittal and axial DICOM MPR slices in 3 image viewers.
    ''' </summary>
    ''' <param name="sagittalViewer">The sagittal viewer.</param>
    ''' <param name="coronalViewer">The coronal viewer.</param>
    ''' <param name="axialViewer">The axial viewer.</param>
    ''' <param name="mprImage">The MPR image.</param>
    Public Shared Sub DisplayThreePlanarSlicesInThreeViewers(sagittalViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer, coronalViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer, axialViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer, mprImage As Vintasoft.Imaging.Dicom.Mpr.MprImage)
        ' create the MPR visualization controller
        Dim controller As New Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController(mprImage, sagittalViewer, coronalViewer, axialViewer)
    
        ' add slices to the MPR visualization controller
        Dim slices As Vintasoft.Imaging.Dicom.Mpr.MprSlice() = controller.AddThreeSlicesVisualization(mprImage.XLength / 2.0, System.Windows.Media.Colors.LightBlue, mprImage.YLength / 2.0, System.Windows.Media.Colors.Coral, mprImage.ZLength / 2.0, System.Windows.Media.Colors.Yellow)
    
        ' specify that the first slice must be shown in sagittalViewer
        controller.ShowSliceInViewer(sagittalViewer, slices(0))
        ' specify that the second slice must be shown in coronalViewer
        controller.ShowSliceInViewer(coronalViewer, slices(1))
        ' specify that the third slice must be shown in axialViewer
        controller.ShowSliceInViewer(axialViewer, slices(2))
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging.Dicom.Mpr
    // - Vintasoft.Imaging.Dicom.Mpr.Wpf.UI
    // - Vintasoft.Imaging.Wpf.UI
    
    /// <summary>
    /// Displays the coronal, sagittal and axial DICOM MPR slices in 3 image viewers.
    /// </summary>
    /// <param name="sagittalViewer">The sagittal viewer.</param>
    /// <param name="coronalViewer">The coronal viewer.</param>
    /// <param name="axialViewer">The axial viewer.</param>
    /// <param name="mprImage">The MPR image.</param>
    public static void DisplayThreePlanarSlicesInThreeViewers(
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer sagittalViewer,
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer coronalViewer,
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer axialViewer,
        Vintasoft.Imaging.Dicom.Mpr.MprImage mprImage)
    {
        // create the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController controller =
            new Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController(
            mprImage, sagittalViewer, coronalViewer, axialViewer);
    
        // add slices to the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.MprSlice[] slices = controller.AddThreeSlicesVisualization(
            mprImage.XLength / 2.0, System.Windows.Media.Colors.LightBlue,
            mprImage.YLength / 2.0, System.Windows.Media.Colors.Coral,
            mprImage.ZLength / 2.0, System.Windows.Media.Colors.Yellow);
    
        // specify that the first slice must be shown in sagittalViewer
        controller.ShowSliceInViewer(sagittalViewer, slices[0]);
        // specify that the second slice must be shown in coronalViewer
        controller.ShowSliceInViewer(coronalViewer, slices[1]);
        // specify that the third slice must be shown in axialViewer
        controller.ShowSliceInViewer(axialViewer, slices[2]);
    }
                    
    


    Here is screenshot of 3 image viewers, which display coronal, sagittal and axial DICOM MPR planar slices:
    Screenshot of 3 image viewers, which display coronal, sagittal and axial DICOM MPR planar slices


    Here is an example that demonstrates how to display an axial DICOM MPR slice in the first image viewer and build and display the curvlinear DICOM MPR slice, which is based on axial slice, in the second image viewer.
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging.Dicom.Mpr
    ' - Vintasoft.Imaging.Dicom.Mpr.Wpf.UI
    ' - Vintasoft.Imaging.Wpf.UI
    
    ''' <summary>
    ''' Displays an axial DICOM MPR slice in the first image viewer and
    ''' builds and displays the curvlinear DICOM MPR slice, which is based on axial slice, in the second image viewer.
    ''' </summary>
    ''' <param name="axialViewer">The viewer with axial slice.</param>
    ''' <param name="curvlinearViewer">The viewer with curvlinear slice.</param>
    ''' <param name="mprImage">The MPR image.</param>
    Public Shared Sub DisplayAxialAndCurvilinearSlicesInTwoViewers(axialViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer, curvlinearViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer, mprImage As Vintasoft.Imaging.Dicom.Mpr.MprImage)
        ' create the MPR visualization controller
        Dim controller As New Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController(mprImage, axialViewer, curvlinearViewer)
    
    
        ' create the axial slice
        Dim axialSlice As Vintasoft.Imaging.Dicom.Mpr.MprPlanarSlice = mprImage.CreateAxialSlice(mprImage.ZLength / 2.0)
        ' add axial slice to the MPR visualization controller
        controller.AddSliceVisualization(axialSlice, System.Windows.Media.Colors.Yellow)
    
        ' show the axial slice in axialViewer
        controller.ShowSliceInViewer(axialViewer, axialSlice)
    
    
        ' create the curvlinear slice
        Dim curvlinearSlice As Vintasoft.Imaging.Dicom.Mpr.MprCurvilinearSlice = mprImage.CreateCurvilinearSlice(axialSlice, Nothing)
        ' set parameters of curvilinear slice
        curvlinearSlice.RenderingMode = Vintasoft.Imaging.Dicom.Mpr.MprSliceRenderingMode.Avg
        curvlinearSlice.Thickness = 10
        Dim curvlinearSliceVisualizer As New Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprSliceVisualizer(curvlinearSlice, System.Windows.Media.Colors.Blue)
    
        ' get the DICOM MPR tool, which will be used for building the curvilinear slice
        Dim dicomMprTool As Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.VisualTools.WpfDicomMprTool = controller.GetDicomMprToolAssociatedWithImageViewer(axialViewer)
        ' add the curvilinear slice to the visual tool and start building of slice
        dicomMprTool.MprImageTool.AddAndBuildSlice(curvlinearSliceVisualizer)
    
        ' show the curvlinear slice in curvlinearViewer
        controller.ShowSliceInViewer(curvlinearViewer, curvlinearSlice)
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging.Dicom.Mpr
    // - Vintasoft.Imaging.Dicom.Mpr.Wpf.UI
    // - Vintasoft.Imaging.Wpf.UI
    
    /// <summary>
    /// Displays an axial DICOM MPR slice in the first image viewer and
    /// builds and displays the curvlinear DICOM MPR slice, which is based on axial slice, in the second image viewer.
    /// </summary>
    /// <param name="axialViewer">The viewer with axial slice.</param>
    /// <param name="curvlinearViewer">The viewer with curvlinear slice.</param>
    /// <param name="mprImage">The MPR image.</param>
    public static void DisplayAxialAndCurvilinearSlicesInTwoViewers(
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer axialViewer,
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer curvlinearViewer,
        Vintasoft.Imaging.Dicom.Mpr.MprImage mprImage)
    {
        // create the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController controller =
            new Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprVisualizationController(
            mprImage, axialViewer, curvlinearViewer);
    
    
        // create the axial slice
        Vintasoft.Imaging.Dicom.Mpr.MprPlanarSlice axialSlice = mprImage.CreateAxialSlice(mprImage.ZLength / 2.0);
        // add axial slice to the MPR visualization controller
        controller.AddSliceVisualization(axialSlice, System.Windows.Media.Colors.Yellow);
    
        // show the axial slice in axialViewer
        controller.ShowSliceInViewer(axialViewer, axialSlice);
    
    
        // create the curvlinear slice
        Vintasoft.Imaging.Dicom.Mpr.MprCurvilinearSlice curvlinearSlice = mprImage.CreateCurvilinearSlice(
            axialSlice, null);
        // set parameters of curvilinear slice
        curvlinearSlice.RenderingMode = Vintasoft.Imaging.Dicom.Mpr.MprSliceRenderingMode.Avg;
        curvlinearSlice.Thickness = 10;
        Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprSliceVisualizer curvlinearSliceVisualizer =
            new Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.WpfMprSliceVisualizer(curvlinearSlice, System.Windows.Media.Colors.Blue);
    
        // get the DICOM MPR tool, which will be used for building the curvilinear slice
        Vintasoft.Imaging.Dicom.Mpr.Wpf.UI.VisualTools.WpfDicomMprTool dicomMprTool =
             controller.GetDicomMprToolAssociatedWithImageViewer(axialViewer);
        // add the curvilinear slice to the visual tool and start building of slice
        dicomMprTool.MprImageTool.AddAndBuildSlice(curvlinearSliceVisualizer);
    
        // show the curvlinear slice in curvlinearViewer
        controller.ShowSliceInViewer(curvlinearViewer, curvlinearSlice);
    }
                    
    


    Here is screenshot of 2 image viewers, which display an axial DICOM MPR slice with curvilinear DICOM MPR slice:
    Screenshot of 2 image viewers, which display an axial DICOM MPR slice with curvilinear DICOM MPR slice