owin                package:spatstat                R Documentation

_C_r_e_a_t_e _a _W_i_n_d_o_w

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

     Creates an object of class `"owin"' representing  an observation
     window in the two-dimensional plane

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

      owin()
      owin(xrange, yrange)
      owin(poly=xy)
      owin(xrange, yrange, poly=xy)
      owin(xrange, yrange, mask=mat)
      owin(mask=mat)

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

  xrange: x coordinate limits of enclosing box

  yrange: y coordinate limits of enclosing box

    poly: polygonal boundary of window

    mask: logical matrix giving binary image of window

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

     In the `spatstat' library, a point pattern dataset must include
     information about the window of observation. This is represented
     by an object of class `"owin"'. See `owin.object' for an overview.

     To create a window in its own right,  users would normally invoke
     `owin', although sometimes `as.owin' may be convenient.

     A window may be rectangular, polygonal, or a mask (a binary
     image).

        *  rectangular windows: If only `xrange' and `yrange' are
           given, then the window will be rectangular, with its x and y
           coordinate dimensions given by these two arguments (which
           must be vectors of length 2). If no arguments are given at
           all, the default is the unit square with dimensions
           `xrange=c(0,1)' and `yrange=c(0,1)'.

        *  polygonal windows: If `poly' is given, then the window will
           be polygonal.

           *  single polygon: If `poly' is a structure with two
              component vectors `x' and `y' of equal length, then these
              vectors are interpreted as the cartesian coordinates of
              the vertices of a polygon circumscribing the window. The
              vertices must be listed anticlockwise. No vertex should
              be repeated (i.e. do not repeat the first vertex).

           *  multiple polygons or holes: If `poly' is a list, each
              entry `poly[[i]]' of which is a structure with two
              component vectors `x' and `y' of equal length, then the
              successive list members `poly[[i]]' are interpreted as
              separate polygons which together make up the boundary of
              the window. The vertices of each polygon must be listed
              anticlockwise if the polygon is part of the external
              boundary, but clockwise if the polygon is the boundary of
              a hole in the window. Again, do not repeat any vertex.

        *  binary masks: If `mask' is given, then the window will be a
           binary image. The argument `mask' should be a logical matrix
           such that `mask[i,j]' is `TRUE' if the point `(x[j],y[i])'
           belongs to the window, and `FALSE' if it does not. Note
           carefully that rows of `mask' correspond to the y
           coordinate, and columns to the x coordinate. Here `x' and
           `y' are vectors of x and y coordinates equally spaced over
           `xrange' and `yrange' respectively. 

_V_a_l_u_e:

     An object of class `"owin"'  describing a window in the
     two-dimensional plane.

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

     Adrian Baddeley adrian@maths.uwa.edu.au <URL:
     http://www.maths.uwa.edu.au/~adrian/> and Rolf Turner
     rolf@math.unb.ca <URL: http://www.math.unb.ca/~rolf>

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

     `owin.object', `as.owin', `complement.owin', `ppp.object', `ppp'

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

       library(spatstat)

       w <- owin()
       w <- owin(c(0,1), c(0,1))
       # the unit square

       w <- owin(c(10,20), c(10,30))
       # a rectangle of dimensions 10 x 20 units
       # with lower left corner at (10,10)

       w <- owin(poly=list(x=c(0.5,1,0.5,0),y=c(0,1,2,1)))
       w <- owin(c(0,1), c(0,2), poly=list(x=c(0.5,1,0.5,0),y=c(0,1,2,1)))
       # diamond shape

       w <- owin(c(0,1), c(0,1), mask=matrix(T, 100,100))
               # 100 x 100 image, all TRUE
       X <- raster.x(w)
       Y <- raster.y(w)
       wm <- owin(w$xrange, w$yrange, mask=((X - 0.5)^2 + (Y - 0.5)^2 <= 1))
               # discrete approximation to the unit disc


       plot(c(0,1),c(0,1),type="n")
       bdry <- locator()
       # click the vertices of a polygon (anticlockwise)


       w <- owin(poly=bdry)
       plot(w)


      im <- as.logical(matrix(scan("myfile"), nrow=128, ncol=128))
      # read in an arbitrary 128 x 128 digital image from text file
      rim <- im[, 128:1]
      # Assuming it was given in row-major order in the file
      # i.e. scanning left-to-right in rows from top-to-bottom,
      # the use of matrix() has effectively transposed rows & columns,
      # so to convert it to our format just reverse the column order.
      w <- owin(mask=rim)
      plot(w)
      # display it to check!


