FUNCTION stroal,ima,sh ; ; Segmentation routine using the algorithm by L.H. Strous (Thesis, 1994) ; IMA - input 2D image ; SH - input distance between investigated points (in pixels), ; default = 1 ; SEG - returned segmentation mask of the same size and type as IMA ; (1=bright, -1=dark, 0=undefined) ; Calling: SEG = STROAL(IMA,SH) ; Program written by Michal, 1998; revised March 2000 si=size(ima) ima2=ima*2 seg=ima*0 if n_params() lt 2 then sh=1 ; computing the formula a=I1+I3-2*I2 for 4 directions iew=shift(ima,sh,0) iwe=shift(ima,-sh,0) ins=shift(ima,0,sh) isn=shift(ima,0,-sh) ine=shift(ima,sh,sh) isw=shift(ima,-sh,-sh) ise=shift(ima,sh,-sh) inw=shift(ima,-sh,sh) 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 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