Leadtools.Dicom.Common Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
GetImage Method
See Also 
Leadtools.Dicom.Common.Extensions Namespace > DicomExtensions Class : GetImage Method



ds
The Leadtools.Dicom.DicomDataSet that contains the image orientation vectors
element
An item in the Data Set.
index
The zero-based index of the frame to load.
bitsPerPixel
Value that represents the resulting image pixel depth. Possible values are:
Value Meaning
0 Keep the original file's pixel depth (do not convert).
1 to 8 The specified bits per pixel in the resulting image.
12 12 bits per pixel in the resulting image.
16 16 bits per pixel in the resulting image.
24 24 bits per pixel in the resulting image.
32 32 bits per pixel in the resulting image.
order
This value is ignored.
flags
Flags that control the behaviour of this method.
orientation
An OrientationConfiguration that will be applied to the current view perpspective.
ds
The Leadtools.Dicom.DicomDataSet that contains the image orientation vectors
element
An item in the Data Set.
index
The zero-based index of the frame to load.
bitsPerPixel
Value that represents the resulting image pixel depth. Possible values are:
Value Meaning
0 Keep the original file's pixel depth (do not convert).
1 to 8 The specified bits per pixel in the resulting image.
12 12 bits per pixel in the resulting image.
16 16 bits per pixel in the resulting image.
24 24 bits per pixel in the resulting image.
32 32 bits per pixel in the resulting image.
order
This value is ignored.
flags
Flags that control the behaviour of this method.
orientation
An OrientationConfiguration that will be applied to the current view perpspective.
Returns the Leadtools.RasterImage contained in the Leadtools.Dicom.DicomDataSet, but with the Leadtools.RasterViewPerspective changed accordingly from applying a PlaneOrientation to a given Leadtools.RasterViewPerspective.

Syntax

Visual Basic (Declaration) 
<ExtensionAttribute()>
Public Shared Function GetImage( _
   ByVal ds As DicomDataSet, _
   ByVal element As DicomElement, _
   ByVal index As Integer, _
   ByVal bitsPerPixel As Integer, _
   ByVal order As RasterByteOrder, _
   ByVal flags As DicomGetImageFlags, _
   ByVal orientation As OrientationConfiguration _
) As RasterImage
Visual Basic (Usage)Copy Code
Dim ds As DicomDataSet
Dim element As DicomElement
Dim index As Integer
Dim bitsPerPixel As Integer
Dim order As RasterByteOrder
Dim flags As DicomGetImageFlags
Dim orientation As OrientationConfiguration
Dim value As RasterImage
 
value = DicomExtensions.GetImage(ds, element, index, bitsPerPixel, order, flags, orientation)

Parameters

ds
The Leadtools.Dicom.DicomDataSet that contains the image orientation vectors
element
An item in the Data Set.
index
The zero-based index of the frame to load.
bitsPerPixel
Value that represents the resulting image pixel depth. Possible values are:
Value Meaning
0 Keep the original file's pixel depth (do not convert).
1 to 8 The specified bits per pixel in the resulting image.
12 12 bits per pixel in the resulting image.
16 16 bits per pixel in the resulting image.
24 24 bits per pixel in the resulting image.
32 32 bits per pixel in the resulting image.
order
This value is ignored.
flags
Flags that control the behaviour of this method.
orientation
An OrientationConfiguration that will be applied to the current view perpspective.

Return Value

The image of a Pixel Data element.

Example

This example does the following:

  • Loads a DICOM dataset that contains orientation vectors that orient it as a coronal slice
  • Creates an OrientationConfiguration that contains a coronal PlaneOrientation that corresponds to a horizontal flip
  • Gets the image from the DICOM dataset and modifies the view perpsective to reflect OrientationConfiguration

Visual BasicCopy Code
Public Sub GetImageExample()
    Dim dicomFileCoronal As String = LeadtoolsExamples.Common.ImagesPath.Path & "coronal.dcm"
    Dim ds As New DicomDataSet()
    ds.Load(dicomFileCoronal, DicomDataSetLoadFlags.None)

    ' Create a new coronal PlaneOrientation that corresponds to a horizontal flip
    Dim poCoronal As New PlaneOrientation()
    poCoronal.Name = "Coronal or Frontal"
    poCoronal.Top = OrientationAxis.Inferior
    poCoronal.Right = OrientationAxis.Right
    poCoronal.Condition = New TagValueOrientationCondition(DicomTag.ImageOrientationPatient, Nothing)
    If (Not poCoronal.IsValid(Plane.Coronal)) Then
        MessageBox.Show("Invalid PlaneOrientation for Coronal")
        Return
    End If

    ' Create a new sagittal PlaneOrientation that corresponds to a Rotate90
    Dim poSaggital As New PlaneOrientation()
    poSaggital.Name = "Saggital"
    poSaggital.Top = OrientationAxis.Anterior
    poSaggital.Right = OrientationAxis.Inferior
    poSaggital.Condition = New TagValueOrientationCondition(0, Nothing)
    If (Not poSaggital.IsValid(Plane.Sagittal)) Then
        MessageBox.Show("Invalid PlaneOrientation for Sagittal")
        Return
    End If

    ' Create a new Axial that corresponds to a Rotate180
    Dim poAxial As New PlaneOrientation()
    poAxial.Name = "Axial"
    poAxial.Top = OrientationAxis.Posterior
    poAxial.Right = OrientationAxis.Left
    poAxial.Condition = New TagValueOrientationCondition(0, Nothing)
    If (Not poAxial.IsValid(Plane.Axial)) Then
        MessageBox.Show("Invalid PlaneOrientation for Axial")
        Return
    End If

    ' Setup the OrientationConfiguration
    Dim oc As New OrientationConfiguration()
    oc.Coronal.Add(poCoronal)
    oc.Sagittal.Add(poSaggital)
    oc.Axial.Add(poAxial)
    If (Not oc.IsValid()) Then
        MessageBox.Show("Invalid OrientationConfiguration")
        Return
    End If

    ' Find the image from the dataset with the new view perspective
    ' RasterViewPerspective newViewPerspective = ds.GetNewViewPerspective(RasterViewPerspective.TopLeft, oc);
    Dim image As RasterImage = ds.GetImage(Nothing, 0, 0, RasterByteOrder.Gray, DicomGetImageFlags.None, oc)

    ' New view perspective should be BottomLeft
    Dim newViewPerspective As RasterViewPerspective = image.ViewPerspective
    MessageBox.Show("newViewPerspective should be BottomLeft" & Constants.vbLf & "Actual newViewPerspective is " & newViewPerspective.ToString())
End Sub
C#Copy Code
public void GetImageExample()
{
   string dicomFileCoronal = LeadtoolsExamples.Common.ImagesPath.Path + "coronal.dcm";
   DicomDataSet ds = new DicomDataSet();
   ds.Load(dicomFileCoronal, DicomDataSetLoadFlags.None);

   // Create a new coronal PlaneOrientation that corresponds to a horizontal flip
   PlaneOrientation poCoronal = new PlaneOrientation();
   poCoronal.Name = "Coronal or Frontal";
   poCoronal.Top = OrientationAxis.Inferior;
   poCoronal.Right = OrientationAxis.Right;
   poCoronal.Condition = new TagValueOrientationCondition(DicomTag.ImageOrientationPatient, null);
   if (!poCoronal.IsValid(Plane.Coronal))
   {
      MessageBox.Show("Invalid PlaneOrientation for Coronal");
      return;
   }

   // Create a new sagittal PlaneOrientation that corresponds to a Rotate90
   PlaneOrientation poSaggital = new PlaneOrientation();
   poSaggital.Name = "Saggital";
   poSaggital.Top = OrientationAxis.Anterior;
   poSaggital.Right = OrientationAxis.Inferior;
   poSaggital.Condition = new TagValueOrientationCondition(0, null);
   if (!poSaggital.IsValid(Plane.Sagittal))
   {
      MessageBox.Show("Invalid PlaneOrientation for Sagittal");
      return;
   }

   // Create a new Axial that corresponds to a Rotate180
   PlaneOrientation poAxial = new PlaneOrientation();
   poAxial.Name = "Axial";
   poAxial.Top = OrientationAxis.Posterior;
   poAxial.Right = OrientationAxis.Left;
   poAxial.Condition = new TagValueOrientationCondition(0, null);
   if (!poAxial.IsValid(Plane.Axial))
   {
      MessageBox.Show("Invalid PlaneOrientation for Axial");
      return;
   }

   // Setup the OrientationConfiguration
   OrientationConfiguration oc = new OrientationConfiguration();
   oc.Coronal.Add(poCoronal);
   oc.Sagittal.Add(poSaggital);
   oc.Axial.Add(poAxial);
   if (!oc.IsValid())
   {
      MessageBox.Show("Invalid OrientationConfiguration");
      return;
   }

   // Find the image from the dataset with the new view perspective
   // RasterViewPerspective newViewPerspective = ds.GetNewViewPerspective(RasterViewPerspective.TopLeft, oc);
   RasterImage image = ds.GetImage(null, 0, 0, RasterByteOrder.Gray, DicomGetImageFlags.None, oc);

   // New view perspective should be BottomLeft
   RasterViewPerspective newViewPerspective = image.ViewPerspective;
   MessageBox.Show("newViewPerspective should be BottomLeft\nActual newViewPerspective is " + newViewPerspective.ToString());
}

Remarks

This method will load any image from ds, using element as the parent element to begin the search, where the element searched for is the Leadtools.Dicom.DicomTag.PixelData element. The resulting image has its Leadtools.RasterViewPerspective changed accordingly from applying a PlaneOrientation to a given Leadtools.RasterViewPerspective.

The input view perspective is define by two values: the original Leadtools.RasterViewPerspective contained in ds, and a row and column orientation vector (which are read from the ds by searching for the Leadtools.Dicom.DicomElement that has a tag of Leadtools.Dicom.DicomTag.ImageOrientationPatient which contains the orientation vectors.).

Note that the orientation contains three lists of conditions (one for each 3D axis) that can be applied to the image contained in the ds if the condition is met.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

Leadtools.Dicom.Common requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features