;+ ; NAME: ; qView_GetImage ; PURPOSE: ; Part of qView package; used in event processing ; Extracts a data array from the user value of state.getdata ; CATEGORY: ; CALLING SEQUENCE: FUNCTION qView_GetImage, state, sz=sz, step=step, all=all, id=id, $ fromactive=fromactive, minmax=minmax ; INPUTS: ; state scalar, structure ; contains IDs for all qView widgets ; OPTIONAL INPUT PARAMETERS: ; id = id scalar, type integer, valid values: 0,1,2,3, default: 0 ; Defines the area (range of pixels in x and y direction) to be ; extracted from the data array. ; id=0: extracts whole image area (data[*,*,i]) ; id=1: extracts range defined by box[*,1] ??Is this used at all??? ; id=2: ; id=3: ; step=step scalar, type integer, valid values: -1,0,1, default: 0 ; /all scalar, type integer, default: not set ; /fromactive scalar, type integer, default: not set ; OUTPUTS: ; sz=sz scalar, type: long integer ; # images currently in memory (in user value of state.getdata) ; minmax=minmax 2-element array, type: same as user value of state.getdata ; minimum and maximum of image set currently in memory ; OPTIONAL OUTPUT PARAMETERS: ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; COMMON BLOCKS: ; SIDE EFFECTS: ; RESTRICTIONS: ; PROCEDURE: ; The user value of state.getdata contains a data array representing a ; 2D (single) image or a 3D image cube. ; ; User value of state.activeimg: ; ; If the user value of state.activeimg is positive then the data array is a single full ; image as read by qView_ReadFile. The user value is the file number ; of image read into the data array. ; ; If the user value of state.activeimg is -1 then the data array is a 3D cube of images ; as read by qView_GetData (note that the 3rd dimension may be degenerate if ; only one image was read into the cube). ; ; MODIFICATION HISTORY: ; JAN-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- InitVar, id , 0 InitVar, step, 0 ; Should be -1,0 or 1 InitVar, all , /key InitVar, fromactive, /key ; frst, last and incr define the selection of files (image files frst to last in ; steps of incr). If set=-1 then all files have been read (only the part ; defined by box[*,1] is kept in memory. If set>=0 then only a single file has ; been read and a single complete image is in memory. The value of set refers ; to one of the files in the file selection (what if set=0???). widget_control, state.frstfile , get_value=frst widget_control, state.lastfile , get_value=last widget_control, state.incrfile , get_value=incr widget_control, state.activeimg, get_value=active, get_uvalue=set all *= set LT 0 fromactive *= set LT 0 active = active+step*incr ; Step to next or previous image if active GT last then active = frst if active LT frst then active = last ; set = -1 if an image cube is in memory ; set = image # of single image stored in 'data'. nfiles = 1+(last-frst)/incr files = frst+lindgen(nfiles)*incr ; List of selected files i = min(abs(files-active), active) ; Pick file closest to active widget_control, state.activeimg, set_value=files[active] ; Update activeimg field in widget active *= set LT 0 ; Index into 'data' array widget_control, state.box[0,0], get_uvalue=box widget_control, state.getdata, get_uvalue=data, /no_copy ; Get data array ;zmin = min(data,max=zmax) & minmax = [zmin,zmax] ; 'minmax' is keyword widget_control, state.box[2,0], get_uvalue=minmax s = size(data) IF s[0] EQ 3 THEN sz = s[3] ELSE sz = 1 ; 'sz' is keyword: # images in 'data' array ; The 'data' array is a 3D array array containing a set of 2D images (or 2D ; array with a single 2D image) ; id=0: extracts a whole image from 'data' ; id=1: uses box[*,1] to extract a part of an image from 'data' ; used by 'get_data' to extract a part from images read from file ; id=2: uses box[*,2] to extract a part of an image from 'data' ; id=3: uses box[*,3] to extract a part of an image from 'data' CASE id OF 0: BEGIN xb = 0 & xe = s[1]-1 yb = 0 & ye = s[2]-1 END 1: BEGIN message, 'oops xb = box[0,1] & xe = box[1,1] yb = box[2,1] & ye = box[3,1] END ELSE: BEGIN ; Part of image from 'data' xb = box[0,id]-box[0,1] & xe = box[1,id]-box[0,1] yb = box[2,id]-box[2,1] & ye = box[3,id]-box[2,1] END ENDCASE xb0 = box[0,3]-box[0,1] & xe0 = box[1,3]-box[0,1] ; Box used to define base yb0 = box[2,3]-box[2,1] & ye0 = box[3,3]-box[2,1] ;message, /info, 'qView_GetImage ;help, xb,xe,yb,ye,active,data CASE 1 OF all : img = data[xb:xe,yb:ye,*] fromactive: img = data[xb:xe,yb:ye,active:*] ELSE : img = data[xb:xe,yb:ye,active] ENDCASE ;img = qView_SubtractBase(img) widget_control, state.getdata, set_uvalue=data, /no_copy RETURN, img & END