pixmap                package:pixmap                R Documentation

_P_i_x_m_a_p _I_m_a_g_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     The family '"pixmap"' (``pixel maps'') of classes provides methods
     for creating, plotting and converting bitmapped images in three
     different formats: RGB, grey and indexed pixmaps.

_U_s_a_g_e:

     pixmap(data=NULL, nrow=dim(data)[1], ncol=dim(data)[2],
            bbox=NULL, bbcent=FALSE, cellres=NULL)
     pixmapRGB(data, ...)
     pixmapGrey(data, ...)
     pixmapIndexed(data, col, ...)

_A_r_g_u_m_e_n_t_s:

    data: An optional data vector.

    nrow: Vertical size of the image in pixels.

    ncol: Horizontal size of the image in pixels.

    bbox: Bounding box of the image, vector of length 4 of form 'c(x1,
          y1, x2, y2)' with coordinates for the lower left corner and
          upper right corner.

  bbcent: Logical, if 'TRUE' the bounding box specifies the coordinates
          of the centers of the lower left and upper right pixels,
          default is the coordinates of the lower left and upper right
          corner of the image.

 cellres: Numeric vector of length 1 or 2, specifies the resolution of
          pixels in horizontal and vertical direction. If only one
          value is given, resolution in both directions is identical.

     col: Character vector of colors to use for indexed pictures, or a
          function like 'rainbow' which can be used to create a
          palette.

     ...: Additional arguments passed to 'pixmap()'.

_D_e_t_a_i_l_s:

     If the 'data' argument is 2- or 3-dimensional, 'nrow' and 'ncol'
     default to the first two dimensions of 'data', such that 'pixmap'
     does the expected when given a matrix or an array.

     The arguments 'bbox', 'bbcent' and 'cellres' can be used to
     specify a coordinate system for the image. Note that together with
     'nrow' and 'ncol' the coordinate system is overspecified, hence
     not all parameters must be specified, the rest is computed or set
     to sensible defaults.

     For 'bbcent=FALSE' we have 'cellres[1] = (bbox[3]-bbox[1])/ncol'
     and 'cellres[2] = (bbox[4]-bbox[2])/nrow', for  'bbcent=TRUE' we
     get 'cellres[1] = (bbox[3]-bbox[1])/(ncol-1)' and 'cellres[2] =
     (bbox[4]-bbox[2])/(nrow-1)'.

     The name 'pixmap' was chosen because both 'image' and 'bitmap' are
     already used in R.

_A_u_t_h_o_r(_s):

     Friedrich Leisch

_S_e_e _A_l_s_o:

     'pixmap-class', 'read.pnm'

_E_x_a_m_p_l_e_s:

      ## A simple example
      x <- pixmapIndexed(rep(1:8, 9), nrow=6, col=terrain.colors(8))
      plot(x)

      ## The same with different colors, and passing the function instead of
      ## a color vector 
      x <- pixmapIndexed(rep(1:8, 9), nrow=6, col=rainbow)
      plot(x)
      plot(x, asp=.5, axes=TRUE)

      ## Read data from a file
      x <- read.pnm(system.file("pictures/logo.ppm", package="pixmap")[1])
      plot(x)

      ## Another example that math can be beautiful
      x <- seq(-3,3,length=100)
      z1 <- outer(x,x,function(x,y) abs(sin(x)*sin(y)))
      z2 <- outer(x,x,function(x,y) abs(sin(2*x)*sin(y)))
      z3 <- outer(x,x,function(x,y) abs(sin(x)*sin(2*y)))

      ## Notice that we specify a bounding box to get the correct
      ## coordinates on the axes. z1, z2 and z3 are used as red,
      ## green and blue channel, respectively.
      z <- pixmapRGB(c(z1,z2,z3), 100, 100, bbox=c(-1,-1,1,1))
      plot(z, axes=TRUE)

      ## look at a grey version
      plot(as(z, "pixmapGrey"))

      ## subsetting works as expected
      plot(z[1:20,])
      plot(z[,1:40])
      plot(z[1:20,10:40])

