Learn R Programming

SpatialVx (version 0.3)

imomenter: Image Moments

Description

Calculate some of the raw image moments, as well as some useful image characteristics.

Usage

imomenter(x, loc = NULL, ...)

## S3 method for class 'im': imomenter(x, loc = NULL, ...)

## S3 method for class 'matrix': imomenter(x, loc = NULL, ...)

## S3 method for class 'imomented': print(x, ...)

Arguments

x
imomenter: matrix or object of class im (from package spatstat).

print: object of class imomenter.

loc
A two-column matrix giving the location coordinates. May be missing in which case they are assumed to be integers giving the row and column numbers.
...
Not used.

Value

  • A list object of class imomented is returned with components:
  • areaSame as M00.
  • centroidnumeric with named components x and y giving the x- and y- coordinates of the centroid as calculated by the image moment method.
  • orientation.angleThe orientation angle of the image as calculated by image moments.
  • raw.momentsnamed numeric vector with the raw image moments: M00, M10, M01, M11, M20 and M02 used in calculating the other returned values.
  • cov2 by 2 image covariance as calculated by the image moment method.

Details

Calculates Hu's image moments (Hu 1962). Calculates the raw moments: M00 (aka area), M10, M01, M11, M20, and M02, as well as the (normalized) central moments: mu11', mu20', and mu02', which are returned as the image covariance matrix: rbind(c(mu20', mu11'), c(mu11', mu02')). In addition, the image centroid and orientation angle are returned, as calculated using the image moments.

The orientation angle calculated here is that which is used by MODE, although not currently used in the MODE analyses in this package (smatr is used instead to find the major axis, etc). The eigenvalues of the image covariance correspond to the major and minor axes of the image.

For more information on image moments, see http://en.wikipedia.org/wiki/Image_moments and references therein.

References

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

See Also

Mij, FeatureAxis

Examples

Run this code
look <- matrix(0, 10, 10)

look[3:5, 7:8] <- rnorm(6)

imomenter(look)

data(geom000) 
data(ICPg240Locs)

imomenter(geom000)
imomenter(geom000, loc = ICPg240Locs)

data(geom004)

imomenter(geom004)

imomenter(geom004, loc = ICPg240Locs)

Run the code above in your browser using DataLab