pro sharpfocus2, img, sharp, norm, fd_loc, hr_loc, iss=iss
;+
;NAME:
;	sharpfocus
;PURPOSE:
;	To 
;HISTORY:
;	Written 6-Apr-94 by M.Morrison (using Zayer routine as start)
;	26-Apr-94 (MDM) - Added /ISS option
;-

nx = n_elements(img(*,0,0))
ny = n_elements(img(0,*,0))
n  = n_elements(img(0,0,*))
;
middle=n/2
sharp=fltarr(2, n)
norm=fltarr(n)
if (keyword_set(iss)) then middle = 0	;no FD images in MDIISS
;
if (not keyword_set(iss)) then begin
    ;---------------------------------------- FD Focus
    print,'Calculating FD focus...'
    ;
    w=5
    l=25
    leg=25
    normarea=4*float(leg)^2
    focus_area, img, 4, w, l, leg, fd_loc, 0
    ;
    for i=0,middle-1 do begin
	temp = img(fd_loc.strt(0):fd_loc.stp(0), fd_loc.strt(1):fd_loc.stp(1), i)
	norm(i) = total(temp) / normarea
	sharp(0,i) = sharpness(img(*,*,i), fd_loc.xcut, fd_loc.ycut, w, l) / norm(i)
    endfor
end 
;
;---------------------------------------- HR Focus
print,'Calculating HR focus...'
;
w=10
l=50
leg=50
normarea=4*float(leg)^2
focus_area, img, middle+5, w, l, leg, hr_loc, 1
;
for i=middle,n-1 do begin
    temp = img(hr_loc.strt(0):hr_loc.stp(0), hr_loc.strt(1):hr_loc.stp(1), i)
    norm(i) = total(temp) / normarea
    sharp(0,i) = sharpness(img(*,*,i), hr_loc.xcut, hr_loc.ycut, w, l) / norm(i)
endfor
;
end
