;+ ; NAME: ; qImage_cw_ZWedge ; PURPOSE: ; Calculates the Z-values min, max, average and standard deviations ; for a wedge in the image plane ; CATEGORY: ; Compound widget qImage_cw ; CALLING SEQUENCE: FUNCTION qImage_cw_ZWedge, state, p_box , $ exclude_p_box = exclude_p_box , $ noupdate = noupdate , $ zval = zval , $ wedge = wedge , $ centroid = centroid , $ image = image , $ img_center = img_center , $ img_prorate = img_prorate ; INPUTS: ; state array[1]; type: structure ; qImage_cw state structure ; OPTIONAL INPUT PARAMETERS: ; p_box array[2,2]; type:float ; limiting values in phase angle and radius of the wedge ; in the form [[angle1,radius1],[angle2,radius2]]. ; Angle1 and angle2 are in radians between [-!pi,+!pi]. ; The wedge runs counterclockwise from 'angle1' to 'angle2' ; over less than 180 degrees: either angle2 > angle1 with ; angle2-angle1 < !pi or angle2 < angle1 with ; angle+2*!pi-angle1 < !pi. Always radius1 < radius2. ; ; If p_box is not specified then the wedge specified in ; the qImage_cw widget is used. ; ; exclude_p_box=exclude_p_box ; array[2,2; type: float ; another wedge specified in the same way as p_box. ; This wedge should lie completely inside the p_box wedge. ; If this box is specified than the return values refer to the ; area in between the two wedges. This box is passed unmodified to ; wedge_content. ; !!!!! If exclude_p_box is set then also /noupdate should be set: ; if /noupdate NOT set then p_box will be slightly modified, and ; exclude_p_box won't. ; ; /noupdate Only used if polar_box is specified. This argument is passed to ; qImage_cw_Wedge where it bypasses a call to qImage_cw_Box ; (which updates the position widgets). ; ; img_prorate=img_prorate ; array[2]; type: integer ; if set then pixels straddling the wedge boundary will be prorated ; by dividing them into img_prorate[0] x img_prorate[1] subpixels. ; OUTPUTS: ; zpix scalar; type: float or integer ; # pixels in wedge (non-integer values result from pro-rating) ; if the wedge is empty then zero is returned ; OPTIONAL OUTPUT PARAMETERS: ; zval array[4]; float ; minimum, maximum, average and standard deviation across the wedge ; if the wedge is empty then 4 x !values.f_nan is returned ; wedge array[2,n]; type: float ; boundary of wedge as a closed array (first=last point) ; in rectangular (pixel) coordinates (output from qImage_cw_Wedge) ; centroid array[2]; type: float ; centroid of the wedge ; if the wedge is empty then 2 x !values.f_nan is returned ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; BadValue, IsType, InitVar, qImage_cw_Wedge, qImage_cw_BoxImage, qImage_cw_Box ; Inside_Wedge, wedge_content ; PROCEDURE: ; > qImage_cw_Wedge is used to limit the part of the image to be included to the smallest ; square box including the whole wedge. ; > Inside_Wedge applied to pixel centers (integer coordinate values) is used to find ; pixels entirely lying inside the wedge. ; > A similar test on pixel corners (half-integer coordinate values) in combination with ; the previous test is used to locate pixels which lie across the wedge boundary. ; > These last group of pixels is subdivided in a 10x10 array of subpixels. A test on the ; centers on these subpixels is used to prorate the pixels with the ratio of subpixels ; inside the wedge and total number of pixels. ; > The prorating can be switched of by setting the user value of state.wid_prorate to 0. ; > Prorating is done only for the average value. Minimum, maximum and standard deviation ; are calculated with all pixels with centers inside the wedge weighted the same. ; STATE INFO USED: ; widget_control, state.wid_prorate, get_uvalue=set ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- zpix = 0 bad = BadValue(0.0) zval = replicate(bad,4) centroid = replicate(bad,2) b_box = qImage_cw_Wedge(state, p_box, wedge=wedge, noupdate=noupdate, img_center=img_center) CASE IsType(image, /defined) OF 0: BEGIN IF NOT qImage_cw_BoxImage(state, b_box, sub_img=sub_img, sub_box=sub_box) THEN BEGIN message, /info, 'empty wedge' RETURN, zpix ENDIF b_box = sub_box qImage_cw_Box, state, img_center, /center widget_control, /hourglass widget_control, state.wid_prorate[2], get_uvalue=set CASE set OF 0: prorate = intarr(2) 1: BEGIN widget_control, state.wid_prorate[0], get_value=mx widget_control, state.wid_prorate[1], get_value=my prorate = [mx,my]*(mx*my gt 0) ; Safety belt? END ENDCASE END 1: BEGIN sub_img = image[b_box[0]:b_box[2],b_box[1]:b_box[3]] InitVar, img_prorate, [0,0] prorate = img_prorate[0:1] END ENDCASE RETURN, wedge_content(sub_img, p_box, b_box=b_box, exclude_p_box=exclude_p_box, $ center=img_center, prorate=prorate, zval=zval, centroid=centroid) END