function peak_coord, array ;+ ; NAME: ; PEAK_COORD ; ; PURPOSE: ; Measurement of coordinates of the pixel which has the maximum value in a ; 2-dimensional array or in each of slices in a 3-dimensional array. ; ; CATEGORY: ; Image analysis. ; ; CALLING SEQUENCE: ; Result = PEAK_COORD(Array) ; ; INPUTS: ; Image: A 2- or 3-dimensional array to be analyzed. This array may be of any type. ; ; OPTIONAL INPUT PARAMETERS: ; None. ; ; KEYWORD PARAMETERS: ; None. ; ; OUTPUTS: ; Result: In the case of 2-D input array it is 2-element vector containing coordinates of ; the maximum in the array. In the case of 3-D input array of size (K,L,N) it is a ; (2,N)-dimensional array containing coordinates of the peaks in each slice. The result is ; long integer. ; ; COMMON BLOCKS: ; None. ; ; SIDE EFFECTS: ; None. ; ; RESTRICTIONS: ; None. ; ; PROCEDURE: ; Linear subscript IMAX of the maximum is measured using MAX function. ; Two-dimensional coordinates are then found as [IMAX mod K, IMAX / K]. In the ; case of 3-D array, the loop is executed over the number N. ; ; MODIFICATION HISTORY: ; ; ISTP SD RAS, 1999. ; Victor Grechnev (grechnev@iszf.irk.ru): Initially written. ; ; ISTP SD RAS, Jul, 2002. ; Natalia Meshalkina (nata@iszf.irk.ru): Help added. ;- Sz=size(array) if Sz(0) eq 2 then begin amax = max(array, imax) return, ([imax mod Sz(1), imax /Sz(1)]) endif else begin maxima = intarr(2, Sz(Sz(0))) for j=0, Sz(Sz(0))-1 do begin amax = max(array(*,*,j), imax) maxima(*,j) = [imax mod Sz(1), imax /Sz(1)] endfor return, maxima endelse end