This function computes a set of quadrature weights
  for a given pattern of points
  (typically comprising both ``data'' and `dummy'' points).
  See quad.object for an explanation of quadrature
  weights and quadrature schemes.
The weights are computed by the ``counting weights'' rule
  based on a regular grid of rectangular tiles.
  First X and (optionally) window are converted into a
  point pattern object. Then the bounding rectangle of the window of
  the point pattern is
  divided into a regular ntile[1] * ntile[2] grid of rectangular tiles.
  The weight attached to a point of X is the area of the tile
  in which it lies, divided by the number of points of X lying in
  that tile.
For non-rectangular windows the tile areas are currently calculated
  by approximating the window as a binary mask. The accuracy of this
  approximation is controlled by npix, which becomes
  the argument dimyx of as.mask.