L_DicomSetWindow

Summary

Sets the attributes that describe window center and window width.

Syntax

#include "ltdic.h"

L_LTDIC_API L_UINT16 L_DicomSetWindow(hDS, uFrameIndex, uWindowIndex, pWindowAttributes, uFlags)

Parameters

HDICOMDS hDS

A DICOM handle.

L_UINT32 uFrameIndex

A zero-based index that identifies the frame number in the dataset. If the dataset does not support Multi-frames, this parameter is ignored.

L_UINT uWindowIndex

Index to the window center , window width value to be updated. According to the DICOM standard if multiple values are present for the window center and window width, both attributes shall have the same number of values and shall be considered as pairs. This index is zero-based.

pDICOMWINDOWATTRIBS pWindowAttributes

Pointer to a structure containing the window-related attributes to set.

L_UINT uFlags

Possible values are:

Value Meaning
0 Default
[0x008] DICOM_SETIMAGE_MFG_OVERWRITE_SHARED If set, existing Frame VOI LUT Sequence items under the Shared Functional Groups Sequence will be overwritten. If this flag is not included, Shared Functional Groups Sequence elements are unchanged.
[0x0010] DICOM_SETIMAGE_MFG_VOI_LUT_PER_FRAME If the Frame VOI LUT Sequence does not already exist, it is added under the Per-frame Functional Groups Sequence. If the Frame VOI LUT Sequence already exists under the Shared Functional Groups Sequence, this flag is ignored.
[0x0020] DICOM_SETIMAGE_MFG_VOI_LUT_SHARED If the Frame VOI LUT Sequence does not already exist, it is added under the Shared Functional Groups Sequence. If the Frame VOI LUT Sequence already exists under the Per-frame Functional Groups Sequence, this flag is ignored.

Returns

Value Meaning
DICOM_SUCCESS The function was successful.
>0 An error occurred. Refer to Return Codes.

Comments

This function will set the attributes that describe window center and window width.

Before calling this function, initialize pWindowAttributes->uStructSize to be sizeof (DICOMWINDOWATTRIBS) and initialize all the members of the structure.

If "Window Center" (0028,1050) does not already exist in the dataset this function will insert it and set its value to pWindowAttributes->fWindowCenter.

If "Window Width" (0028,1051) does not already exist in the dataset this function will insert it and set its value to pWindowAttributes->fWindowWidth.

The Multi-frame Functional Groups module may have a Shared Functional Groups Sequence item, and/or a Per-frame Functional Groups Sequence item. Either of these items may have a Frame VOI LUT Sequence (0028,9132) item. The uFlags parameter can be used to add or modify existing information in the Frame VOI LUT Sequence.

The following flags are used only if the Frame VOI LUT Sequence does not already exist.

In this case, the sequence is placed in the sequence indicated by the flag (Per-frame Functional Groups Sequence or Shared Functional Groups Sequence).

If a Frame VOI LUT Sequence already exists in a DICOM dataset, uFlags is ignored and the sequence is placed in the location where sequences already exist.

The specific elements that are read or updated when using these flags are 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

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

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example will add a new "Window Width" and
"Window Center" to the dataset , or replace
the existing one(s)

#define SET_SIZE(p) (p)->uStructSize = sizeof(*(p)); 
 
L_INT DicomSetWindowExample(HDICOMDS hDicomDS, L_UINT uBitsStored, L_BOOL bAdd) 
{ 
   DICOMWINDOWATTRIBS   WindowAttributes ={0}; 
   L_UINT16             uRet; 
   L_UINT               uWindowCount=0; 
   L_UINT               uWindowIndex=0; 
 
   SET_SIZE(&WindowAttributes); 
   uRet = L_DicomGetWindowCount(hDicomDS, 0, &uWindowCount); 
   if(uRet != DICOM_SUCCESS) 
      return uRet; 
 
   if(uWindowCount>0) 
   { 
      uRet = L_DicomGetWindow(hDicomDS, 0, 0,&WindowAttributes, sizeof(DICOMWINDOWATTRIBS),0); 
      if(uRet != DICOM_SUCCESS) 
         return uRet; 
 
      // Half the width for the first window 
      WindowAttributes.fWindowWidth    = WindowAttributes.fWindowWidth  /2; 
      WindowAttributes.fWindowCenter   = WindowAttributes.fWindowCenter /2; 
   } 
   else 
   { 
      // This represents an identity VOI LUT transformation in the case  
      // where no Modality LUT is specified and the stored pixel data are  
      // uBitsStored bit unsigned integers. 
      WindowAttributes.fWindowWidth    = 1 << uBitsStored      ; 
      WindowAttributes.fWindowCenter   = 1 << (uBitsStored-1)  ; 
   } 
 
   uWindowIndex = uWindowCount; 
   if(!bAdd) 
   { 
      // Delete the existing window(s) 
      uRet = L_DicomDeleteWindow(hDicomDS, 0, 0); 
      if(uRet != DICOM_SUCCESS) 
         return uRet; 
      uWindowIndex = 0; 
   } 
 
   // Add the new window 
   return L_DicomSetWindow(hDicomDS, 0, uWindowIndex, &WindowAttributes, 0); 
} 

Help Version 23.0.2024.7.1
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.