IDLffDICOM::GetValue
This method takes optional DICOM group and/or element arguments and returns an array of POINTERs to the values of the elements matching those parameters.
Syntax
Result = Obj->[IDLffDICOM::]GetValue([Group [, Element]] [, REFERENCE=list of element references] [, /NO_COPY])
Return Value
Returns an array of pointers to the values of the elements matching the Group and Element parameters. If no arguments or keywords are specified, the returned array contains pointers to all elements in the object. The effect of multiple keywords and parameters is to AND their results. If no matching elements can be found, the function returns -1.
Arguments
Group
Set this optional argument to the value for the DICOM group for which to search, such as ‘0018’x. If this argument is omitted, then all of the DICOM array elements are returned.
Element
This optional argument can be specified only if the Group argument has also been specified. Set this to the value for the DICOM element for which to search, such as ‘0010’x. If this argument is omitted and the Group argument was specified, then all elements of the specified Group are returned.
Keywords
REFERENCE
Set this keyword to a list of element references from which to return pointer values.
NO_COPY
If this keyword is set, the pointers returned point to the actual data in the object for the specified DICOM fields. If not set (the default), the pointers point to copies of the data instead, and need to be freed by using PTR_FREE.
Examples
Example 1
obj = OBJ_NEW('IDLffDICOM')
read = obj->Read(DIALOG_PICKFILE(FILTER='*'))
; Get the image data
array = obj->GetValue('7fe0'x, '0010'x)
OBJ_DESTROY, obj
TVScl, *array[0]
PTR_FREE, array
Example 2
This example is broken into sections; click on each section to run the complete example:
PRO ex_idlffdicom_getvalue
obj = OBJ_NEW('IDLffDICOM')
read = obj->Read(DIALOG_PICKFILE(FILTER='*'))
; Get all of the image data element(s), 7fe0,0010, from the file:
array = obj->GetValue('7fe0'x,'0010'x,/NO_COPY)
; Get the row & column size of the image(s):
rows = obj->GetValue('0028'x,'0010'x,/NO_COPY)
cols = obj->GetValue('0028'x,'0011'x,/NO_COPY)
; If the image has a samples per pixel value greater than 1
; it is most likely a color image, get the samples per pixel:
isColor = 0
samples = obj->GetValue('0028'x,'0002'x,/NO_COPY)
IF (SIZE(samples,/N_DIMENSIONS) NE 0) THEN BEGIN
IF (*samples[0] GT 1) THEN isColor = 1
ENDIF
; Next, we need to differentiate between files with color data
; that is either color-by-plane or color-by-pixel, get the planar
; configuration:
IF (isColor EQ 1) THEN BEGIN
isPlanar = 0
planar = obj->GetValue('0028'x,'0006'x, /NO_COPY)
IF (SIZE(planar, /N_DIMENSIONS) NE 0) THEN BEGIN
IF (*planar[0] EQ 1) THEN isPlanar = 1
ENDIF
ENDIF
; Display the first NumWin images from the file:
IF N_ELEMENTS(array) GT 10 THEN NumWin = 10 $
ELSE NumWin = N_ELEMENTS(array)
offset = 0
FOR index = 0, NumWin-1 DO BEGIN
; Create window for each image that is the size of the image:
WINDOW,index,XSize=*cols[0],YSize=*rows[0],XPos=offset,YPos=0
WSET,index
; Display the image data
IF (isColor EQ 1) THEN $
IF (isPlanar EQ 1) THEN $
; color-by-plane
TVScl,TRANSPOSE(*array[index],[2,0,1]),/TRUE $
ELSE $
; color-by-pixel
TVScl,*array[index],/TRUE $
ELSE $
; monochrome
TVScl,*array[index]
offset = offset+10
ENDFOR
; Clean up
OBJ_DESTROY,obj
END
Version History
5.2 |
Introduced |