function esegment,x
if data_chk(x,/nimage) ne 1 then begin 
   box_message,['2d Image input required...', $ 
                'IDL> segmap=esegment(image)']
   return,-1
endif
                   
 s = x gt shift(x,1,0) and x gt shift(x,-1,0)
 s = s + (x gt shift(x,0,1) and x gt shift(x,0,-1))
 s = s + (x gt shift(x,1,1) and x gt shift(x,-1,-1))
 s = s + (x gt shift(x,1,-1) and x gt shift(x,-1,1))
 return,s
end