LDicomDS::SetWindow

#include "ltdic.h"

L_UINT16 LDicomDS::SetWindow(uFrameIndex, uWindowIndex, pWindowAttributes, uFlags)

Sets the attributes that describe the window center and the window width.

Parameters

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

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 Sequencealready 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 Sequencealready exists under the Per-frame Functional Groups Sequence, this flag is ignored.|

Returns

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

Comments

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 isnert 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

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).

L_INT LDicomDS_SetWindowExample(LDicomDS    &InDS, 
                                    L_UINT      uBitsStored, 
                                    L_BOOL      bAdd/*Add a new window or replace the existing one(s)*/  
                                    ) 
{ 
   L_INT                nRet; 
   DICOMWINDOWATTRIBS   WindowAttributes ={0}; 
   L_UINT               uWindowCount=0;  
   L_UINT               uWindowIndex=0;  
 
   WindowAttributes.uStructSize = sizeof(DICOMWINDOWATTRIBS); 
 
   nRet = InDS.GetWindowCount (0, &uWindowCount);  
 
   if(nRet != DICOM_SUCCESS)  
 
   { 
 
      return nRet; 
 
   } 
 
   if(uWindowCount > 0) 
 
   { 
 
      nRet = InDS.GetWindow (0, 0,&WindowAttributes, sizeof(DICOMWINDOWATTRIBS),0);  
 
      if(nRet != DICOM_SUCCESS)  
 
      { 
 
         return nRet; 
 
      } 
 
      // 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)  
 
      nRet = InDS.DeleteWindow (0, 0);  
 
      if(nRet != DICOM_SUCCESS)  
 
      { 
 
         return nRet; 
 
      } 
 
      uWindowIndex = 0;  
 
   } 
 
   // Add the new window 
 
   return InDS.SetWindow (0, uWindowIndex,&WindowAttributes,0); 
 
} 

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

LEADTOOLS DICOM C++ Class Library Help