L_DicomGetImageList

#include "Ltdic.h"

L_LTDIC_API L_UINT16 L_DicomGetImageList(hDS, pElement, hList, nIndex, nCount, nBitsPerPixel, nOrder, uFlags)

HDICOMDS hDS;

/* a DICOM handle */

pDICOMELEMENT pElement;

/* pointer to a DICOMELEMENT structure */

HBITMAPLIST hList;

/* handle to the list of bitmaps */

L_UINT32 nIndex;

/* index value */

L_UINT32 nCount;

/* number of frames to load */

L_INT32 nBitsPerPixel;

/* resulting bitmap pixel depth */

L_INT32 nOrder;

/* desired color order */

L_UINT uFlags;

/* flags */

Loads the bitmap list with frames from a Pixel Data element.

Parameter

Description

hDS

A DICOM handle.

pElement

Pointer to a DICOMELEMENT structure within the Data Set.

hList

Handle to the list of bitmaps.

nIndex

Position of the first frame to get. Use zero-based indexing. For example, if there are 10 bitmaps in a list, the index of the last one is 9. To get

nCount

Number of frames to load into the bitmap list.

nBitsPerPixel

Resulting bitmap 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 resultant bitmap

 

12

12 bits per pixel in the resultant bitmap.

 

16

16 bits per pixel in the resultant bitmap

 

24

24 bits per pixel in the resultant bitmap

 

32

32 bits per pixel in the resultant bitmap

nOrder

The desired color order. Possible values are:

 

Value

Meaning

 

ORDER_RGB

[0] Red-green-blue order.

 

ORDER_BGR

[1] Blue-green-red order.

 

ORDER_GRAY

[2] 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in the Document/Medical editions.

 

ORDER_RGBORGRAY

[3] Load the image as red, green, blue OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical editions only.

 

ORDER_BGRORGRAY

[4] Load the image as blue, green, red OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical editions only.

 

0

The data is 8 bits per pixel or less.

uFlags

Flags which control the behavior of this function. Possible values are:

 

Value

Meaning

 

DICOM_GETIMAGE_AUTO_LOAD_OVERLAYS

[0x0001] If set, the function will automatically extract the overlays included in the dataset and add them to the loaded bitmap.

 

DICOM_GETIMAGE_AUTO_APPLY_MODALITY_LUT

[0x0002] If set, the function will automatically apply the "Modality LUT" when loading the bitmap.

 

DICOM_GETIMAGE_AUTO_APPLY_VOI_LUT

[0x0004] If set, the function will automatically apply the "VOI LUT" when loading the bitmap.

 

DICOM_GETIMAGE_ALLOW_RANGE_EXPANSION

[0x0008] (Deprecated, do not use) If set, the function will adjust the high bit and/or low bit (if possible) inside the bitmap handle in order to hold the range of pixel values after applying the modality LUT.

 

DICOM_GETIMAGE_AUTO_SCALE_MODALITY_LUT

[0x0010] If set, the function will scale the resulting pixel data to fit within the range of 0 to 2^BitsPerPixel-1 if any of the values would exceed that range.

 

DICOM_GETIMAGE_AUTO_SCALE_VOI_LUT

[0x0020] Only used in conjuction with DICOM_GETIMAGE_AUTO_SCALE_MODALITY_LUT. If set, the function will rescale the VOI LUT to match the rescale that was performed by DICOM_GETIMAGE_AUTO_SCALE_MODALITY_LUT.

Returns

0

SUCCESS

>0

An error occurred. Refer to Return Codes.

Comments

As an example, if you wish to load 50 images starting with the 50th frame in the Pixel Data, call this function with nIndex set to 49 (the 50th frame in a zero-based index) and nCount set to 50.

If pElement is NULL, you can retrieve a bitmap list of all images within the Data Set. To do this you must call L_DicomGetCountImage with pElement set to NULL to determine the number of images in the Data Set and set the nCount parameter in L_DicomGetImageList to this value.

If DICOM_GETIMAGE_ALLOW_RANGE_EXPANSION is set in uFlags, consider the following example:

If the dataset has the following attributes:

Bits allocated

16

Bits stored

12

Pixel Range

0 - +4095

Pixel Representation is unsigned (0)

 

Photometric Interpretation is MONOCHROME2

 

Rescale Slope

1

Rescale Intercept

-1024

After applying the rescale slope and the intercept:

Output minimum pixel value = (0 * 1 +(-1024)) = -1024

Output maximum pixel value = (4095 * 1 + (-1024)) = 3071

The new pixel value range (1024 to 3071) cant be represented with the current bits stored (12 bits), which can represent values in the range (2048 to 2048). In this case the function will change the high bit inside the bitmap handle to be 12 instead of 11 (bits stored becomes 13), which can represent values in the range (8192 to 8191).

Please note that the function wont be able to update the high bit and/or low bit if the number of bits stored was already equal to the number of bits allocated.

If the DICOM dataset has a Multi-frame Functional Groups module, some VOI LUT information will be read from the correspondingFrame VOI LUT Sequence, and some Modality LUT information will be read from the corresponding Pixel Value Transformation Sequence.

The specific elements that are read is shown below:

(0028,9132) Frame VOI LUT Sequence Child Elements

Tag

Name

(0028,1050)

Window Center

(0028,1051)

Window Width

(0028,1055)

Window Center & Width Explanation

(0028,9145) Pixel Value Transformation Sequence child elements

Tag

Name

(0028,1052)

Rescale Intercept

(0028,1053)

Rescale Slope

(0028,1054)

Rescale Type

For a detailed discussion on Multi-frame Functional Groups and how the DICOM_SET_IMAGE_MFG flags are used, see the topic Multi-frame Functional Groups.

Required DLLs and Libraries

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

Platforms

Win32, x64

See Also

Functions:

L_DicomGetCountImage, L_DicomGetImage

Topics:

Working with Data Sets

Example

This example fills a bitmap list with all images from the Data Set

L_INT DicomGetImageListExample(L_VOID)
{
   HDICOMDS    hDS;
   HBITMAPLIST hList;
   L_UINT16 nRet;

   hDS = L_DicomCreateDS(NULL);

   nRet = L_DicomLoadDS(hDS, TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Image1.dcm"), 0);
   if (nRet != DICOM_SUCCESS)
   {
      L_DicomFreeDS(hDS);
      return nRet;
   }

   nRet = (L_UINT16) L_CreateBitmapList(&hList);
   if (nRet != SUCCESS)
   {
      L_DicomFreeDS(hDS);
      return nRet;
   }

   nRet = L_DicomGetImageList(hDS, NULL, hList, 0, ELEMENT_INDEX_MAX, 0, ORDER_BGR, 0);
   if (nRet != DICOM_SUCCESS)
   {
      L_DicomFreeDS(hDS);
      return nRet;
   }

   nRet = (L_UINT16) L_DestroyBitmapList(hList);
   if (nRet != SUCCESS)
   {
      L_DicomFreeDS(hDS);
      return nRet;
   }

   L_DicomFreeDS(hDS);
   return DICOM_SUCCESS;
}