getFeatures             package:EBImage             R Documentation

_F_e_a_t_u_r_e _e_x_t_r_a_c_t_i_o_n _f_o_r _o_b_j_e_c_t_s _i_n _i_n_d_e_x_e_d _i_m_a_g_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Functions to extract numerical descriptors for objects in indexed
     images. The functions here call a set of individual feature
     extraction routines for every feature set like hull, texture
     (Haralick), edge, moment features etc.

_U_s_a_g_e:

       ## S4 method for signature 'IndexedImage':
       getFeatures(x, ref, N=12, R=30, apply.Gaussian=TRUE, nc=256, ...)
       ## S4 method for signature 'IndexedImage':
       features(x, ...)

_A_r_g_u_m_e_n_t_s:

       x: An object of 'IndexedImage' (like those obtained from
          'propagate' or 'watershed'. 

     ref: A reference image containing images of the objects in
          Grayscale mode (intensity values)! 

       N: Passed to 'zernikeMoments'. Integer value  defining the
          degree of the Zernike polynomials, which in turn defines the 
          number of features calculated. Defaults to 12.

       R: Passed to 'zernikeMoments'. Defines the radius  of the circle
          around an object centre from which the features are
          calculated.  It also defines the standard deviation for the
          2D Gausian applied at the  centre of an object. See details.
          Defaults to 30. 

apply.Gaussian: Passed to 'zernikeMoments'. A logical  value that
          specifies if a local 2D Gaussian modification should be
          applied  to every object at its centre. Defaults to 'TRUE'.

      nc: Passed to 'haralickFeatures'. A numeric value.  Specifies the
          number of gray levels to separate 'ref' into when 
          calculating the co-occurrence matrix. Here defaults to 256.

     ...: Reserved. 

_D_e_t_a_i_l_s:

     'ref' can be missing in calls to 'getFeatures'. In this case
     texture and other intensity-dependent features will be omitted.

_V_a_l_u_e:

     'getFeatures' calculates feature matrices and returns an object of
      'IndexedImage' with its 'features' slot set. The typical use
     would be to re-assign the result to the original image itself, 
     i.e. 'x <- getFeatures(x, a)'.

     'features' extracts the content of the 'features' slot of the 
     'IndexedImage'. If it is empty, the function calls 'getFeatures'
     without a reference image and returns the generated feature set.
     In this case the 'features' slot of the original image is not
     updated.

_A_u_t_h_o_r(_s):

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

_S_e_e _A_l_s_o:

     ' IndexedImage, propagate, paintObjects, stackObjects,
     hullFeatures, haralickFeatures, moments, edgeFeatures,
     zernikeMoments '

_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)
       ft = hullFeatures(io)
       mf = moments(io, ii)   ## need these for intensity and size
       for ( i in seq_along(ft) ) ft[[i]] = cbind(ft[[i]], mf[[i]])
       io = rmObjects(io, lapply(ft, function(x) 
              which(x[,"h.s"] < 150 | x[,"int"] < 50 | 0.3 * x[,"h.p"] < x[,"h.edge"] )
            ))
       io = getFeatures(io, ii)
       str( features(io) )
       

