floodFill              package:EBImage              R Documentation

_F_i_l_l_i_n_g _m_a_t_r_i_x _d_a_t_a _w_i_t_h _f_l_o_o_d _f_i_l_l _a_l_g_o_r_i_t_h_m

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

     Functions to fill regions in images and matrices/arrays and fill
     holes in  indexed objects.

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

       ## S4 method for signature 'array':
       floodFill(x, pt, col, tolerance=1e-3, ...)
       ## S4 method for signature 'IndexedImage':
       fillHull(x, ...)

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

       x: An 'array'-like object (e.g. 'Image')  to be filled. For
          'fillHull' this must be an instance of 'IndexedImage'.

      pt: An integer of 2 values for 'x-y' coordinates of the point
          where fill starts. 

     col: A value for the fill color, supposedly in the same storage
          mode as  'x'. If 'x' is an image 'col' will be converted to
          the  corresponding storage mode using the 'channel' function,
          and thus can be a character value specifying the color in X11
          mode.

tolerance: Color tolerance used during the fill. 

     ...: Reserved. 

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

     If no color is specified, the color under the coordinates of 'pt'
     is used  (this only has sense if tolerance is not zero). The flood
     fill is implemented using the fast scan line algorithm. It is
     assumed that 'floodFill' is run either on matrices of
     single-framed images. If the latter is not the case, only the
     first frame will be modified!

     'fillHull' files holes in objects of 'IndexedImage''s.

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

     A copy of 'x' with the fill applied.

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

     Gregoire Pau, Oleg Sklyar; 2007

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

     ' Image, IndexedImage '

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

     if (interactive()) {
       data(imageWithHoles)

       display(x, main="Original image")
       display(floodFill(x,c(5,5),tolerance=0.2))
       display(floodFill(x,c(40,40),tolerance=0.2))

       mask = x
       mask[mask>0.3]=1
       mask[mask<=0.3]=0

       y = floodFill(mask,c(40,40),2)
       class(y) = "IndexedImage"
       display(y, main="Indexed mask with holes")
       
       y = fillHull(y)
       display(y, main="Indexed mask without holes")

       rgb = channel(normalize(y), "rgb")
       rgb = floodFill(rgb, c(1,1), "red")
       rgb = floodFill(rgb, c(50,50), "blue")
       rgb = floodFill(rgb, c(150,150), "green")
       display(rgb)
     }

