# im.object

##### Class of Images

A class `"im"`

to represent a two-dimensional pixel image.

##### Details

An object of this class represents a two-dimensional pixel image. It specifies

the dimensions of the rectangular array of pixels

\(x\) and \(y\) coordinates for the pixels

a numeric value (``grey value'') at each pixel

If `X`

is an object of type `im`

,
it contains the following elements:

`v` |
matrix of values |

`dim` |
dimensions of matrix `v` |

`xrange` |
range of \(x\) coordinates of image window |

`yrange` |
range of \(y\) coordinates of image window |

`xstep` |
width of one pixel |

`ystep` |
height of one pixel |

`xcol` |
vector of \(x\) coordinates of centres of pixels |

Users are strongly advised not to manipulate these entries directly.

Objects of class `"im"`

may be created by the functions
`im`

and `as.im`

.
Image objects are also returned by various functions including
`distmap`

, `Kmeasure`

, `setcov`

,
`eval.im`

and `cut.im`

.

Image objects may be displayed using the methods
`plot.im`

, `image.im`

, `persp.im`

and `contour.im`

. There are also methods
`print.im`

for printing information about an image,
`summary.im`

for summarising an image,
`mean.im`

for calculating the average pixel value,
`hist.im`

for plotting a histogram of pixel values,
`quantile.im`

for calculating quantiles of pixel values,
and `cut.im`

for dividing the range of pixel values into
categories.

Pixel values in an image may be extracted
using the subset operator `[.im`

.
To extract all pixel values from an image object,
use `as.matrix.im`

.
The levels of a factor-valued image can be extracted and
changed with `levels`

and `levels<-`

.

Calculations involving one or more images (for example,
squaring all the pixel values in an image, converting numbers to
factor levels, or
subtracting one image from another) can often be done
easily using `eval.im`

.
To find all pixels satisfying
a certain constraint, use `solutionset`

.

Note carefully that the entry `v[i,j]`

gives the pixel value at the location `(xcol[j],yrow[i]`

.
That is, the **row** index of the matrix `v`

corresponds
to increasing **y** coordinate, while the column index of `mat`

corresponds to increasing **x** coordinate.
Thus `yrow`

has one entry for each row of `v`

and `xcol`

has one entry for each column of `v`

.
Under the usual convention in R, a correct
display of the image would be obtained by transposing the matrix, e.g.
`image.default(xcol, yrow, t(v))`

, if you wanted to do it by hand.

##### Warnings

The internal representation of images is likely to change in future
releases of spatstat. Do not address the entries in an
image directly. To extract all pixel values from an image object,
use `as.matrix.im`

.

##### See Also

*Documentation reproduced from package spatstat, version 1.55-1, License: GPL (>= 2)*