watershed              package:EBImage              R Documentation

_W_a_t_e_r_s_h_e_d _t_r_a_n_s_f_o_r_m_a_t_i_o_n _a_n_d _w_a_t_e_r_s_h_e_d _b_a_s_e_d _o_b_j_e_c_t _d_e_t_e_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Watershed transformation and watershed based object detection.

_U_s_a_g_e:

       watershed(x, tolerance=1, ext=1)

_A_r_g_u_m_e_n_t_s:

       x: An 'Image' object or an array.

tolerance: The minimum height of the object in the units of image
          intensity between its highest point (seed) and the point
          where it contacts another object (checked for every contact
          pixel). If the height is smaller than the tolerance, the
          object will be combined with one of its neighbors, which is
          the highest. Tolerance should be chosen according to the
          range of 'x'. Default value is 1, which  is a reasonable
          value if 'x' comes from 'distmap'.

     ext: Radius of the neighborhood in pixels for the detection of
          neighboring objects. Higher value smoothes out small objects. 

_D_e_t_a_i_l_s:

     The algorithm identifies and separates objects that stand out of
     the background (zero). After the water fill, the source image is
     flipped upside down and the resulting valleys (values with higher
     intensities) are filled in first until another object or
     background is met. The deepest valleys (pixels with highest
     intensity) become indexed first, starting from 1.

     The function 'bwlabel' is a simpler, faster alternative to 
     segment connected objects from binary images.

_V_a_l_u_e:

     An 'Grayscale' 'Image' object or an array, containing the labelled
     version of 'x'.

_A_u_t_h_o_r(_s):

     Oleg Sklyar, osklyar@ebi.ac.uk, 2007

_S_e_e _A_l_s_o:

     'bwlabel',  'propagate'

_E_x_a_m_p_l_e_s:

       x = readImage(system.file('images', 'shapes.png', package='EBImage'))
       x = x[110:512,1:130]
       if (interactive()) display(x, title='Binary')
       y = distmap(x)
       if (interactive()) display(normalize(y), title='Distance map')
       w = watershed(y)
       if (interactive()) display(normalize(w), title='Watershed')

