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
       ## S4 method for signature 'IndexedImage, Image,
       ##   numeric':
       stackObjects(x, ref, index, ...)

       ## S4 method for signature 'IndexedImage, Image,
       ##   missing':
       stackObjects(x, ref, index, combine, rotate, bg.col, ext, centerby, rotateby, ...)

_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. 

centerby,rotateby: If 'ref' is a TrueColor image, these character 
          values specify which channel should be used to center and
          rotate objects.  By default the image is converted by
          'channel(ref,"gray")'.  Other possible values are '"red",
          "green"' or '"blue"'. 

     ...: 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, combine=FALSE)
       ## 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)
       

