Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


Harris Geospatial / Docs Center / IDL Reference / DICOM Toolkit / IDLffDicomEx::ChangeTransferSyntax

IDLffDicomEx::ChangeTransferSyntax

IDLffDicomEx::ChangeTransferSyntax

The IDLffDicomEx::ChangeTransferSyntax procedure method changes the transfer syntax of the IDLffDicomEx object and its associated pixel data. This allows you to change the compression setting of the pixel data and ensure that the transfer syntax value and pixel data are synchronized. Directly changing the transfer syntax (0002,0010) is not advised.

Note: There is no support for the JPEG compression algorithms on Macintosh.

Note: Attempting to change an existing file from a lossy JPEG format to another format will fail. This is prohibited to ensure that a file saved in a lossy format is always known to be less than the original data.

Note: When this method successfully completes the equivalent of an IDLffDicomEx::Commit call will have occurred (the file is saved to disk) to ensure the pixel data and the transfer syntax are synchronized. This means any sequence identifiers for the object are invalid and must be re-accessed using the IDLffDicomEx::GetPrivateValue or IDLffDicomEx::GetValue method.

  1. The original syntax is uncompressed and the new syntax is uncompressed. After calling this method, the pixel data remains unchanged, but the transfer syntax is changed.
  2. The original syntax is compressed (lossless only) and the new syntax is uncompressed. After calling this method, the pixel data is retrieved and uncompressed, the transfer syntax is changed, the pixel data is written back into the image in the uncompressed format.
  3. The original syntax is uncompressed and the new syntax is compressed (lossless or lossy). After calling this method, the pixel data is retrieved from the image, the transfer syntax is changed, the pixel data is written back into the image in the compressed format.
  4. The original syntax is compressed (lossless only) and the new syntax is compressed (lossless or lossy). After calling this method, the pixel data is uncompressed, the transfer syntax is changed, the pixel data is written back into the image in the compressed format.
  5. The original transfer syntax is the same as the new syntax. Calling this method saves the file.

Bit Depth Versus Image Compression

The following table provides information on the types of JPEG compression support for images with various bit depths. Not all JPEG formats can be used on all image types. Refer to Digital Imaging and Communications in Medicine (DICOM) - Part 5: Data Structures and Encoding for additional details.

JPEG Format

8 bit

12 bit

16 bit

JPEG Baseline (lossy)

Yes

No

No

JPEG Extended (Process 2 & 4)(lossy)

Yes

Yes

No

JPEG Lossless, Non-Hierarchical

Yes

Yes

Yes

JPEG 2000 Image Compression (Lossless Only)

Yes

Yes

Yes

JPEG 2000 Image Compression

Yes

Yes

Yes

Syntax


Obj->[IDLffDicomEx::]ChangeTransferSyntax, NewSyntaxUID [, /LOSSY]

Arguments


NewSyntaxUID

A string that specifies the new transfer syntax for the file. This argument must be one of the values listed in the following table:

Argument Value

Transfer Syntax Name

1.2.840.10008.1.2

Implicit VR Little Endian

1.2.840.10008.1.2.1

Explicit VR Little Endian

1.2.840.10008.1.2.2

Explicit VR Big Endian

1.2.840.10008.1.2.4.50

JPEG Baseline (lossy)

1.2.840.10008.1.2.4.51

JPEG Extended (Process 2 & 4)(lossy)

1.2.840.10008.1.2.4.70

JPEG Lossless, Non-Hierarchical

1.2.840.10008.1.2.4.90

JPEG 2000 Image Compression (Lossless Only)

1.2.840.10008.1.2.4.91

JPEG 2000 Image Compression

Keywords


LOSSY

Set this keyword to control how tags that can indicate lossy compression are updated. The default behavior when the NewSyntaxUID argument is set to a lossy transfer syntax is to update the two tags as indicated in the following table. This occurs when the LOSSY keyword is not set. If this keyword is set the indicated tags remain unchanged. See Digital Imaging and Communications in Medicine (DICOM) - Part 3, Section C.7.6.1.1.5 for additional details on what other tags you can update when the compression format is lossy.

DICOM Attribute

Indication of Lossy Compression

Image Type (0008,0008)

The first value in this multi-value tag is updated to read as 'DERIVED'.

Note: If the Image Type tag is not present it is added.

Lossy Compression (0028,2110)

This tag is updated to read '01' indicating the image has undergone lossy compression. This value should never be changed once set to 01.

Example


The following example changes the file compression of a selected file to a lossy format. Use the BITS_STORED property to query the bit depth of the image as not all images support all types of compression. Do not set the LOSSY keyword so the Image Type attribute is modified to state that the image is derived. Following compression, the original and compressed images are shown in a window.

Note: This example is not designed for images with more than a single sample per pixel (e.g. RGB images).

Note: To avoid an error, you must delete the aImgClone.dcm file prior to running this example more than a single time. The ChangeTransferSyntax method internally calls the IDLffDicomEx::Commit method and writes the file to disk.

PRO dicom_changecompression_doc
 
; Select a DICOM file.
sFile = DIALOG_PICKFILE( $
    PATH=FILEPATH('',SUBDIRECTORY=['examples','data']), $
    TITLE='Select DICOM Patient File', FILTER='*.dcm', $
    GET_PATH=path)
 
; Create a clone (aImgClone.dcm) of the selected file (sfile).
; Set the NON_CONFORMING keyword to be able to add a public SQ  
; of radiopharmaceutical items to any file. 
 oImg = OBJ_NEW('IDLffDicomEx', path + 'aImgClone.dcm', $
    CLONE=sfile, /NON_CONFORMING)
 
; Get the value of the Image Type attribute prior to 
; changing the transfer syntax.
oImg->GetProperty, IMAGE_TYPE = vImgType, $
   ROWS=vRows, COLUMNS=vCols
PRINT, 'Image Type Property = ', vImgType
 
; Check to see if the image has multiple frames.
frameTest = oImg->QueryValue('0028,0008')
IF FrameTest EQ 2 THEN BEGIN
   oImg->GetProperty, NUMBER_OF_FRAMES=frame
   frame = frame - 1
ENDIF ELSE BEGIN
   frame = 0
ENDELSE
order = 0
 
; Get the current transfer syntax. 
oImg->GetProperty, TRANSFER_SYNTAX = vSyntax, $
  BITS_STORED = vBits
PRINT, 'Old Syntax ', vSyntax
 
; Get the pixel data before compression.
vPixOrig = oImg->GetPixelData(ORDER=vOrder, COUNT=vCnt)
 
; Change the compression of the file to a lossy type based on
; bit-depth of the image. Note that internally, the
; ChangeTransferSyntax calls commit and writes file to disk. 
If vBits EQ 8 THEN $
  oImg->ChangeTransferSyntax, '1.2.840.10008.1.2.4.50'
 
IF vBits NE 8 THEN BEGIN
  ; If vBits not equal to 8 then compress the file using
  ; JPEG 2000 lossy compression.
  oImg->ChangeTransferSyntax, '1.2.840.10008.1.2.4.91'
ENDIF
 
oImg->GetProperty, TRANSFER_SYNTAX = vSyntax, $
   IMAGE_TYPE = vImgType
 
PRINT, 'New Syntax ', vSyntax
PRINT, 'New Image Type Property = ', vImgType
 
; Retrieve the compress pixel data. 
vPixLossy = oImg->GetPixelData()
 
; Display the original and lossy compressed data.
WINDOW, XSIZE = vCols*2, YSIZE = vRows, $
   TITLE = "Original and Compressed Frames"
FOR i = 1, frame+1 DO BEGIN
   TVSCL, vPixOrig[*,*,i-1], 0, ORDER = order
   TVSCL, vPixLossy[*,*,i-1], 1, ORDER = order
   WAIT, 1
ENDFOR
 
; Clean up references.
OBJ_DESTROY, oImg
 
END

Version History


6.1

Introduced



© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us