new Imagebox3(imageSource, numWorkersopt)
Create an Imagebox3 instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
imageSource |
File | string | (Required) The local File object or the remote URL referencing the TIFF file. | |
numWorkers |
number |
<optional> |
The number of web workers to be used to to decode image tiles. Defaults to 0, meaning all decoding operations are performed on the main thread. |
- Source:
Methods
(async) changeImageSource(newImageSource) → {Promise}
Switch image sources without destroying the Imagebox3 instance. Recommended when a new image needs to be loaded instead of
re-instantiating Imagebox3, so as to avoid spawning a new worker pool. Await the fulfilment of the returned Promise
before running further operations.
Parameters:
Name | Type | Description |
---|---|---|
newImageSource |
File | string | The local File object or the remote URL referencing the new TIFF file. |
- Source:
Returns:
- Type
- Promise
(async) createWorkerPool(numWorkers) → {Object}
Create a new pool of web workers to be used for decoding image tiles based on the supported decoders. Highly recommended if retrieving
multiple patches parallelly. Destroys all previously created Imagebox3 worker pools before creating a new one.
Parameters:
Name | Type | Description |
---|---|---|
numWorkers |
number | The number of web workers in the decoder pool. Defaults to 0, meaning all operations will be performed on the main thread. |
- Source:
Returns:
- Type
- Object
destroyWorkerPool()
Destroy the current pool of web workers. Highly recommended if re-instantiating Imagebox3 to avoid zombie web workers
from slowing down the client, since web workers are not destroyed even if their initiator is garbage-colleged.
- Source:
getImageCount() → {number}
Retrieve the number of images in the TIFF image pyramid.
- Source:
Returns:
- Type
- number
getImageSource() → {File|string}
Retrieve the image source to the TIFF file that the current Imagebox3 instance is using.
- Source:
Returns:
- The local File object or the remote URL referencing the TIFF file.
- Type
- File | string
(async) getInfo() → {Object}
Retrieve basic information about the largest image in the TIFF. Currently returns the image width and height,
and the pixels per micron corresponding to the slide.
- Source:
Returns:
- Type
- Object
getPyramid() → {Object}
Retrieve the TIFF metadata obejct containing information about the image pyramid.
- Source:
Returns:
- Type
- Object
(async) getSupportedDecoders() → {Array.<string>}
Get the compression scheme identifiers (as specified in the TIFF format specification) that Imagebox3 can decode.
JPEG/LZW/Deflate/WebP are automatically supported, along with JPEG-2000 which is added as an external decoder
if the image needs it.
- Source:
Returns:
- Type
- Array.<string>
(async) getThumbnail(thumbnailWidth, thumbnailHeight) → {Blob}
Retrieve a thumbnail representation of the whole slide image from the TIFF.
Parameters:
Name | Type | Description |
---|---|---|
thumbnailWidth |
number | The width of the thumbnail image to be returned. |
thumbnailHeight |
number | The height of the thumbnail image to be returned. |
- Source:
Returns:
- Type
- Blob
(async) getTile(topLeftX, topLeftY, tileWidthInImage, tileHeightInImage, tileResolutionToRender, imageIndexopt) → {Blob}
Retrieve a single tile from the whole slide corresponding to the bounding box formed by the parameters and at the specified resolution. The bounding box
should always be parameterized as per the largest image representation in the TIFF pyramid. By default, the optimal image from which to retrieve
the tile is estimated heuristically, based on the size of the bounding box and the requested resolution.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
topLeftX |
number | The X coordinate of the top-left corner of the bounding box for the tile to be retrieved. | |
topLeftY |
number | The Y coordinate of the top-left corner of the bounding box for the tile to be retrieved. | |
tileWidthInImage |
number | The width of the bounding box for the tile. | |
tileHeightInImage |
number | The height of the bounding box for the tile. | |
tileResolutionToRender |
number | The resolution in which the tile should be returned. | |
imageIndex |
number |
<optional> |
The index of the image in the pyramid to be specifically used to retrieve the tile. |
- Source:
Returns:
- Type
- Blob
(async) init() → {Promise}
Initialize the created Imagebox3 instance by retrieving all Image File Directory metadata from the TIFF file.
This function needs to be called after instantiation. Any operations should be performed only after the returned Promise is fulfilled.
- Source:
Returns:
- Type
- Promise