computeFeatures {EBImage} | R Documentation

## Compute object features

### Description

Computes morphological and texture features from image objects.

### Usage

    computeFeatures(x, ref, methods.noref=c("computeFeatures.moment", "computeFeatures.shape"),
      methods.ref=c("computeFeatures.basic", "computeFeatures.moment", "computeFeatures.haralick"),
      xname="x", refnames, properties=FALSE, expandRef=standardExpandRef, ...)

    computeFeatures.basic(x, ref, properties=FALSE, basic.quantiles=c(0.01, 0.05, 0.5, 0.95, 0.99), xs, ...)
    computeFeatures.shape(x, properties=FALSE, xs, ...)
    computeFeatures.moment(x, ref, properties=FALSE, xs, ...)
    computeFeatures.haralick(x, ref , properties=FALSE, haralick.nbins=32, haralick.scales=c(1, 2), xs, ...)

    standardExpandRef(ref, refnames, filter = gblob())

### Arguments

`x` | An `Image` object or an array containing labelled objects. Labelled objects are pixel sets with the same unique integer value.
`ref` | A matrix or a list of matrices, containing the intensity values of the reference objects.
`methods.noref` | A character vector containing the function names to be called to compute features without reference intensities. Default is `computeFeatures.moment` and `computeFeatures.shape`.
`methods.ref` | A character vector containing the function names to be called to compute features with reference intensities. Default is `computeFeatures.basic`, `computeFeatures.moment` and `computeFeatures.haralick`.
`xname` | A character string naming the object layer. Default is `x`.
`refnames` | A character vector naming the reference intensity layers. Default are the names of `ref`, if present. If not, reference intensity layers are named using lower-case letters.
`properties` | A logical. If `FALSE`, the default, the function returns the feature matrix. If `TRUE`, the function returns feature properties.
`expandRef` | A function used to expand the reference images. Default is `standardExpandRef`. See Details.
`basic.quantiles` | A numerical vector indicating the quantiles to compute.
`haralick.nbins` | An integer indicating the number of bins using to compute the Haralick matrix. See Details.
`haralick.scales` | A integer vector indicating the number of scales to use to compute the Haralick features.
`xs` | An optional temporary object created by `computeFeatures` used for performance considerations.
`filter` | The filter applied to reference images using `filter2` in order to add granulometry.
`...` | Optional arguments passed to the feature computation functions.

### Details

Features are named x.y.f, where x is the object layer, y the reference image layer and f the feature name. Examples include `cell.dna.mean`, indicating mean DNA intensity computed in the cell or `nucleus.tubulin.cx`, indicating the x center of mass of tubulin computed in the nucleus region.

The function `computeFeatures` computes sets of features. Features are organized in 4 sets, each computed by a different function. The function `computeFeatures.basic` computes spatial-independent statistics on pixel intensities:

- b.mean: mean intensity

- b.sd: standard deviation intensity

- b.mad: mad intensity

- b.q*: quantile intensity

The function `computeFeatures.shape` computes features that quantify object shape:

- s.area: area size (in pixels)

- s.perimeter: perimeter (in pixels)

- s.radius.mean: mean radius (in pixels)

- s.radius.sd: standard deviation of the mean radius (in pixels)

- s.radius.max: max radius (in pixels)

- s.radius.min: min radius (in pixels)

The function `computeFeatures.moment` computes features related to object image moments, which can be computed with or without reference intensities:

- m.cx: center of mass x (in pixels)

- m.cy: center of mass y (in pixels)

- m.majoraxis: elliptical fit major axis (in pixels)

- m.eccentricity: elliptical eccentricity defined by sqrt(1-minoraxis^2/majoraxis^2). Circle eccentricity is 0 and straight line eccentricity is 1.

- m.theta: object angle (in radians)

The function `computeFeatures.haralick` computes features that quantify pixel texture. Features are named according to Haralick's original paper.

### Value

If `properties` if `FALSE` (by default), `computeFeatures` returns a matrix of n cells times p features, where p depends of the options given to the function. Returns `NULL` if no object is present.

If `properties` if `TRUE`, `computeFeatures` returns a matrix of p features times 2 properties (translation and rotation invariance). Feature properties are useful to filter out features that may not be needed for specific tasks, e.g. cell position when doing cell classification.

### Author(s)

Gregoire Pau, gregoire.pau@embl.de, 2011

### References

R. M. Haralick, K Shanmugam and Its'Hak Deinstein (1979). Textural Features for Image Classification. IEEE Transactions on Systems, Man and Cybernetics.

### See Also

`bwlabel`, `propagate`

### Examples

      ## load and segment nucleus
      y = readImage(system.file("images", "nuclei.tif", package="EBImage"))[,,1]
      x = thresh(y, 10, 10, 0.05)
      x = opening(x, makeBrush(5, shape='disc'))
      x = bwlabel(x)
      display(y, title="Cell nuclei")
      display(x, title="Segmented nuclei")

      ## compute shape features
      fts = computeFeatures.shape(x)
      fts

      ## compute features
      ft = computeFeatures(x, y, xname="nucleus")
      cat("median features are:\n")
      apply(ft, 2, median)

      ## compute feature properties
      ftp = computeFeatures(x, y, properties=TRUE, xname="nucleus")
      ftp

[Package EBImage version 4.22.1 Index]