FUNCTION stroal2,ima,sh1,sh2 ; ; Version 2 of STROAL.PRO ; Segmentation routine using the algorithm by L.H. Strous (Thesis, 1994) ; IMA - input 2D image ;IF CCD pixel has a square shape only two parameters are needed: ; SH1 - input distance between investigated points (in pixels), in vertical or horisontal shift. ; SH2 - input distance between investigated points (in pixels), in diagonal shift. ; default : sh1=sh2=1 OR sh2=sh1 ; SEG - returned segmentation mask of the same size and type as IMA ; (1=bright, -1=dark, 0=undefined) ; Calling: SEG = STROAL2(IMA,SH1,SH2) ; ; ver.1 written by Michal, 1998; revised March 2000, ; ver.2 written by Hashem, 2006 si=size(ima) ima2=ima*2 seg=ima*0 if n_params() lt 2 then begin sh1=1 sh2=1 endif if n_params() lt 3 then sh2=sh1 ; computing the formula a=I1+I3-2*I2 for 4 directions iew=shift(ima,sh1,0) iwe=shift(ima,-sh1,0) ins=shift(ima,0,sh1) isn=shift(ima,0,-sh1) ine=shift(ima,sh2,sh2) isw=shift(ima,-sh2,-sh2) ise=shift(ima,sh2,-sh2) inw=shift(ima,-sh2,sh2) aew=iew+iwe-ima2 ans=ins+isn-ima2 ane=ine+isw-ima2 ase=ise+inw-ima2 wdark=where((aew gt 0) and (ans gt 0) and (ane gt 0) and (ase gt 0)) wbrit=where((aew lt 0) and (ans lt 0) and (ane lt 0) and (ase lt 0)) seg(wdark)=(-1) ; positive-concave-dark seg(wbrit)=1 ; negative-convex-bright sh=max([sh1,sh2]) seg(0:sh-1,*)=0 ; forget absurd values at the edges seg(*,0:sh-1)=0 seg(si(1)-sh:si(1)-1,*)=0 seg(*,si(2)-sh:si(2)-1)=0 RETURN,seg END