\name{rip}
\docType{class}
\alias{rip}
\alias{print.rip}
\alias{plot.rip}
\alias{image.rip}
\alias{nchannel}
\title{The rip class and methods}
\usage{
\method{print}{rip}(x, ...)
\method{plot}{rip}(x, rescale = TRUE, ...)
\method{plot}{rip}(x, rescale = TRUE, ...)
\method{image}{rip}(x, ..., rescale = TRUE, restrict = !rescale,
    shift = FALSE, xlab = "", ylab = "", asp = 1,
    interpolate = FALSE)
nchannel(x)
}
\arguments{

  \item{x}{
    An object of class \code{"rip"}.
  }
  \item{rescale}{
    Logical flag indicating whether data should be rescaled to lie
    between 0 and 255. If \code{TRUE}, \code{min(x)} becomes 0 and
    \code{max(x)} becomes 255.
  }
  \item{restrict}{
    Logical flag indicating whether values outside of the range [0, 255]
    should be truncated to their nearest endpoints.
  }
  \item{shift}{
    Logical flag indicating whether quadrants should be shifted by half
    of the range. This currently only works for single channel images
    and is useful primarily to visualize results of DFT, where
    \code{shift} controls whether the axis range is \code{c(-pi, pi)} or
    \code{c(0, 2 * pi)}.
  }
  \item{xlab, ylab}{
    character string or expression specifying x-axis and y-axis labels.
  }
  \item{asp}{
    Aspect ratio for the plot.
  }
  \item{interpolate}{
    Logical flag indicating whether the image should be interpolated.
  }
  \item{...}{
    Additional arguments. The \code{plot} method passes extra arguments
    to \code{\link[graphics]{plot.raster}}.
  }

}
\value{
  \code{nchannel} returns the number of channels in \code{x}. The other
  functions have no useful return value, and are called for their side effects.

}

\description{

  The \code{print} method for \code{"rip"} objects displays the
  dimension and number of channels.

  The \code{plot} method essentially calls \code{plot(as.raster(x))} with an
  option to rescale the image first.

  The \code{image} method provides more flexibility, and finally calls
  \code{\link[graphics]{rasterImage}}.
  
}
\details{

  The basic data type in the OpenCV library is the \code{cv::Mat} class,
  representing an n-dimensional dense numerical single-channel or
  multi-channel array. This class can be used to store real or
  complex-valued vectors and matrices, grayscale or color images, voxel
  volumes, vector fields, point clouds, tensors.

  The \code{"rip"} class mirrors this class, which is essentially a
  matrix with an additional \code{"cvdim"} attribute. For example, a 600
  x 400 color image with three (RGB) channels will be represented as a
  600 x 1200 matrix with attribute \code{cvdim = c(600, 400, 3)}. In the
  underlying matrix, the first three columns will store the RBG channels
  for the first \sQuote{column} of the image, and so on. Similarly, for
  a complex matrix of size 600 x 400, the number of channels will be 2
  (real and imaginary) and the underlying matrix will have dimension 600
  x 800.

  The conventional approach in R to represent such objects is a
  three-dimensional array. Coercion to and from arrays can be performed
  using \code{\link[=as.array.rip]{as.array}} and \code{\link{as.rip}}
  methods.

  A \code{"rip"} object by itself does not contain any information on
  the interpretation of the data contained therein. Its primary purpose
  is to serve as an R analog of \code{cv::Mat} objects; R functions
  that wrap OpenCV operations should coerce between \code{"rip"} and
  \code{cv::Mat} objects (in C++ code) as appropriate.
  
}

\examples{

v <- as.rip(t(volcano), channel = 1)
v
class(v)
image(v)
plot(v)

}
\author{
  Deepayan Sarkar
}
