Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.4.5
|
This tutorial teaches you how to use the cut-plane and double cut-plane features to generate a slice out of a stack of images.
Note: If you do not intend to load a DICOM file, then you do not need to add Leadtools.Dicom.dll.
Note: If you encounter an "Invalid File Format" or "Feature Not Supported" exception, please refer to the topic Invalid File Format/Feature Not Supported.
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.MedicalViewer
Imports Leadtools.Medical3D
Imports Leadtools.Dicom
[C#]
using Leadtools;
using Leadtools.Codecs;
using Leadtools.MedicalViewer;
using Leadtools.Medical3D;
using Leadtools.Dicom;
Private Sub InitClass()
Dim MY_LICENSE_FILE As String = "d:\temp\TestLic.lic"
' Unlock DICOM support
Dim MY_DicomDEVELOPER_KEY As String = "xyz123abc"
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DicomDEVELOPER_KEY);
' Unlock Medical support
Dim MY_MedicalDEVELOPER_KEY As String = "abc123xyz"
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_MedicalDEVELOPER_KEY);
' Unlock Medical 3D support
Dim MY_3DDEVELOPER_KEY As String = "123xyzabc"
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_3DDEVELOPER_KEY);
' Create a new instance of the codecs class, which will be used to load the images.
Dim _codecs As RasterCodecs = New RasterCodecs()
' Create a new instance of the Medical Viewer, the layout will be divided to 2X2.
Dim viewer As MedicalViewer = New MedicalViewer(2, 2)
' Fit the view to the whole form
viewer.Dock = DockStyle.Fill
' Create the cell that will hold the stack of images.
Dim cell As MedicalViewerMultiCell = New MedicalViewerMultiCell()
' Add the cell above to the MedicalViewer.
viewer.Cells.Add(cell)
cell.Image = _codecs.Load("C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm")
' Add the viewer as a child to the form.
Me.Controls.Add(viewer)
End Sub
[C#]
void InitClass()
{
string MY_LICENSE_FILE = "d:\\temp\\TestLic.lic";
// Unlock DICOM support
string MY_DicomDEVELOPER_KEY = "xyz123abc";
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DicomDEVELOPER_KEY);
// Unlock Medical support
string MY_MedicalDEVELOPER_KEY = "abc123xyz";
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_MedicalDEVELOPER_KEY);
// Unlock Medical 3D support
string MY_3DDEVELOPER_KEY = "123xyzabc";
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_3DDEVELOPER_KEY);
// Create a new instance of the codecs class, which will be used to load the images.
RasterCodecs _codecs = new RasterCodecs();
// Create a new instance of the Medical Viewer, the layout will be divided to 2X2.
MedicalViewer viewer = new MedicalViewer(2, 2);
// Fit the view to the whole form
viewer.Dock = DockStyle.Fill;
// Create the cell that will hold the stack of images.
MedicalViewerMultiCell cell = new MedicalViewerMultiCell();
// Add the cell above to the MedicalViewer.
viewer.Cells.Add(cell);
cell.Image = _codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm");
// Add the viewer as a child to the form.
this.Controls.Add(viewer);
}
Note: You may need to change the above path to point to "image1.dcm" located in the LEADTOOLS images directory.
Show()
Update()
[C#]
Show();
Update();
AddHandler cell.Data3DRequested, AddressOf Of MedicalViewerData3DRequestedEventArgs
[C#]
cell.Data3DRequested += new EventHandler<MedicalViewerData3DRequestedEventArgs>(cell_Data3DRequested);
Make the event handler procedure look as shown below:
Private Sub cell_Data3DRequested(ByVal sender As Object, ByVal e As MedicalViewerData3DRequestedEventArgs)
e.Succeed = Medical3DEngine.Provide3DInformation(e)
End Sub
C#
void cell_Data3DRequested(object sender, MedicalViewerData3DRequestedEventArgs e)
{
e.Succeed = Medical3DEngine.Provide3DInformation(e);
}
AddHandler cell.Data3DFrameRequested, AddressOf Of MedicalViewer3DFrameRequestedEventArgs
[C#]
cell.Data3DFrameRequested += new EventHandler<MedicalViewer3DFrameRequestedEventArgs>(cell_Data3DFrameRequested);
Make the event handler procedure look like as shown below (You may need to change the file name based on the file name you chose in the previous steps):
Private Sub cell_Data3DFrameRequested(ByVal sender As Object, ByVal e As MedicalViewer3DFrameRequestedEventArgs)
' Create a new instance of the Codecs class, which will be used to load the images.
Dim _codecs As RasterCodecs = New RasterCodecs()
' This line loads the image with the desired frame index (e.ImageIndex) and assigns it to the argument parameter Image.
e.Image = _codecs.Load("C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm", 0, CodecsLoadByteOrder.BgrOrGray, e.ImageIndex + 1, e.ImageIndex + 1)
End Sub
[C#]
void cell_Data3DFrameRequested(object sender, MedicalViewer3DFrameRequestedEventArgs e)
{
// Create a new instance of the Codecs class, which will be used to load the images.
RasterCodecs _codecs = new RasterCodecs();
// This line loads the image with the desired frame index (e.ImageIndex) and assigns it to the argument parameter Image.
e.Image = _codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm", 0, CodecsLoadByteOrder.BgrOrGray, e.ImageIndex + 1, e.ImageIndex + 1);
}
' Creating a double cut-line: The double cut-line consist of two cut-lines. For each one, you will need to create a cell.
MedicalViewerCell firstCutLineCell = new MedicalViewerCell()
MedicalViewerCell secondCutLineCell = new MedicalViewerCell()
' add both of the instances to the MedicalViewer instance.
viewer.Cells.Add(firstCutLineCell)
viewer.Cells.Add(secondCutLineCell)
[C#]
// Creating a double cut-line: The double cut-line consist of two cut-lines. For each one, you will need to create a cell.
MedicalViewerCell firstCutLineCell = new MedicalViewerCell();
MedicalViewerCell secondCutLineCell = new MedicalViewerCell();
// add both of the instances to the MedicalViewer instance.
viewer.Cells.Add(firstCutLineCell);
viewer.Cells.Add(secondCutLineCell);
These instances will be used to view the double cut-lines output images.
Dim doubleCutLine As MedicalViewerDoublePlaneCutLine = new MedicalViewerDoublePlaneCutLine(firstCutLineCell, secondCutLineCell)
[C#]
MedicalViewerDoublePlaneCutLine doubleCutLine = new MedicalViewerDoublePlaneCutLine(firstCutLineCell, secondCutLineCell);
cell.ReferenceLine.DoubleCutLines.Add(doubleCutLine)
[C#]
cell.ReferenceLine.DoubleCutLines.Add(doubleCutLine);
Public Sub New()
InitializeComponent()
InitClass()
End Sub
Private Sub InitClass()
Dim MY_LICENSE_FILE As String = "d:\temp\TestLic.lic"
' Unlock DICOM support
Dim MY_DicomDEVELOPER_KEY As String = "xyz123abc"
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DicomDEVELOPER_KEY);
' Unlock Medical support
Dim MY_MedicalDEVELOPER_KEY As String = "abc123xyz"
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_MedicalDEVELOPER_KEY);
' Unlock Medical 3D support
Dim MY_3DDEVELOPER_KEY As String = "123xyzabc"
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_3DDEVELOPER_KEY);
' Create a new instance of the codecs class, which will be used to load the images.
Dim _codecs As RasterCodecs = New RasterCodecs()
' Create a new instance of the Medical Viewer, the layout will be divided to 2X2.
Dim viewer As MedicalViewer = New MedicalViewer(2, 2)
' Fit the view to the whole form
viewer.Dock = DockStyle.Fill
' Create the cell that will hold the stack of images.
Dim cell As MedicalViewerMultiCell = New MedicalViewerMultiCell()
' Add the cell above to the MedicalViewer.
viewer.Cells.Add(cell)
cell.Image = _codecs.Load("C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm")
' Add the viewer as a child to the form.
Me.Controls.Add(viewer)
Show()
Update()
AddHandler cell.Data3DRequested, AddressOf Of MedicalViewerData3DRequestedEventArgs
AddHandler cell.Data3DFrameRequested, AddressOf Of MedicalViewer3DFrameRequestedEventArgs
' Creating a double cut-line: The double cut-line consist of two cut-lines. For each one, you will need to create a cell.
Dim firstCutLineCell As MedicalViewerCell = New MedicalViewerCell()
Dim secondCutLineCell As MedicalViewerCell = New MedicalViewerCell()
' add both of the instances to the MedicalViewer instance.
viewer.Cells.Add(firstCutLineCell)
viewer.Cells.Add(secondCutLineCell)
Dim doubleCutLine As MedicalViewerDoublePlaneCutLine = New MedicalViewerDoublePlaneCutLine(firstCutLineCell, secondCutLineCell)
cell.ReferenceLine.DoubleCutLines.Add(doubleCutLine)
End Sub
Private Sub cell_Data3DRequested(ByVal sender As Object, ByVal e As MedicalViewerData3DRequestedEventArgs)
e.Succeed = Medical3DEngine.Provide3DInformation(e)
End Sub
Private Sub cell_Data3DFrameRequested(ByVal sender As Object, ByVal e As MedicalViewer3DFrameRequestedEventArgs)
' Create a new instance of the Codecs class, which will be used to load the images.
Dim _codecs As RasterCodecs = New RasterCodecs()
' This line loads the image with the desired frame index (e.ImageIndex) and assigns it to the argument parameter Image.
e.Image = _codecs.Load("C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm", 0, CodecsLoadByteOrder.BgrOrGray, e.ImageIndex + 1, e.ImageIndex + 1)
End Sub
[C#]
public Form1()
{
InitializeComponent();
InitClass();
}
void InitClass()
{
string MY_LICENSE_FILE = "d:\\temp\\TestLic.lic";
// Unlock DICOM support
string MY_DicomDEVELOPER_KEY = "xyz123abc";
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DicomDEVELOPER_KEY);
// Unlock Medical support
string MY_MedicalDEVELOPER_KEY = "abc123xyz";
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_MedicalDEVELOPER_KEY);
// Unlock Medical 3D support
string MY_3DDEVELOPER_KEY = "123xyzabc";
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_3DDEVELOPER_KEY);
// Create a new instance of the codecs class, which will be used to load the images.
RasterCodecs _codecs = new RasterCodecs();
// Create a new instance of the Medical Viewer, the layout will be divided to 2X2.
MedicalViewer viewer = new MedicalViewer(2, 2);
// Fit the view to the whole form
viewer.Dock = DockStyle.Fill;
// Create the cell that will hold the stack of images.
MedicalViewerMultiCell cell = new MedicalViewerMultiCell();
// Add the cell above to the MedicalViewer.
viewer.Cells.Add(cell);
cell.Image = _codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm");
// Add the viewer as a child to the form.
this.Controls.Add(viewer);
Show();
Update();
cell.Data3DRequested += new EventHandler<MedicalViewerData3DRequestedEventArgs>(cell_Data3DRequested);
cell.Data3DFrameRequested += new EventHandler<MedicalViewer3DFrameRequestedEventArgs>(cell_Data3DFrameRequested);
// Creating a double cut-line: The double cut-line consist of two cut-lines. For each one, you will need to create a cell.
MedicalViewerCell firstCutLineCell = new MedicalViewerCell();
MedicalViewerCell secondCutLineCell = new MedicalViewerCell();
// add both of the instances to the MedicalViewer instance.
viewer.Cells.Add(firstCutLineCell);
viewer.Cells.Add(secondCutLineCell);
MedicalViewerDoublePlaneCutLine doubleCutLine = new MedicalViewerDoublePlaneCutLine(firstCutLineCell, secondCutLineCell);
cell.ReferenceLine.DoubleCutLines.Add(doubleCutLine);
}
void cell_Data3DRequested(object sender, MedicalViewerData3DRequestedEventArgs e)
{
e.Succeed = Medical3DEngine.Provide3DInformation(e);
}
void cell_Data3DFrameRequested(object sender, MedicalViewer3DFrameRequestedEventArgs e)
{
// Create a new instance of the Codecs class, which will be used to load the images.
RasterCodecs _codecs = new RasterCodecs();
// This line loads the image with the desired frame index (e.ImageIndex) and assigns it to the argument parameter Image.
e.Image = _codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\image1.dcm", 0, CodecsLoadByteOrder.BgrOrGray, e.ImageIndex + 1, e.ImageIndex + 1);
}
Note: For more information on how to acquire the above unlock keys, please contact LEAD Technologies support.
Note: Now you will need to have DICOMDIR files for the next step. You can download a sample from our site. Download the file from here (Download chest_ct_compressed_subset_for_3d_tutorial.zip), and extract the file to "C:\Leadtools_DICOMDIR". For more information on building 3D objects from a DICOMDIR, please see Loading a DICOMDIR To Create a 3D Object.