Error processing SSI file
LEADTOOLS Medical (Leadtools.Dicom assembly)

Show in webframe

GetImages(DicomElement,Int32,Int32,Int32,RasterByteOrder,DicomGetImageFlags,DicomGetImageCallback) Method








An item in the Data Set.
The zero-based index of the first frame to load.
Value that represents the number of frames to load.
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 Use the specified bits per pixel in the resulting image.
12 Use 12 bits per pixel in the resulting image.
16 Use 16 bits per pixel in the resulting image.
24 Use 24 bits per pixel in the resulting image.
32 Use 32 bits per pixel in the resulting image.
This value is ignored.
Flags that control the behavior of this method.
DicomGetImageCallback which will be called for each image that is loaded. This parameter cannot be null.
Gets the images of a Pixel Data element.
Syntax
'Declaration
 
Public Overloads Function GetImages( _
   ByVal element As DicomElement, _
   ByVal index As Integer, _
   ByVal count As Integer, _
   ByVal bitsPerPixel As Integer, _
   ByVal order As RasterByteOrder, _
   ByVal flags As DicomGetImageFlags, _
   ByVal callback As DicomGetImageCallback _
) As RasterImage
'Usage
 
Dim instance As DicomDataSet
Dim element As DicomElement
Dim index As Integer
Dim count As Integer
Dim bitsPerPixel As Integer
Dim order As RasterByteOrder
Dim flags As DicomGetImageFlags
Dim callback As DicomGetImageCallback
Dim value As RasterImage
 
value = instance.GetImages(element, index, count, bitsPerPixel, order, flags, callback)
 function Leadtools.Dicom.DicomDataSet.GetImages(DicomElement,Int32,Int32,Int32,RasterByteOrder,DicomGetImageFlags,DicomGetImageCallback)( 
   element ,
   index ,
   count ,
   bitsPerPixel ,
   order ,
   flags ,
   callback 
)

Parameters

element
An item in the Data Set.
index
The zero-based index of the first frame to load.
count
Value that represents the number of frames 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 Use the specified bits per pixel in the resulting image.
12 Use 12 bits per pixel in the resulting image.
16 Use 16 bits per pixel in the resulting image.
24 Use 24 bits per pixel in the resulting image.
32 Use 32 bits per pixel in the resulting image.
order
This value is ignored.
flags
Flags that control the behavior of this method.
callback
DicomGetImageCallback which will be called for each image that is loaded. This parameter cannot be null.

Return Value

The images of a Pixel Data element.
Remarks

For more details, see GetImages

Example

This example will read a DICOM dataset and get all the images from the pixel data element.

Copy Code  
Imports Leadtools
Imports Leadtools.Dicom

Private Function DicomTestGetImageCallback(index As Integer, count As Integer) As Boolean
   System.Diagnostics.Debug.WriteLine(String.Format("GetImage: {0} of {1}", index + 1, count))
   Return True
End Function
<TestMethod()> _
Public Sub TestDicomGetImages()
   Dim dicomFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.dcm")

   ' Make sure to initialize the DICOM engine, this needs to be done only once in the whole application
   DicomEngine.Startup()
   Dim ds As DicomDataSet = New DicomDataSet()
   Using (ds)
      'Load DICOM File
      ds.Load(dicomFileName, DicomDataSetLoadFlags.None)

      Dim pixelDataElement As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PixelData, True)
      If pixelDataElement Is Nothing Then
         MessageBox.Show("This dataset is missing the pixel data element", "Sample")
         Return
      End If

      If ds.GetImageCount(pixelDataElement) = 0 Then
         MessageBox.Show("This dataset has no images", "Sample")
         Return
      End If

      Dim imageInformation As DicomImageInformation = ds.GetImageInformation(pixelDataElement, 0)
      If imageInformation Is Nothing Then
         MessageBox.Show("Can't retrieve image information", "Sample")
         Return
      End If

      ' Get all the frames into a RasterImage object
      Dim image As RasterImage = ds.GetImages(pixelDataElement, 0, imageInformation.FrameCount, 0, RasterByteOrder.Gray, _
                                              DicomGetImageFlags.AllowRangeExpansion Or DicomGetImageFlags.AutoApplyModalityLut Or DicomGetImageFlags.AutoApplyVoiLut, _
                                              AddressOf DicomTestGetImageCallback)

      If image Is Nothing Then
         MessageBox.Show("Can't retrieve image", "Sample")
         Return
      End If

      System.Diagnostics.Debug.WriteLine(String.Format("Total Images: {0}", image.PageCount))
   End Using
   DicomEngine.Shutdown()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Dicom;

private bool DicomTestGetImageCallback(int index, int count)
{
   System.Diagnostics.Debug.WriteLine(string.Format("GetImage: {0} of {1}", index + 1, count));
   return true;
}
[TestMethod]
public void TestDicomGetImages()
{
   string dicomFileName = Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.dcm");

   //Make sure to initialize the DICOM engine, this needs to be done only once in the whole application
   DicomEngine.Startup();
   using (DicomDataSet ds = new DicomDataSet())
   {
      //Load DICOM File
      ds.Load(dicomFileName, DicomDataSetLoadFlags.None);

      DicomElement pixelDataElement = ds.FindFirstElement(null, DicomTag.PixelData, true);
      if (pixelDataElement == null)
      {
         MessageBox.Show("This dataset is missing the pixel data element", "Sample");
         return;
      }

      if (ds.GetImageCount(pixelDataElement) == 0)
      {
         MessageBox.Show("This dataset has no images", "Sample");
         return;
      }

      DicomImageInformation imageInformation = ds.GetImageInformation(pixelDataElement, 0);
      if (imageInformation == null)
      {
         MessageBox.Show("Can't retrieve image information", "Sample");
         return;
      }

      // Get all the frames into a RasterImage object
      RasterImage image = ds.GetImages(pixelDataElement, 0, imageInformation.FrameCount, 0, RasterByteOrder.Gray,
                                       DicomGetImageFlags.AllowRangeExpansion | DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut,
                                       DicomTestGetImageCallback);

      if (image == null)
      {
         MessageBox.Show("Can't retrieve image", "Sample");
         return;
      }

      System.Diagnostics.Debug.WriteLine(string.Format("Total Images: {0}", image.PageCount));

   }
   DicomEngine.Shutdown();
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
using Leadtools.Dicom.Constants;
using Leadtools;
using Leadtools.Dicom;

private bool DicomTestGetImageCallback(int index, int count)
{
   Debug.WriteLine(string.Format("GetImage: {0} of {1}", index + 1, count));
   return true;
}
[TestMethod]
public async Task TestDicomGetImages()
{

   //Make sure to initialize the DICOM engine, this needs to be done only once in the whole application
   DicomEngine.Startup();
   using (DicomDataSet ds = new DicomDataSet())
   {
      //Load DICOM File
      string filePath = @"Assets\IMAGE1.dcm";
      StorageFile file = await Tools.AppInstallFolder.GetFileAsync(filePath);
      ILeadStream stream = LeadStreamFactory.Create(file);
      bool success = await ds.LoadAsync(stream, DicomDataSetLoadFlags.None);
      Debug.Assert(success);

      DicomElement pixelDataElement = ds.FindFirstElement(null, DicomTagConstants.PixelData, true);
      if (pixelDataElement == null)
      {
         Debug.WriteLine("TestDicomGetImages: This dataset is missing the pixel data element");
         return;
      }

      if (ds.GetImageCount(pixelDataElement) == 0)
      {
         Debug.WriteLine("TestDicomGetImages: This dataset has no images");
         return;
      }

      DicomImageInformation imageInformation = ds.GetImageInformation(pixelDataElement, 0);
      if (imageInformation == null)
      {
         Debug.WriteLine("TestDicomGetImages: Can't retrieve image information");
         return;
      }

      // Get all the frames into a RasterImage object

      DicomGetImageCallback callback = new DicomGetImageCallback(DicomTestGetImageCallback);
      RasterImage image = ds.GetImages(pixelDataElement, 0, imageInformation.FrameCount, 0,
                                       DicomGetImageFlags.AllowRangeExpansion | DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut,
                                       DicomTestGetImageCallback);

      if (image == null)
      {
         Debug.WriteLine("TestDicomGetImages: Can't retrieve image");
         return;
      }

     Debug.WriteLine(string.Format("TestDicomGetImages: Total Images: {0}", image.PageCount));

   }
   DicomEngine.Shutdown();
}
Requirements

Target Platforms

See Also

Reference

DicomDataSet Class
DicomDataSet Members
Overload List
GetImageCount Method
GetImage(DicomElement,Int32,Int32,RasterByteOrder,DicomGetImageFlags) Method

Error processing SSI file
Leadtools.Dicom requires a Medical toolkit server license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features