function buildInverseTransform (options) {
  // X and Y Offset in Slide Coordinate System
  if (!('offset' in options)) {
    throw new Error('Option "offset" is required.')
  }
  if (!Array.isArray(options.offset)) {
    throw new Error('Option "offset" must be an array.')
  }
  if (options.offset.length !== 2) {
    throw new Error('Option "offset" must be an array with 2 elements.')
  }

  // Image Orientation Slide with direction cosines for Row and Column direction
  if (!('orientation' in options)) {
    throw new Error('Option "orientation" is required.')
  }
  if (!Array.isArray(options.orientation)) {
    throw new Error('Option "orientation" must be an array.')
  }
  if (options.orientation.length !== 6) {
    throw new Error('Option "orientation" must be an array with 6 elements.')
  }

  // Pixel Spacing along the Row and Column direction
  if (!('spacing' in options)) {
    throw new Error('Option "spacing" is required.')
  }
  if (!Array.isArray(options.spacing)) {
    throw new Error('Option "spacing" must be an array.')
  }
  if (options.spacing.length !== 2) {
    throw new Error('Option "spacing" must be an array with 2 elements.')
  }

  const orientation = options.orientation
  const offset = options.offset
  const spacing = options.spacing
  const m = [
    [orientation[0] * spacing[1], orientation[3] * spacing[0], offset[0]],
    [orientation[1] * spacing[1], orientation[4] * spacing[0], offset[1]],
    [0, 0, 1]
  ]
  return inv(m)
}
/**
 * Builds an affine transformation matrix to map coordinates in the slide
 * coordinate system into the Total Pixel Matrix.
 *
 * @param {number[]} options.offset - X and Y offset of the image in the slide coordinate system
 * @param {number[]} options.orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
 * @param {number[]} options.spacing - Spacing between pixel rows and columns of the Total Pixel Matrix
 * @returns {number[][]} 3x3 affine transformation matrix
 */
Builds an affine transformation matrix to map coordinates in the slide
coordinate system into the Total Pixel Matrix.

@param {number[]} options.offset - X and Y offset of the image in the slide coordinate system
@param {number[]} options.orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
@param {number[]} options.spacing - Spacing between pixel rows and columns of the Total Pixel Matrix
@returns {number[][]} 3x3 affine transformation matrix
Builds an affine transformation matrix to map coordinates in the slide coordinate system into the Total Pixel Matrix . @param { number [] } options . offset - X and Y offset of the image in the slide coordinate system @param { number [] } options . orientation - Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system @param { number [] } options . spacing - Spacing between pixel rows and columns of the Total Pixel Matrix @returns { number [] [] } 3x3 affine transformation matrix
function buildInverseTransform (options) {
  if (!('offset' in options)) {
    throw new Error('Option "offset" is required.')
  }
  if (!Array.isArray(options.offset)) {
    throw new Error('Option "offset" must be an array.')
  }
  if (options.offset.length !== 2) {
    throw new Error('Option "offset" must be an array with 2 elements.')
  }
  if (!('orientation' in options)) {
    throw new Error('Option "orientation" is required.')
  }
  if (!Array.isArray(options.orientation)) {
    throw new Error('Option "orientation" must be an array.')
  }
  if (options.orientation.length !== 6) {
    throw new Error('Option "orientation" must be an array with 6 elements.')
  }
  if (!('spacing' in options)) {
    throw new Error('Option "spacing" is required.')
  }
  if (!Array.isArray(options.spacing)) {
    throw new Error('Option "spacing" must be an array.')
  }
  if (options.spacing.length !== 2) {
    throw new Error('Option "spacing" must be an array with 2 elements.')
  }
  const orientation = options.orientation
  const offset = options.offset
  const spacing = options.spacing
  const m = [
    [orientation[0] * spacing[1], orientation[3] * spacing[0], offset[0]],
    [orientation[1] * spacing[1], orientation[4] * spacing[0], offset[1]],
    [0, 0, 1]
  ]
  return inv(m)
}
function buildInverseTransform ( options ) { if ( ! ( 'offset' in options ) ) { throw new Error ( 'Option "offset" is required.' ) } if ( ! Array . isArray ( options . offset ) ) { throw new Error ( 'Option "offset" must be an array.' ) } if ( options . offset . length !== 2 ) { throw new Error ( 'Option "offset" must be an array with 2 elements.' ) } if ( ! ( 'orientation' in options ) ) { throw new Error ( 'Option "orientation" is required.' ) } if ( ! Array . isArray ( options . orientation ) ) { throw new Error ( 'Option "orientation" must be an array.' ) } if ( options . orientation . length !== 6 ) { throw new Error ( 'Option "orientation" must be an array with 6 elements.' ) } if ( ! ( 'spacing' in options ) ) { throw new Error ( 'Option "spacing" is required.' ) } if ( ! Array . isArray ( options . spacing ) ) { throw new Error ( 'Option "spacing" must be an array.' ) } if ( options . spacing . length !== 2 ) { throw new Error ( 'Option "spacing" must be an array with 2 elements.' ) } const orientation = options . orientation const offset = options . offset const spacing = options . spacing const m = [ [ orientation [ 0 ] * spacing [ 1 ] , orientation [ 3 ] * spacing [ 0 ] , offset [ 0 ] ] , [ orientation [ 1 ] * spacing [ 1 ] , orientation [ 4 ] * spacing [ 0 ] , offset [ 1 ] ] , [ 0 , 0 , 1 ] ] return inv ( m ) }
Builds an affine transformation matrix to map coordinates in the slide
 coordinate system into the Total Pixel Matrix.
Builds an affine transformation matrix to map coordinates in the slide coordinate system into the Total Pixel Matrix .
// X and Y Offset in Slide Coordinate System // Image Orientation Slide with direction cosines for Row and Column direction // Pixel Spacing along the Row and Column direction