PRO starmag,img,col,row,diff ;program to find the DN of a star with respect to the median background i=intarr(256,256) row=REPLICATE(256.,N_ELEMENTS(row))-row i(col,row)=1 ; binary image of stars cell=INTARR(13,13)+1 cell(0:2,0:2)=0 cell(10:12,10:12)=0 cell(10:12,0:2)=0 cell(0:2,10:12)=0 di =DILATE(i,cell) dimg=di*img ; image of areas around (col,row) of size 'cell' nbhd=INTARR(13,13,N_ELEMENTS(row)) diff=FLTARR(N_ELEMENTS(row)) & tot=diff & meandiff=diff ;calculating median BG and difference between BG and original image for each pt. FOR j=0,N_ELEMENTS(row)-1 DO BEGIN IF (col(j) GE 0) AND (row(j) GE 0) AND $ ;only stars within the 256*256 ;image are differenced (col(j) LE 255) AND (row(j) LE 255) THEN BEGIN nbhd=img(MAX([0,col(j)-6]):MIN([255,col(j)+6]),$ ;neighborhood MAX([0,row(j)-6]):MIN([255,row(j)+6])); around each pt. ;does not go past the(0,0),(256,256) boundary. snbhd=SIZE(nbhd) md = MEDIAN(nbhd) mnbhd=(nbhd-REPLICATE(md,snbhd(1),snbhd(2)))>0;nbhd with its ;median subtracted ai=REBIN(BINDGEN(snbhd(1)),snbhd(1),snbhd(2));matrix, with the size of nbhd, of increasing collumn nos. aj=REBIN(TRANSPOSE(BINDGEN(snbhd(2))),snbhd(1),snbhd(2)) ;transpose of ai mx=TOTAL(ai*mnbhd)/TOTAL(mnbhd) ;row and col #'s of the weighted my=TOTAL(aj*mnbhd)/TOTAL(mnbhd) ;centre of nbhd, depending on DN bmx=BYTE(mx+0.5) ;rounded byte forms of mx & my bmy=BYTE(my+0.5) mn = mean(nbhd) little=nbhd(MAX([bmx-2,0]):MIN([bmx+2,snbhd(1)-1]),$ MAX([bmy-2,0]):MIN([bmy+2,snbhd(2)-1])) stardn=TOTAL(little); total DN of pixels around (mx,my) diff(j)=stardn-md*N_ELEMENTS(little) ;difference between DN of star and median neighborhood. tot(j)=stardn meandiff(j)=stardn-mn; diff. between total DN and mean of nbhd ;print,nbhd,form='(13I6)' ;print,little,FORM='(5I6)' IF j EQ 0 then print,md,mx,my,diff(j) ;if diff(j) LT 0 THEN STOP stop ENDIF ELSE diff(j) = 0 ENDFOR RETURN END