imagematrix: Generate an imagematrix, i.e. primary data structure of...

Description Usage Arguments Details Value See Also Examples

View source: R/imagematrix.R

Description

This function makes an imagematrix object from a matrix. This data structure is primary data structure to represent image in rimage package.

Usage

1
2
imagematrix(mat, type=NULL,
         ncol=dim(mat)[1], nrow=dim(mat)[2], noclipping=FALSE)

Arguments

mat

array, matrix or vector

type

"rgb" or "grey"

ncol

width of image

nrow

height of image

noclipping

TRUE if you disable automatic clipping. See details.

Details

For grey scale image, matrix should be given in the form of 2 dimensional matrix. First dimension is row, and second dimension is column.

For rgb image, matrix should be given in the form of 3 dimensional array (row, column, channel). mat[,,1], mat[,,2], mat[,,3] are red plane, green plane and blue plane, respectively.

You can omit 'type' specification if you give a proper array or matrix. Also, if you give a rgb image matrix and specify "grey" as type, the rgb image matrix is automatically converted to a grey scale image.

This function automatically clips the pixel values which are less than 0 or greater than 1. If you want to disable this behavior, give 'noclipiing=TRUE'.

The major difference between imagematrix and pixmap is representation method. pixmap (>0.3) uses OOP class. On the other hand, rimage uses traditional S class. The advantage of traditional S class in representing image is that one can deal with the data structure as an ordinary matrix.

The minor difference between imagematrix and pixmap is automatic data conversion behavior. pixmap normalizes a given matrix automatically if any element of the matrix is out of range between 0 and 1. On the other hand, imagematrix clips the matrix, which means that the pixels which have lower value than 0 are replaced to 0 and the pixels have greater value than 1 are replaced to 1.

Value

return an imagematrix object

See Also

plot.imagematrix,print.imagematrix

Examples

1
2
3
  p <- q <- seq(-1, 1, length=20)
  r <- 1 - outer(p^2, q^2, "+") / 2
  plot(imagematrix(r))

ripa documentation built on May 29, 2017, 5:39 p.m.

Related to imagematrix in ripa...