stackObjects             package:EBImage             R Documentation

_G_e_n_e_r_a_t_e _a _s_t_a_c_k _o_f _i_m_a_g_e_s _f_o_r _d_e_t_e_c_t_e_d _o_b_j_e_c_t_s, _o_n_e _o_b_j_e_c_t _p_e_r _i_m_a_g_e

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

     From an indexed image the functions generates an image stack with
     one image per object placing each object in the middle of the
     image. Objects can be automatically rotated to align them along
     the horizontal axis.

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

       ## S4 methods for signatures 'x=IndexedImage,ref=Image,index=character'
       ## and 'x=IndexedImage,ref=Image,index=list'
       ## and 'x=IndexedImage,ref=Image,index=numeric'
       ## S4 method for signature 'IndexedImage, Image,
       ##   missing':
       stackObjects(x, ref, index, combine, rotate, bg.col, ext, ...)
       

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

       x: An object of 'IndexedImage'. Images must be Grayscale and
          carry object indexing information, like those returned by
          'watershed' or 'propagate'. 

     ref: A reference image containing images of the objects to be
          stacked using 'x' both as index and the mask. Can be in any
          color mode. 

   index: Indexes of objects to stack. See details for supported types. 

 combine: Called on a stack if images, specifies if the resulting list
          of image stacks with individual objects should be combined
          into a single image stack. Defaults to 'FALSE'. 

  rotate: Specifies if the objects should be aligned rotationally.
          Defaults to 'TRUE'. 

  bg.col: Color for pixels outside the mask defined by 'x'. Defaults to
          'TRUE'. 

     ext: Extension of the target bounding box. See details. If not
          given, 'ext' is calculated from data. 

     ...: Reserved. 

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

     The bounding box is set to be a square, which centre coinsides
     with the geometric center of the object. The 'ext' argument can be
     used to specified its size, where edge length will be given by
     '2*ext+1'. If 'ext' is not specified, it is calculated from the
     data by taking the 95% quantile of the vector of 'h.s2major'
     descriptor of 'hullFeatures' taken over all, objects in the image.
     This descriptor specifies the extension of the object along its
     major axis starting from its center.

     The size of the bounding box is fixed for all frames to enable
     combining the resulting frames into a single multiframe image.

     'index' must be coersable to numeric to specify object indexes
     that are taken into the resulting stack. It can be specified as
     'numeric' directly only for images with 1 frame. For images with
     multiple frames it can be either a 'list' or a 'character'. If
     specified as a 'list', it can be a named list of numeric indexes
     where names are converted to 'character' frame indexes in an
     arbitrary order, or it can be an unnamed list of the same length
     as the number of frames. If specifies as 'character', each element
     must contain two numbers separated by a dot where the first number
     is the index of the frame and the second one is the index of the
     object within the frame, e.g. '"2.035"' will specify frame 2 and
     object 35.

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

     An image stack or a list of image stacks if 'x' was itself a stack
     (contained more than one image).

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

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

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

     ' tile, combine, paintObjects '

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

       ## load images
       f <- paste( system.file(package="EBImage"), "images/Gene1_G.tif", sep="/" )
       ii = readImage(f)
       ## normalize images
       ii = normalize(ii, separate=TRUE)
       ## segment
       mask = thresh(ii, 25, 25, 0.02)
       ## refine segmentation with morphology filters
       mk3 = morphKern(3)
       mk5 = morphKern(5)
       mask = dilate(erode(closing(mask, mk5), mk3), mk5)
       ## index objects with 'watershed'
       io = watershed( distmap(mask), 1.5, 1)
       if (interactive()) display(io)

       ## stack individual objects
       s = stackObjects(io, ii)
       ## display stack of objects of from the first image
       if (interactive()) display(s[[1]])
       ## combine stacks of objects into a single stack
       s = combine(s)
       ## tile the stack into one frame
       t = tile(s)
       if (interactive()) display(t)
       

