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

