function coordinateFormatScoord3d2Geometry (coordinates, pyramid) {
  let transform = false
  if (!Array.isArray(coordinates[0])) {
    coordinates = [coordinates]
    transform = true
  }
  const metadata = pyramid[pyramid.length - 1]
  const orientation = metadata.ImageOrientationSlide
  const spacing = getPixelSpacing(metadata)
  const origin = metadata.TotalPixelMatrixOriginSequence[0]
  const offset = [
    Number(origin.XOffsetInSlideCoordinateSystem),
    Number(origin.YOffsetInSlideCoordinateSystem)
  ]

  let outOfFrame = false
  const affine = buildInverseTransform({
    offset,
    orientation,
    spacing
  })
  coordinates = coordinates.map((c) => {
    if (c[0] > 25 || c[1] > 76) {
      outOfFrame = true
    }
    const slideCoord = [c[0], c[1]]
    const pixelCoord = applyInverseTransform({
      coordinate: slideCoord,
      affine
    })
    return [pixelCoord[0], -(pixelCoord[1] + 1), 0]
  })
  if (transform) {
    return coordinates[0]
  }
  if (outOfFrame) {
    console.warning(
      'found coordinates outside slide coordinate system 25 x 76 mm'
    )
  }
  return coordinates
}
/**
 * Translates coordinates of coordinates in Frame of Reference
 * (slide coordinate system) in millimeter unit into coordinates in
 * Total Pixel Matrix in pixel unit.
 *
 * @param {number[]|number[][]} coordinates - Coordinates in Frame of Reference
 * @param {Object[]} pyramid - Metadata for resolution levels of image pyramid
 * @returns {number[]|number[][]} Coordinates in Total Pixel Matrix
 * @private
 */
Translates coordinates of coordinates in Frame of Reference
(slide coordinate system) in millimeter unit into coordinates in
Total Pixel Matrix in pixel unit.


Translates coordinates of coordinates in Frame of Reference ( slide coordinate system ) in millimeter unit into coordinates in Total Pixel Matrix in pixel unit .
function coordinateFormatScoord3d2Geometry (coordinates, pyramid) {
  let transform = false
  if (!Array.isArray(coordinates[0])) {
    coordinates = [coordinates]
    transform = true
  }
  const metadata = pyramid[pyramid.length - 1]
  const orientation = metadata.ImageOrientationSlide
  const spacing = getPixelSpacing(metadata)
  const origin = metadata.TotalPixelMatrixOriginSequence[0]
  const offset = [
    Number(origin.XOffsetInSlideCoordinateSystem),
    Number(origin.YOffsetInSlideCoordinateSystem)
  ]
  let outOfFrame = false
  const affine = buildInverseTransform({
    offset,
    orientation,
    spacing
  })
  coordinates = coordinates.map((c) => {
    if (c[0] > 25 || c[1] > 76) {
      outOfFrame = true
    }
    const slideCoord = [c[0], c[1]]
    const pixelCoord = applyInverseTransform({
      coordinate: slideCoord,
      affine
    })
    return [pixelCoord[0], -(pixelCoord[1] + 1), 0]
  })
  if (transform) {
    return coordinates[0]
  }
  if (outOfFrame) {
    console.warning(
      'found coordinates outside slide coordinate system 25 x 76 mm'
    )
  }
  return coordinates
}
function coordinateFormatScoord3d2Geometry ( coordinates , pyramid ) { let transform = false if ( ! Array . isArray ( coordinates [ 0 ] ) ) { coordinates = [ coordinates ] transform = true } const metadata = pyramid [ pyramid . length - 1 ] const orientation = metadata . ImageOrientationSlide const spacing = getPixelSpacing ( metadata ) const origin = metadata . TotalPixelMatrixOriginSequence [ 0 ] const offset = [ Number ( origin . XOffsetInSlideCoordinateSystem ) , Number ( origin . YOffsetInSlideCoordinateSystem ) ] let outOfFrame = false const affine = buildInverseTransform ( { offset , orientation , spacing } ) coordinates = coordinates . map ( ( c ) => { if ( c [ 0 ] > 25 || c [ 1 ] > 76 ) { outOfFrame = true } const slideCoord = [ c [ 0 ] , c [ 1 ] ] const pixelCoord = applyInverseTransform ( { coordinate : slideCoord , affine } ) return [ pixelCoord [ 0 ] , - ( pixelCoord [ 1 ] + 1 ) , 0 ] } ) if ( transform ) { return coordinates [ 0 ] } if ( outOfFrame ) { console . warning ( 'found coordinates outside slide coordinate system 25 x 76 mm' ) } return coordinates }
Translates coordinates of coordinates in Frame of Reference
 (slide coordinate system) in millimeter unit into coordinates in
 Total Pixel Matrix in pixel unit.
Translates coordinates of coordinates in Frame of Reference ( slide coordinate system ) in millimeter unit into coordinates in Total Pixel Matrix in pixel unit .