moments {EBImage} | R Documentation

## Image moments and moment invariants, feature extraction

### Description

A set of functions to compute central, scale and rotation invariant moments as well as to estimate object rotation angles and elongations based on central moments.

### Usage

      ## S4 methods for signatures 'x=IndexedImage,ref=Image'
      ## and 'x=IndexedImage,ref=missing'
      cmoments(x, ref, ...)

      ## S4 method for signature 'IndexedImage, Image':
      smoments(x, ref, pw=3, what="s", ...)
      ## S4 method for signature 'IndexedImage, missing':
      smoments(x, ref, pw=3, what="s", ...)

      ## S4 methods for signatures 'x=IndexedImage,ref=Image'
      ## and 'x=IndexedImage,ref=missing'
      rmoments(x, ref, ...)

      ## S4 methods for signatures 'x=IndexedImage,ref=Image'
      ## and 'x=IndexedImage,ref=missing'
      ## and 'x=Image,ref=missing'
      moments(x, ref, ...)

### Arguments

`x` | An object of `Image`; a `Grayscale` object of `Image` in the last case.
`ref` | A `Grayscale` object of `Image`.
`pw` | A numeric value. When calculating central os scale invariant moments using `smoments` `pw` specifies the order of the matrix of moments to calculate.
`what` | A character string, or the first case insensitive letter, for the type of the moments to calculate: `C`entral, `S`cale invariants, or `R`otation invariants (specifying `R` is essentiall the same as calling `rmoments`.
`...` | Reserved.

### Details

`cmoments` computes centers of the objects (`x=M10/M00, y=M01/M00`), their "mass" (intensity, `int=M00`) and the area (number of non-background pixels).

`smoments` computes for each object in an image a square matrix of order `pw` of either central moments (`mu[i,j]`) or scale invariant moments (`nabla[i,j]`) depending on the parameter `what`.

`rmoments` computes for each object the Hu's set of 7 rotation invariants.

`moments` computes for each object a summary of interesting moments and derived descriprots that include mass (total intensity), location, elements of the covariance matrix and its eigenvalues, rotation angle and the Hu's 7 rotation invariants.

Functions with signature `x=IndexedImage` work on images with multiple indexed objects in every frame. The index information is used to identify every object and serves as a mask resetting for every object pixels outside of the mask to background. The intensity is retrieved from the corresponding reference image. If it is not supplied, the intensity is set to 1 at each pixel of an object.

`moments` with `x='Image'` expect input image to contain one and only one object in each frame (such as those obtained by `stackObjects`).

### Value

For `x=IndexedImage`:
For a single frame in `x` the result of `smoments` with types `S` and `C` is a 3D array with first two dimensions building square matrices of size `pw`*`pw` and the third dimension corresponds to the number of indexed objects in the frame. All other functions return 2D matrices with different moments or descriptors in columns and objects in rows.
For multiple frames a list of the above will be returned.
For `x=Image`:
The result is a 2D matrix of with different moments or descriptors in columns and objects in rows. (each frame is assumed to contain a single object).

### Author(s)

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

### References

M.K. Hu, Visual Pattern Recognition by Moment Invariants, IRE Trans. Info. Theory, vol. IT-8, pp.179-187, 1962

Image moments: http://en.wikipedia.org/wiki/Image_moments

### See Also

`IndexedImage, watershed, getFeatures`

### Examples

      ## see example(getFeatures)

[Package EBImage version 2.6.0 Index]