# Namespace: utils

## utils

Namespace for various utilities.

Source:
  - dicom-microscopy-viewer.js, line 168

### Methods

#### (static) applyInverseTransform(options) → {Array.<number>}

Apply an affine transformation to a reference coordinate in the slide coordinate system to map it into the total pixel matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | Options ###### Properties
Name | Type | Description
--- | --- | ---
`coordinate` | Array.<number> | (x, y) reference coordinate
`affine` | Array.<Array.<number>> | 3x3 affine transformation matrix

Source:
  - utils.js, line 308

##### Returns:

(column, row) image coordinate

Type
  Array.<number>

#### (static) applyTransform(options) → {Array.<number>}

Apply an affine transformation to an image coordinate in the total pixel matrix to map it into the slide coordinate system.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | Options ###### Properties
Name | Type | Description
--- | --- | ---
`coordinate` | Array.<number> | (column, row) image coordinate
`affine` | Array.<Array.<number>> | 3x3 affine transformation matrix

Source:
  - utils.js, line 201

##### Returns:

(x, y) reference coordinate

Type
  Array.<number>

#### (static) are1DArraysAlmostEqual(array, array, eps) → {boolean}

Check if 1D arrays are equal.

##### Parameters:

Name | Type | Description
--- | --- | ---
`array` | Array.<number> | a
`array` | Array.<number> | b
`eps` | number |

Source:
  - utils.js, line 448

##### Returns:

yes/no answer

Type
  boolean

#### (static) are2DArraysAlmostEqual(array, array, eps) → {boolean}

Check if 2D arrays are equal.

##### Parameters:

Name | Type | Description
--- | --- | ---
`array` | Array.<number> | a
`array` | Array.<number> | b
`eps` | number |

Source:
  - utils.js, line 421

##### Returns:

yes/no answer

Type
  boolean

#### (static) areCodedConceptsEqual(codedConcept1, codedConcept2) → {boolean}

Check whether coded concepts are equal.

##### Parameters:

Name | Type | Description
--- | --- | ---
`codedConcept1` | object |
`codedConcept2` | object |

Source:
  - utils.js, line 545

##### Returns:

yes/no answer

Type
  boolean

#### (static) areNumbersAlmostEqual(a, b, eps) → {boolean}

Check if two numbers are equal.

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`a` | number |  |
`b` | number |  |
`eps` | number | 0.000001 |

Source:
  - utils.js, line 471

##### Returns:

yes/no answer

Type
  boolean

#### (static) buildInverseTransform() → {Array.<Array.<number>>}

Build an affine transformation matrix to map coordinates in the slide coordinate system into the Total Pixel Matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options.offset` | Array.<number> | X and Y offset of the image in the slide coordinate system
`options.orientation` | Array.<number> | Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
`options.spacing` | Array.<number> | Spacing between pixel rows and columns of the Total Pixel Matrix

Source:
  - utils.js, line 249

##### Returns:

3x3 affine transformation matrix

Type
  Array.<Array.<number>>

#### (static) buildTransform(options) → {Array.<Array.<number>>}

Build an affine transformation matrix to map coordinates in the Total Pixel Matrix into the slide coordinate system.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | Options ###### Properties
Name | Type | Description
--- | --- | ---
`offset` | Array.<number> | X and Y offset of the image in the slide coordinate system
`orientation` | Array.<number> | Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
`spacing` | Array.<number> | Spacing between pixel rows and columns of the Total Pixel Matrix

Source:
  - utils.js, line 142

##### Returns:

3x3 affine transformation matrix

Type
  Array.<Array.<number>>

#### (static) computeRotation(options) → {number}

Computes the rotation of the image with respect to the frame of reference.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | Options ###### Properties
Name | Type | Description
--- | --- | ---
`orientation` | Array.<number> | Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
`inDegrees` | boolean | Whether angle should be returned in degrees instead of radians

Source:
  - utils.js, line 115

##### Returns:

Angle

Type
  number

#### (static) createRotationMatrix(options) → {Array.<Array.<number>>}

Create a rotation matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | Options ###### Properties
Name | Type | Description
--- | --- | ---
`orientation` | Array.<number> | Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system

Source:
  - utils.js, line 47

##### Returns:

2x2 rotation matrix

Type
  Array.<Array.<number>>

#### (static) createWindow(lowerBound, upperBound) → {Array.<number>}

Create window.

##### Parameters:

Name | Type | Description
--- | --- | ---
`lowerBound` | number | Lower bound of the window
`upperBound` | number | Upper bound of the window

Source:
  - utils.js, line 98

##### Returns:

Window center and width

Type
  Array.<number>

#### (static) doContentItemsMatch(contentItem1, contentItem2) → {boolean}

Check wether two content items match.

##### Parameters:

Name | Type | Description
--- | --- | ---
`contentItem1` | object |
`contentItem2` | object |

Source:
  - utils.js, line 574

##### Returns:

yes/no answer

Type
  boolean

#### (static) getContentItemNameCodedConcept(contentItem) → {object}

Get name coded concept from content item.

##### Parameters:

Name | Type | Description
--- | --- | ---
`contentItem` | object |

Source:
  - utils.js, line 532

##### Returns:

The concept name coded concept

Type
  object

#### (static) mapPixelCoordToSlideCoord(options) → {Array.<number>}

Map 2D (column, row) image coordinates in the Total Pixel Matrix to 3D (x, y, z) slide coordinates in the Frame of Reference.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | Options ###### Properties
Name | Type | Description
--- | --- | ---
`offset` | Array.<number> | X and Y offset in the slide coordinate system
`orientation` | Array.<number> | Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
`spacing` | Array.<number> | Spacing between pixels along the Column and Row direction of the Total Pixel Matrix
`point` | Array.<number> | (colum, row) image coordinates

Source:
  - utils.js, line 358

##### Returns:

(x, y, z) slide coordinates

Type
  Array.<number>

#### (static) mapSlideCoordToPixelCoord(options) → {Array.<number>}

Map 3D (x, y, z) slide coordinates in the Frame of Reference to 2D (column, row) image coordinates in the Total Pixel Matrix.

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | Options ###### Properties
Name | Type | Description
--- | --- | ---
`offset` | Array.<number> | X and Y offset in the slide coordinate system
`orientation` | Array.<number> | Direction cosines along the row and column direction of the Total Pixel Matrix for each of the three axis of the slide coordinate system
`spacing` | Array.<number> | Spacing between pixels along the Column and Row direction of the Total Pixel Matrix
`point` | Array.<number> | (x, y, z) slide coordinates

Source:
  - utils.js, line 391

##### Returns:

(row, column) image coordinates

Type
  Array.<number>

#### (static) rescale(value, minInput, maxInput, minOutput, maxOutput) → {number}

Rescale intensity from [minInput, maxInput] to [minOutput, maxOutput].

##### Parameters:

Name | Type | Description
--- | --- | ---
`value` | number | Input value that should be rescaled
`minInput` | number | Lower bound of the full input value range
`maxInput` | number | Upper bound of the full input value range
`minOutput` | number | Lower bound of the full output value range
`maxOutput` | number | Upper bound of the full output value range

Source:
  - utils.js, line 74

##### Returns:

Rescaled value

Type
  number