L_DicomSetImage

#include "Ltdic.h"

L_UINT16 EXT_FUNCTION L_DicomSetImage(hDS, pElement, pBitmap, nCompression, nPhotometric, nBitsPerPixel, nQFactor, uFlags, pfnCallback, pUserData)

HDICOMDS hDS;

/* a DICOM handle */

pDICOMELEMENT pElement;

/* pointer to a DICOMELEMENT structure */

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT32 nCompression;

/* compression type */

L_INT32 nPhotometric;

/* photometric constant */

L_INT32 nBitsPerPixel;

/* resulting bitmap pixel depth */

L_INT32 nQFactor;

/* quality factor */

L_UINT uFlags;

/* flags. */

FILESAVECALLBACK pfnCallback;

/* optional callback function */

L_VOID *pUserData;

/* pointer to more parameters for the callback */

Replaces the image(s) in a Pixel Data element.

Parameter

Description

hDS

A DICOM handle.

pElement

Pointer to a DICOMELEMENT structure within the Data Set.

pBitmap

Pointer to the bitmap handle that references the image to set.

nCompression

Value that indicates the type of compression to use. Possible values are:

 

Value

Meaning

 

IMAGE_COMPRESSION_NONE

[0x00] No compression.

 

IMAGE_COMPRESSION_RLE

[0x01] RLE compression.

 

IMAGE_COMPRESSION_JPEG_LOSSLESS

[0x02] JPEG LossLess compression.

 

IMAGE_COMPRESSION_JPEG_LOSSY

[0x03] JPEG Lossy compression.

 

IMAGE_COMPRESSION_J2K_LOSSLESS

[0x06] JPEG 2000 lossless compression.

 

IMAGE_COMPRESSION_J2K_LOSSY

[0x07] JPEG 2000 Lossy compression.

nPhotometric

Photometric constant. Possible values are:

 

Value

Meaning

 

IMAGE_PHOTOMETRIC_MONOCHROME2

[0x01] 8- or 16-bits per pixel, grayscale image.

 

IMAGE_PHOTOMETRIC_PALETTE_COLOR

[0x02] 8-bits per pixel, palettized color image.

 

IMAGE_PHOTOMETRIC_RGB

[0x03] 24-bits per pixel, RGB color image.

 

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

nQFactor

The quality factor (Q factor) is a number that determines the degree of loss in the compression process. You can set a value from 2 to 255, where 2 is the highest quality and 255 is the most compression.

uFlags

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

 

Value

Meaning

 

DICOM_SETIMAGE_AUTO_SAVE_OVERLAYS

[0x0001]If set, the function will automatically insert the overlays associated with the input bitmap into the dataset.

 

DICOM_SETIMAGE_AUTO_SET_VOI_LUT

[0x0002]If set, the function will automatically add a VOI LUT to the dataset.

 

DICOM_SETIMAGE_MINIMIZE_JPEG_SIZE

[0x0004] If set, and the nCompression parameter is IMAGE_COMPRESSION_JPEG_LOSSLESS or IMAGE_COMPRESSION_JPEG_LOSSY, the JPEG compression engine will use optimized Huffman tables, which results in better compression, but slower speed.

pfnCallback

Optional callback function for additional processing.

 

image\sqrblit.gif If you do not provide a callback function, use NULL as the value of this parameter.

 

image\sqrblit.gif If you do provide a callback function, use the function pointer as the value of this parameter.

 

The callback function must adhere to the function prototype described in FILESAVECALLBACK Function.

pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

 

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

 

If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

0

SUCCESS

>0

An error occurred. Refer to Return Codes.

Comments

This function replaces all the images in the Pixel Data Element with the image referenced by pBitmap.

Most DICOM files will only have one Data Element of type TAG_PIXEL_DATA. Therefore, in most instances you can set pElement to NULL, since the function will automatically replace the images of the only Pixel Data Element in the file. If pElement is not NULL, it must point to the Pixel Data Element itself.

If the DICOM file is CLASS_BASIC_DIRECTORY, the file may contain more than one Pixel Data Element. In this case you must specify in pElement the Pixel Data Element in which the images will be replaced.

If you wish to replace only one image within the Pixel Data Element, you must use L_DicomDeleteImage and L_DicomInsertImage.

For a table of possible Compression, Photometric, BitsPerPixel, and Quality Factor combinations, refer to Compression Table.

For more options when using the JPEG 2000 compression, refer to L_DicomSetJ2KOptions.

This function will either insert, delete or update one or more of the following elements:

Tag

Name

(7FE0,0010)

Pixel Data

(0002,0010)

Transfer Syntax UID

(0028,0101)

Bits Stored

(0028,0100)

Bits Allocated

(0028,0102)

High Bit

(0028,0103)

Pixel Representation

(0028,0010)

Rows

(0028,0011)

Columns

(0028,0002)

Samples per Pixel

(0028,0006)

Planar Configuration

(0028,0004)

Photometric Interpretation

(0028,0106)

Smallest Image Pixel Value

(0028,0107)

Largest Image Pixel Value

(0028,1101)

Red Palette Color Lookup Table Descriptor

(0028,1102)

Green Palette Color Lookup Table Descriptor

(0028,1103)

Blue Palette Color Lookup Table Descriptor

(0028,1201)

Red Palette Color Lookup Table Data

(0028,1202)

Green Palette Color Lookup Table Data

(0028,1203)

Blue Palette Color Lookup Table Data

(0028,1199)

Palette Color Lookup Table UID

(0028,1052)

Rescale Intercept

(0028,1053)

Rescale Slope

(0028,1054)

Rescale Type

(0028,1221)

Segmented Red Palette Color Lookup Table Data

(0028,1222)

Segmented Green Palette Color Lookup Table Data

(0028,1223)

Segmented Blue Palette Color Lookup Table Data

(0028,3010)

VOI LUT Sequence

(0028,1050)

Window Center

(0028,1051)

Window Width

(0028,1055)

Window Center & Width Explanation

(0028,0008)

Number of Frames

(0054,0070)

Time Slot Vector

This function is indifferent to the pixel data restrictions imposed by the various DICOM IOD classes, for example this function will allow the user to insert a colored image into a "Digital X-Ray Image Storage" dataset.

This function will always insert a "Number of Frames" (0028, 0008) element and set its value.

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

See Also

Functions:

L_DicomGetImage, L_DicomGetImageList, L_DicomInsertImage, L_DicomInsertImageList, L_DicomSetImageList

Topics:

Working with Data Sets

Example

/* This example sets an image in Data Set */

L_VOID Test(pBITMAPHANDLE pBitmap)
{
   HDICOMDS      hDS;
   pDICOMELEMENT pElement;

   hDS = L_DicomCreateDS(NULL);

   
L_DicomLoadDS(hDS, "c:\\ltwin13\\images\\image1.dic", 0);

   pElement = L_DicomFindFirstElement(hDS, NULL, TAG_PIXEL_DATA, FALSE);
   if (pElement != NULL)
   {
      L_DicomSetImage(hDS, pElement, pBitmap, IMAGE_COMPRESSION_NONE,
                      IMAGE_PHOTOMETRIC_MONOCHROME1, 0, 0, DICOM_SETIMAGE_AUTO_SET_VOI_LUT, NULL, NULL);
   }

   L_DicomFreeDS(hDS);
}