(file) Return to max_pos.pro CVS log (file) (dir) Up to [Development] / JSOC / proj / flatfield / pzt_flat_IDL

File: [Development] / JSOC / proj / flatfield / pzt_flat_IDL / max_pos.pro (download)
Revision: 1.1, Fri Feb 18 00:21:17 2011 UTC (12 years, 7 months ago) by richard
Branch: MAIN
CVS Tags: Ver_LATEST, Ver_9-5, Ver_9-41, Ver_9-4, Ver_9-3, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, Ver_8-0, Ver_7-1, Ver_7-0, Ver_6-4, Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, Ver_5-14, Ver_5-13, HEAD
IDL package for calculating pzt flatfields
2011.02.17


;	max_pos.pro
;
;
;	This function, given an array with a single well
;	defined maximum, finds the maximum position 
;	of that array to decimal accuracy using an interpolation
;	technique to find the maximum of an array from, Niblack, W., 
;	"An Introduction to Digital Image Processing", p 139.
;
;
;           ------------INPUT-------------			
;
;	f	-	An array.
;			type: array,any type
;
;           ------------OUTPUT------------			
;
;	max	-	An array containing the position of the maximum of an array.
;			type: vector,floating point,fltarr(2)
;
;	max(0)	-	The decimal position of the x-maximum.
;			type: scalar,floating point
;
;	max(1)	-	The decimal position of the y-maximum.
;			type: scalar,floating point

function max_pos,f,loc=loc

  ssz=size(f)
  fmax=max(f,loc)
  xmax=loc mod ssz(1)
  ymax=loc/ssz(1)

  ;A more complicated interpolation technique to find the maximum of an array.
  ;from, Niblack, W., "An Introduction to Digital Image Processing", p 139.
  	if (xmax*ymax gt 0) and (xmax lt (ssz(1)-1)) and (ymax lt (ssz(2)-1)) then begin
        denom = fmax*2 - f(xmax-1,ymax) - f(xmax+1,ymax)
        xfra = (xmax-.5) + (fmax-f(xmax-1,ymax))/denom
        denom = fmax*2 - f(xmax,ymax-1) - f(xmax,ymax+1)
        yfra = (ymax-.5) + (fmax-f(xmax,ymax-1))/denom
        xmax=xfra
        ymax=yfra
      endif

  rmax=[xmax,ymax]

return,rmax

end

Karen Tian
Powered by
ViewCVS 0.9.4