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)
     }

