FUNCTION Area_Search,A,px,py,dx,dy ;+ ;Find the point where A is maximum in the neighborhood ;of (px,py). Search the region [px-dx:px+dx,py-dy:py+dy]. ; ;Return the location in A coordinates. ; ;Harvey Rhody ;January 25, 2005 ;For use in matching points between images. ;- ;Check that the neighborhood falls within the array sa=Size(A,/dim) if px-dx LT 0 or px+dx GE sa[0] or py-dy LT 0 or py+dy GE sa[1] THEN $ return,[-1,-1] Amax=max(A[px-dx:px+dx,py-dy:py+dy],kmax) ;Convert index kmax into x and y offset values ;First make sure dx and dy are integers dx=floor(dx) & dy=floor(dy) vy=kmax/(2*dx+1) vx=kmax mod (2*dx+1) Return,[px-dx+vx,py-dy+vy] end