VintaSoft Imaging .NET SDK 12.3: Documentation for .NET developer
In This Topic
    DICOM: View DICOM multiplanar reconstruction in WinForms
    In This Topic

    1. Parameters of DICOM MPR slice visualization

    MprSliceVisualizer 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 WinForms image viewer

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

    2.1. MprImageTool visual tool

    The visual tool MprImageTool is intended for visualization and transformation of DICOM MPR slice in WinForms 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).
    MprImageTool.GetInteractionMode method allows to determine, which operation is assigned to the specified mouse button. MprImageTool.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 MprImageTool 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 MprImageTool.AddAndBuildSlice method.

    Here is an example that demonstrates how to display an axial DICOM MPR slice in image viewer.
    /// <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.UI.ImageViewer viewer, 
        Vintasoft.Imaging.Dicom.Mpr.MprImage mprImage)
    {            
        // create the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController controller =
            new Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController(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.Drawing.Color.Yellow);
    
        // specify that the slice must be shown in viewer
        controller.ShowSliceInViewer(viewer, axialSlice);
    }
    
    ''' <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.UI.ImageViewer, mprImage As Vintasoft.Imaging.Dicom.Mpr.MprImage)
        ' create the MPR visualization controller
        Dim controller As New Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController(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.Drawing.Color.Yellow)
    
        ' specify that the slice must be shown in viewer
        controller.ShowSliceInViewer(viewer, axialSlice)
    End Sub
    


    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. DicomMprTool visual tool

    DicomMprTool is a composite visual tool that combines the functionality of the following visual tools:
    1. MprImageTool � used for visualization and transformation of DICOM MPR slices in WinForms image viewer.
    2. DicomViewerTool � used for scaling of DICOM MPR slices in WinForms image viewer and for applying of VOI LUT to the DICOM MPR slice.
    3. ImageMeasureTool � used for measuring of objects on DICOM MPR slice in image viewer.
    4. TextOverlayTool � 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.
    /// <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.UI.ImageViewer viewer, 
        Vintasoft.Imaging.Dicom.Mpr.MprImage mprImage)
    {            
        // create the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController controller =
            new Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController(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.Drawing.Color.Yellow);
    
        // specify that the slice must be shown in viewer
        controller.ShowSliceInViewer(viewer, coronalSlice);
    }
    
    ''' <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.UI.ImageViewer, mprImage As Vintasoft.Imaging.Dicom.Mpr.MprImage)
        ' create the MPR visualization controller
        Dim controller As New Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController(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.Drawing.Color.Yellow)
    
        ' specify that the slice must be shown in viewer
        controller.ShowSliceInViewer(viewer, coronalSlice)
    End Sub
    


    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 WinForms image viewers

    MprVisualizationController 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.
    /// <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.UI.ImageViewer sagittalViewer,
        Vintasoft.Imaging.UI.ImageViewer coronalViewer,
        Vintasoft.Imaging.UI.ImageViewer axialViewer,
        Vintasoft.Imaging.Dicom.Mpr.MprImage mprImage)
    {
        // create the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController controller =
            new Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController(
            mprImage, sagittalViewer, coronalViewer, axialViewer);
    
        // add slices to the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.MprSlice[] slices = controller.AddThreeSlicesVisualization(
            mprImage.XLength / 2.0, System.Drawing.Color.LightBlue,
            mprImage.YLength / 2.0, System.Drawing.Color.Coral,
            mprImage.ZLength / 2.0, System.Drawing.Color.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]);
    }
    
    ''' <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.UI.ImageViewer, coronalViewer As Vintasoft.Imaging.UI.ImageViewer, axialViewer As Vintasoft.Imaging.UI.ImageViewer, mprImage As Vintasoft.Imaging.Dicom.Mpr.MprImage)
        ' create the MPR visualization controller
        Dim controller As New Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController(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.Drawing.Color.LightBlue, mprImage.YLength / 2.0, System.Drawing.Color.Coral, mprImage.ZLength / 2.0, System.Drawing.Color.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
    


    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.
    /// <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.UI.ImageViewer axialViewer,
        Vintasoft.Imaging.UI.ImageViewer curvlinearViewer,
        Vintasoft.Imaging.Dicom.Mpr.MprImage mprImage)
    {
        // create the MPR visualization controller
        Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController controller =
            new Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController(
            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.Drawing.Color.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.UI.MprSliceVisualizer curvlinearSliceVisualizer =
            new Vintasoft.Imaging.Dicom.Mpr.UI.MprSliceVisualizer(curvlinearSlice, System.Drawing.Color.Blue);
    
        // get the DICOM MPR tool, which will be used for building the curvilinear slice
        Vintasoft.Imaging.Dicom.Mpr.UI.VisualTools.DicomMprTool 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);
    }
    
    ''' <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.UI.ImageViewer, curvlinearViewer As Vintasoft.Imaging.UI.ImageViewer, mprImage As Vintasoft.Imaging.Dicom.Mpr.MprImage)
        ' create the MPR visualization controller
        Dim controller As New Vintasoft.Imaging.Dicom.Mpr.UI.MprVisualizationController(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.Drawing.Color.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.UI.MprSliceVisualizer(curvlinearSlice, System.Drawing.Color.Blue)
    
        ' get the DICOM MPR tool, which will be used for building the curvilinear slice
        Dim dicomMprTool As Vintasoft.Imaging.Dicom.Mpr.UI.VisualTools.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)
    End Sub
    


    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