# Cornerstone core API
TIP
Generated by documentation.js.
# Table of Contents
- Objects
- EnabledElements
- ImageLoader
- ImageCache
- Metadata
- EnabledElementLayers
- Internal
- guid
- drawImage
- drawImageSync
- renderLayers
- getImageFitScale
- generateLut
- getDefaultViewport
- createDefaultDisplayedArea
- createViewport
- generateLinearModalityLUT
- getModalityLUT
- storedPixelDataToCanvasImageDataRGBA
- generateColorLut
- storedRGBAPixelDataToCanvasImageData
- computeAutoVoi
- hasVoi
- isRotated
- getImageSize
- calculateTransform
- storedColorPixelDataToCanvasImageData
- storedPixelDataToCanvasImageData
- storedPixelDataToCanvasImageDataColorLUT
- storedPixelDataToCanvasImageDataPseudocolorLUT
- rendering
- getLut
- getLut
- getRenderCanvas
- getRenderCanvas
- getRenderCanvas
- getRenderCanvas
- renderColorImage
- doesImageNeedToBeRendered
- initializeRenderCanvas
- saveLastRendered
- renderGrayscaleImage
- lutMatches
- renderLabelMapImage
- renderPseudoColorImage
- EnabledElementStub
- createEnabledElementStub
- renderToCanvas
- renderWebImage
- WebGLRendering
- Polyfills
- purgeLayers
- getPixelValues
- getRestoreImageMethod
- ensuresColormap
- restoreImage
- convertImageToFalseColorImage
- convertToFalseColorImage
- linspace
- getRank
- searchSorted
- makeMappingArray
- createLinearSegmentedColormap
- getColormapsList
- getColormap
- linearIndexLookupMain
- setNumberOfTableValues
- setRamp
- setTableRange
- setHueRange
- setSaturationRange
- setValueRange
- setRange
- setAlphaRange
- getColor
- build
- buildSpecialColors
- mapValue
- getIndex
- setTableValue
- getElementData
- removeElementData
- canvasToPixel
- pixelToCanvas
- HSVToRGB
- LookupTable
- disable
- hasImageOrLayers
- enable
- displayImage
- draw
- draw
- drawInvalidated
- invalidate
- invalidateImageId
- updateImage
- getEnabledElements
- hasImageOrLayers
- drawCompositeImage
- tryEnableWebgl
- generateUUID
- createCanvas
- getCanvas
- fitToWindow
- validateParameterUndefined
- validateParameterUndefinedOrNull
- generateLinearVOILUT
- generateLinearVOILUT
- generateNonLinearVOILUT
- getVOILut
- getDefaultViewportForImage
- getImage
- getPixels
- getStoredPixels
- getViewport
- setViewport
- setMaximumSizeBytes
- purgeCacheIfNecessary
- putImageLoadObject
- getImageLoadObject
- removeImageLoadObject
- CacheInformation
- getCacheInfo
- decache
- purgeCache
- changeImageIdCacheSize
- pageToPixel
- pixelDataToFalseColorData
- addGrayscaleLayer
- addLabelMapLayer
- addPseudoColorLayer
- reset
- setCanvasSize
- wasFitToWindow
- relativeRescale
- resize
- setDefaultViewport
- setToPixelCoordinateSystem
- triggerEvent
- WebGLTextureCache
# Objects
# vec2
A two-dimensional vector
Type: Object (opens new window)
# Parameters
x
Number (opens new window) The x distancey
Number (opens new window) The y distance
# VOI
VOI
Type: Object (opens new window)
# Parameters
windowWidth
Number (opens new window) Window Width for displaywindowCenter
Number (opens new window) Window Center for display
# LUT
Lookup Table Array
Type: Object (opens new window)
# Properties
firstValueMapped
Number (opens new window)numBitsPerEntry
Number (opens new window)lut
Array (opens new window)
# ImageStats
Image Statistics Object
Type: Object (opens new window)
# Properties
lastGetPixelDataTime
Number (opens new window)? The time in ms taken to retrieve stored pixels required to draw the imagelastStoredPixelDataToCanvasImageDataTime
Number (opens new window)? The time in ms taken to map from stored pixel array to canvas pixel arraylastPutImageDataTime
Number (opens new window)? The time in ms taken for putImageData to put the canvas pixel data into the canvas contextlastRenderTime
Number (opens new window)? The total time in ms taken for the entire rendering function to runlastLutGenerateTime
Number (opens new window)? The time in ms taken to generate the lookup table for the image
# Image
An Image Object in Cornerstone
Type: Object (opens new window)
# Properties
imageId
string (opens new window) The imageId associated with this image objectminPixelValue
Number (opens new window) the minimum stored pixel value in the imagemaxPixelValue
Number (opens new window) the maximum stored pixel value in the imageslope
Number (opens new window) the rescale slope to convert stored pixel values to modality pixel values or 1 if not specifiedintercept
Number (opens new window) the rescale intercept used to convert stored pixel values to modality values or 0 if not specifiedwindowCenter
Number (opens new window) the default windowCenter to apply to the imagewindowWidth
Number (opens new window) the default windowWidth to apply to the imagegetPixelData
function (opens new window) a function that returns the underlying pixel data. An array of integers for grayscale and an array of RGBA for colorgetImageData
function (opens new window) a function that returns a canvas imageData object for the image. This is only needed for color imagesgetCanvas
function (opens new window) a function that returns a canvas element with the image loaded into it. This is only needed for color images.getImage
function (opens new window) a function that returns a JavaScript Image object with the image data. This is optional and typically used for images encoded in standard web JPEG and PNG formatsrows
Number (opens new window) number of rows in the image. This is the same as height but duplicated for conveniencecolumns
Number (opens new window) number of columns in the image. This is the same as width but duplicated for convenienceheight
Number (opens new window) the height of the image. This is the same as rows but duplicated for conveniencewidth
Number (opens new window) the width of the image. This is the same as columns but duplicated for conveniencecolor
Boolean (opens new window) true if pixel data is RGB, false if grayscalelut
Object (opens new window) The Lookup Tablergba
Boolean (opens new window) Is the color pixel data stored in RGBA?columnPixelSpacing
Number (opens new window) horizontal distance between the middle of each pixel (or width of each pixel) in mm or undefined if not knownrowPixelSpacing
Number (opens new window) vertical distance between the middle of each pixel (or height of each pixel) in mm or undefined if not knowninvert
Boolean (opens new window) true if the the image should initially be displayed be inverted, false if not. This is here mainly to support DICOM images with a photometric interpretation of MONOCHROME1sizeInBytes
Number (opens new window) the number of bytes used to store the pixels for this image.falseColor
Boolean (opens new window)? Whether or not the image has undergone false color mappingorigPixelData
Array (opens new window)? Original pixel data for an image after it has undergone false color mappingstats
ImageStats? Statistics for the last redraw of the imagecachedLut
Object (opens new window) Cached Lookup Table for this image.colormap
(String (opens new window) | Colormap)? Depreacted. Use viewport.colormap instead. an optional colormap ID or colormap object (from colors/colormap.js). This will be applied during rendering to convert the image to pseudocolorlabelmap
Boolean (opens new window)? whether or not to render this image as a label map (i.e. skip modality and VOI LUT pipelines and use only a color lookup table)
# Viewport
A Viewport Settings Object Cornerstone
Type: Object (opens new window)
# Properties
scale
Number (opens new window)? The scale applied to the image. A scale of 1.0 will display no zoom (one image pixel takes up one screen pixel). A scale of 2.0 will be double zoom and a scale of .5 will be zoomed out by 2xtranslation
vec2? An object with properties x and y which describe the translation to apply in the pixel coordinate system. Note that the image is initially displayed centered in the enabled element with a x and y translation of 0 and 0 respectively.voi
VOI? an object with properties windowWidth and windowCenter.invert
boolean (opens new window)? Whether or not the image is inverted.pixelReplication
boolean (opens new window)? true if the image smooth / interpolation should be used when zoomed in on the image or false if pixel replication should be used.hflip
boolean (opens new window)? true if the image is flipped horizontally. Default is falsevflip
boolean (opens new window)? true if the image is flipped vertically. Default is falserotation
Number (opens new window)? the rotation of the image (90 degree increments). Default is 0modalityLUT
LUT? the modality LUT to apply or undefined if nonevoiLUT
LUT? the modality LUT to apply or undefined if nonecolormap
(String (opens new window) | Colormap)? an optional colormap ID or colormap object (from colors/colormap.js). This will be applied during rendering to convert the image to pseudocolorlabelmap
Boolean (opens new window)? whether or not to render this image as a label map (i.e. skip modality and VOI LUT pipelines and use only a color lookup table)
# EnabledElement
An Enabled Element in Cornerstone
Type: Object (opens new window)
# Properties
element
HTMLElement (opens new window) The DOM element which has been enabled for use by Cornerstoneimage
Image (opens new window)? The image currently displayed in the enabledElementviewport
Viewport? The current viewport settings of the enabledElementcanvas
HTMLCanvasElement (opens new window)? The current canvas for this enabledElementinvalid
Boolean (opens new window) Whether or not the image pixel data underlying the enabledElement has been changed, necessitating a redrawneedsRedraw
Boolean (opens new window) A flag for triggering a redraw of the canvas without re-retrieving the pixel data, since it remains validlayers
Array (opens new window)<EnabledElementLayer>? The layers that have been added to the enabledElementsyncViewports
Boolean (opens new window)? Whether or not to synchronize the viewport parameters for each of the enabled element's layerslastSyncViewportsState
Boolean (opens new window)? The previous state for the sync viewport boolean
# EnabledElementLayer
An Enabled Element Layer in Cornerstone
Type: Object (opens new window)
# Properties
element
HTMLElement (opens new window) The DOM element which has been enabled for use by Cornerstoneimage
Image (opens new window)? The image currently displayed in the enabledElementviewport
Viewport? The current viewport settings of the enabledElementcanvas
HTMLCanvasElement (opens new window)? The current canvas for this enabledElementoptions
Object (opens new window)? Layer drawing optionsinvalid
Boolean (opens new window) Whether or not the image pixel data underlying the enabledElement has been changed, necessitating a redrawneedsRedraw
Boolean (opens new window) A flag for triggering a redraw of the canvas without re-retrieving the pixel data, since it remains valid
# ImageLoadObject
An Image Load Object
Type: Object (opens new window)
# Properties
promise
Promise (opens new window) The Promise tracking the loading of this imagecancelFn
(Function (opens new window) | undefined (opens new window)) A function to cancel the image load request
# VOILUTFunction
Volume of Interest Lookup Table Function
Type: Function (opens new window)
# Parameters
modalityLutValue
Number (opens new window)
Returns Number (opens new window) transformed value
# EnabledElements
# getEnabledElement
Retrieves a Cornerstone Enabled Element object
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for Cornerstone
Returns EnabledElement A Cornerstone Enabled Element
# addEnabledElement
Adds a Cornerstone Enabled Element object to the central store of enabledElements
# Parameters
enabledElement
EnabledElement A Cornerstone enabledElement Object
Returns void
# getEnabledElementsByImageId
Adds a Cornerstone Enabled Element object to the central store of enabledElements
# Parameters
imageId
string (opens new window) A Cornerstone Image ID
Returns Array (opens new window)<EnabledElement> An Array of Cornerstone enabledElement Objects
# getEnabledElements
Retrieve all of the currently enabled Cornerstone elements
Returns Array (opens new window)<EnabledElement> An Array of Cornerstone enabledElement Objects
# ImageLoader
This module deals with ImageLoaders, loading images and caching images
# loadImageFromImageLoader
Load an image using a registered Cornerstone Image Loader.
The image loader that is used will be determined by the image loader scheme matching against the imageId.
# Parameters
imageId
String (opens new window) A Cornerstone Image Object's imageIdoptions
Object (opens new window)? Options to be passed to the Image Loader
Returns ImageLoadObject An Object which can be used to act after an image is loaded or loading fails
# loadImage
Loads an image given an imageId and optional priority and returns a promise which will resolve to the loaded image object or fail if an error occurred. The loaded image is not stored in the cache.
# Parameters
imageId
String (opens new window) A Cornerstone Image Object's imageIdoptions
Object (opens new window)? Options to be passed to the Image Loader
Returns ImageLoadObject An Object which can be used to act after an image is loaded or loading fails
# loadAndCacheImage
Loads an image given an imageId and optional priority and returns a promise which will resolve to the loaded image object or fail if an error occurred. The image is stored in the cache.
# Parameters
imageId
String (opens new window) A Cornerstone Image Object's imageIdoptions
Object (opens new window)? Options to be passed to the Image Loader
Returns ImageLoadObject Image Loader Object
# registerImageLoader
Registers an imageLoader plugin with cornerstone for the specified scheme
# Parameters
scheme
String (opens new window) The scheme to use for this image loader (e.g. 'dicomweb', 'wadouri', 'http')imageLoader
Function (opens new window) A Cornerstone Image Loader function
Returns void
# registerUnknownImageLoader
Registers a new unknownImageLoader and returns the previous one
# Parameters
imageLoader
Function (opens new window) A Cornerstone Image Loader
Returns (Function (opens new window) | Undefined (opens new window)) The previous Unknown Image Loader
# ImageCache
This module deals with caching images
# Metadata
# addProvider
Adds a metadata provider with the specified priority
# Parameters
provider
Function (opens new window) Metadata provider functionpriority
Number (opens new window) 0 is default/normal, > 0 is high, < 0 is low (optional, default0
)
Returns void
# removeProvider
Removes the specified provider
# Parameters
provider
Function (opens new window) Metadata provider function
Returns void
# getMetaData
Gets metadata from the registered metadata providers. Will call each one from highest priority to lowest until one responds
# Parameters
type
String (opens new window) The type of metadata requested from the metadata storeimageId
String (opens new window) The Cornerstone Image Object's imageId
Returns any The metadata retrieved from the metadata store
# EnabledElementLayers
# triggerEventForLayer
Helper function to trigger an event on a Cornerstone element with a specific layerId
# Parameters
eventName
String (opens new window) The event name (e.g. CornerstoneLayerAdded)enabledElement
EnabledElement The Cornerstone enabled elementlayerId
String (opens new window) The layer's unique identifier
Returns void
# rescaleImage
Rescale the target layer to the base layer based on the relative size of each image and their pixel dimensions.
This function will update the Viewport parameters of the target layer to a new scale.
# Parameters
baseLayer
EnabledElementLayer The base layertargetLayer
EnabledElementLayer The target layer to rescale
Returns void
# addLayer
Add a layer to a Cornerstone element
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstoneimage
Image (opens new window) A Cornerstone Image object to add as a new layeroptions
Object (opens new window) Options for the layer
Returns String (opens new window) layerId The new layer's unique identifier
# removeLayer
Remove a layer from a Cornerstone element given a layer ID
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for CornerstonelayerId
String (opens new window) The unique identifier for the layer
Returns void
# getLayer
Retrieve a layer from a Cornerstone element given a layer ID
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for CornerstonelayerId
String (opens new window) The unique identifier for the layer
Returns EnabledElementLayer The layer
# getLayers
Retrieve all layers for a Cornerstone element
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstone
Returns Array (opens new window)<EnabledElementLayer> An array of layers
# getVisibleLayers
Retrieve all visible layers for a Cornerstone element
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstone
Returns Array (opens new window)<EnabledElementLayer> An array of layers
# setActiveLayer
Set the active layer for a Cornerstone element
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for CornerstonelayerId
String (opens new window) The unique identifier for the layer
Returns void
# setLayerImage
Set a new image for a specific layerId
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstoneimage
Image (opens new window) The image to be displayed in this layerlayerId
String (opens new window)? The unique identifier for the layer
Returns void
# getActiveLayer
Retrieve the currently active layer for a Cornerstone element
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstone
Returns EnabledElementLayer The currently active layer
# Internal
# guid
Generate a unique identifier
Returns string (opens new window) A unique identifier
# drawImage
Internal API function to draw an image to a given enabled element
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled Element to redrawinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used (optional, defaultfalse
)
Returns void
# drawImageSync
Draw an image to a given enabled element synchronously
# Parameters
enabledElement
EnabledElement An enabled element to draw intoinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# renderLayers
Internal function to render all layers for a Cornerstone enabled element
# Parameters
context
CanvasRenderingContext2D (opens new window) Canvas context to draw uponlayers
Array (opens new window)<EnabledElementLayer> The array of all layers for this enabled elementinvalidated
Boolean (opens new window) A boolean whether or not this image has been invalidated and must be redrawn
Returns void
# getImageFitScale
Calculates the horizontal, vertical and minimum scale factor for an image
# Parameters
windowSize
{width, height} The window size where the image is displayed. This can be any HTML element or structure with a width, height fields (e.g. canvas).image
any The cornerstone image objectrotation
Number (opens new window) Optional. The rotation angle of the image. (optional, defaultnull
)
Returns {horizontalScale, verticalScale, scaleFactor} The calculated horizontal, vertical and minimum scale factor
# generateLut
Creates a LUT used while rendering to convert stored pixel values to display pixels
# Parameters
image
Image (opens new window) A Cornerstone Image ObjectwindowWidth
Number (opens new window) The Window WidthwindowCenter
Number (opens new window) The Window Centerinvert
Boolean (opens new window) A boolean describing whether or not the image has been invertedmodalityLUT
Array (opens new window)? A modality Lookup TablevoiLUT
Array (opens new window)? A Volume of Interest Lookup Table
Returns Uint8ClampedArray (opens new window) A lookup table to apply to the image
# getDefaultViewport
Creates a new viewport object containing default values for the image and canvas
# Parameters
canvas
HTMLElement (opens new window) A Canvas DOM elementimage
Image (opens new window) A Cornerstone Image Object
Returns Viewport viewport object
# createDefaultDisplayedArea
Creates the default displayed area. C.10.4 Displayed Area Module: This Module describes Attributes required to define a Specified Displayed Area space.
# createViewport
Creates a new viewport object containing default values
Returns Viewport viewport object
# generateLinearModalityLUT
Generates a linear modality transformation function
See DICOM PS3.3 C.11.1 Modality LUT Module
http://dicom.nema.org/medical/Dicom/current/output/chtml/part03/sect_C.11.html (opens new window)
# Parameters
slope
Number (opens new window) m in the equation specified by Rescale Intercept (0028,1052).intercept
Number (opens new window) The value b in relationship between stored values (SV) and the output units specified in Rescale Type (0028,1054).Output units = m*SV + b.
Returns function (any): any A linear modality LUT function. Given a stored pixel it returns the modality pixel value
# getModalityLUT
Get the appropriate Modality LUT for the current situation.
# Parameters
slope
Number (opens new window)? m in the equation specified by Rescale Intercept (0028,1052).intercept
Number (opens new window)? The value b in relationship between stored values (SV) and the output units specified in Rescale Type (0028,1054).modalityLUT
Function (opens new window)? A modality LUT function. Given a stored pixel it returns the modality pixel value.
Returns function (any): any A modality LUT function. Given a stored pixel it returns the modality pixel value.
# storedPixelDataToCanvasImageDataRGBA
This function transforms stored pixel values into a canvas image data buffer by using a LUT.
# Parameters
image
Image (opens new window) A Cornerstone Image Objectlut
Array (opens new window) Lookup table arraycanvasImageDataData
Uint8ClampedArray (opens new window) canvasImageData.data buffer filled with white pixels
Returns void
# generateColorLut
Creates a LUT used while rendering to convert stored pixel values to display pixels
# Parameters
image
Image (opens new window) A Cornerstone Image ObjectwindowWidth
Number (opens new window) The Window WidthwindowCenter
Number (opens new window) The Window Centerinvert
Boolean (opens new window) A boolean describing whether or not the image has been invertedvoiLUT
Array (opens new window)? A Volume of Interest Lookup Table
Returns Uint8ClampedArray (opens new window) A lookup table to apply to the image
# storedRGBAPixelDataToCanvasImageData
Converts stored RGBA color pixel values to display pixel values using a LUT.
# Parameters
image
Image (opens new window) A Cornerstone Image Objectlut
Array (opens new window) Lookup table arraycanvasImageDataData
Uint8ClampedArray (opens new window) canvasImageData.data buffer filled with white pixels
Returns void
# computeAutoVoi
Computes the VOI to display all the pixels if no VOI LUT data (Window Width/Window Center or voiLUT) exists on the viewport object.
# Parameters
viewport
Viewport Object containing the viewport propertiesimage
Object (opens new window) An Image loaded by a Cornerstone Image Loader
Returns void
# hasVoi
Check if viewport has voi LUT data
# Parameters
viewport
any The viewport to check for voi LUT data
Returns Boolean (opens new window) true viewport has LUT data (Window Width/Window Center or voiLUT). Otherwise, false.
# isRotated
Check if the angle is rotated
# Parameters
rotation
Number (opens new window) the rotation angle
Returns Boolean (opens new window) true if the angle is rotated; Otherwise, false.
# getImageSize
Retrieves the current image dimensions given an enabled element
# Parameters
image
any The Cornerstone image.rotation
Number (opens new window) Optional. The rotation angle of the image. (optional, defaultnull
)
Returns {width: Number (opens new window), height: Number (opens new window)} The Image dimensions
# calculateTransform
Calculate the transform for a Cornerstone enabled element
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled Elementscale
Number (opens new window)? The viewport scale
Returns Transform The current transform
# storedColorPixelDataToCanvasImageData
Converts stored color pixel values to display pixel values using a LUT.
Note: Skips alpha value for any input image pixel data.
# Parameters
image
Image (opens new window) A Cornerstone Image Objectlut
Array (opens new window) Lookup table arraycanvasImageDataData
Uint8ClampedArray (opens new window) canvasImageData.data buffer filled with white pixels
Returns void
# storedPixelDataToCanvasImageData
This function transforms stored pixel values into a canvas image data buffer by using a LUT. This is the most performance sensitive code in cornerstone and we use a special trick to make this go as fast as possible. Specifically we use the alpha channel only to control the luminance rather than the red, green and blue channels which makes it over 3x faster. The canvasImageDataData buffer needs to be previously filled with white pixels.
NOTE: Attribution would be appreciated if you use this technique!
# Parameters
image
Image (opens new window) A Cornerstone Image Objectlut
Array (opens new window) Lookup table arraycanvasImageDataData
Uint8ClampedArray (opens new window) canvasImageData.data buffer filled with white pixels
Returns void
# storedPixelDataToCanvasImageDataColorLUT
# Parameters
image
Image (opens new window) A Cornerstone Image ObjectcolorLut
(LookupTable | Array (opens new window)) Lookup table arraycanvasImageDataData
Uint8ClampedArray (opens new window) canvasImageData.data buffer filled with white pixels
Returns void
# storedPixelDataToCanvasImageDataPseudocolorLUT
# Parameters
image
Image (opens new window) A Cornerstone Image ObjectgrayscaleLut
Array (opens new window) Lookup table arraycolorLut
(LookupTable | Array (opens new window)) Lookup table arraycanvasImageDataData
Uint8ClampedArray (opens new window) canvasImageData.data buffer filled with white pixels
Returns void
# rendering
# getLut
Generates an appropriate Look Up Table to render the given image with the given window width and level (specified in the viewport) Uses an internal cache for performance
# Parameters
image
Object (opens new window) The image to be renderedviewport
Object (opens new window) The viewport values used for rendering
Returns Uint8ClampedArray (opens new window) Look Up Table array.
# getLut
Retrieve or generate a LUT Array for an Image and Viewport
# Parameters
image
Image (opens new window) An Image Objectviewport
Viewport An Viewport Objectinvalidated
Boolean (opens new window) Whether or not the LUT data has been invalidated (e.g. by a change to the windowWidth, windowCenter, or invert viewport parameters).
Returns Uint8ClampedArray (opens new window) LUT Array
# getRenderCanvas
Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate it is returned, otherwise adjustments are made. It also sets the color transfer functions.
# Parameters
enabledElement
Object (opens new window) The cornerstone enabled elementimage
Object (opens new window) The image to be renderedinvalidated
Boolean (opens new window) Is pixel data valid
Returns HTMLCanvasElement (opens new window) An appropriate canvas for rendering the image
# getRenderCanvas
Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate it is returned, otherwise adjustments are made. It also sets the color transfer functions.
# Parameters
enabledElement
Object (opens new window) The cornerstone enabled elementimage
Object (opens new window) The image to be renderedinvalidated
Boolean (opens new window) Is pixel data validuseAlphaChannel
Boolean (opens new window) Will an alpha channel be used (optional, defaulttrue
)
Returns HTMLCanvasElement (opens new window) An appropriate canvas for rendering the image
# getRenderCanvas
Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate it is returned, otherwise adjustments are made. It also sets the color transfer functions.
# Parameters
enabledElement
Object (opens new window) The cornerstone enabled elementimage
Object (opens new window) The image to be renderedinvalidated
Boolean (opens new window) Is pixel data valid
Returns HTMLCanvasElement (opens new window) An appropriate canvas for rendering the image
# getRenderCanvas
Returns an appropriate canvas to render the Image. If the canvas available in the cache is appropriate it is returned, otherwise adjustments are made. It also sets the color transfer functions.
# Parameters
enabledElement
Object (opens new window) The cornerstone enabled elementimage
Object (opens new window) The image to be renderedinvalidated
Boolean (opens new window) Is pixel data valid
Returns HTMLCanvasElement (opens new window) An appropriate canvas for rendering the image
# renderColorImage
API function to render a color image to an enabled element
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled Element to redrawinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# doesImageNeedToBeRendered
Determine whether or not an Enabled Element needs to be re-rendered.
If the imageId has changed, or if any of the last rendered viewport parameters have changed, this function will return true.
# Parameters
enabledElement
EnabledElement An Enabled Elementimage
Image (opens new window) An Image
Returns boolean (opens new window) Whether or not the Enabled Element needs to re-render its image
# initializeRenderCanvas
Sets size and clears canvas
# Parameters
enabledElement
Object (opens new window) Cornerstone Enabled Elementimage
Object (opens new window) Image to be rendered
Returns void
# saveLastRendered
Saves the parameters of the last render into renderingTools, used later to decide if data can be reused.
# Parameters
enabledElement
Object (opens new window) Cornerstone EnabledElement
Returns Object (opens new window) enabledElement.renderingTools
# renderGrayscaleImage
API function to draw a grayscale image to a given enabledElement
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled Element to redrawinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# lutMatches
Check if two lookup tables match
# Parameters
a
LUT A lookup table functionb
LUT Another lookup table function
Returns boolean (opens new window) Whether or not they match
# renderLabelMapImage
API function to draw a label map image to a given enabledElement
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled Element to redrawinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# renderPseudoColorImage
API function to draw a pseudo-color image to a given enabledElement
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled Element to redrawinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# EnabledElementStub
Type: Object (opens new window)
# Properties
element
HTMLElement (opens new window) The enabled elementcanvas
HTMLCanvasElement (opens new window) The current canvasimage
Object (opens new window) Currently displayed imageinvalid
Boolean (opens new window) Whether or not the image pixel data has been changedneedsRedraw
Boolean (opens new window) A flag for triggering a redraw of the canvas without re-retrieving the pixel data, since it remains validoptions
Object (opens new window) Layer drawing optionslayers
Array (opens new window)<Object (opens new window)> Layers added to the EnabledElementdata
Object (opens new window)renderingTools
Object (opens new window)viewport
Object (opens new window) The current viewport
# createEnabledElementStub
creates a dummy enabled element
# Parameters
canvas
HTMLCanvasElement (opens new window) the canvas that will be assigned to the enabled element.image
any An Image loaded by a Cornerstone Image Loaderoptions
any Options for rendering the image (e.g.enable webgl by {renderer: 'webgl' })viewport
any A set of Cornerstone viewport parameters
Returns EnabledElementStub a dummy enabled element
# renderToCanvas
Render the image to the provided canvas immediately.
# Parameters
canvas
any The HTML canvas where the image will be rendered.image
any An Image loaded by a Cornerstone Image Loaderviewport
any A set of Cornerstone viewport parameters (optional, defaultnull
)options
any Options for rendering the image (e.g. enable webgl by {renderer: 'webgl'}) (optional, defaultnull
)
Returns void
# renderWebImage
API function to draw a standard web image (PNG, JPG) to an enabledImage
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled Element to redrawinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# WebGLRendering
# getImageDataType
Returns the image data type as a string representation.
# Parameters
image
any The cornerstone image object
Returns string (opens new window) image data type (rgb, iint16, uint16, int8 and uint8)
# storedPixelDataToImageData
Convert stored pixel data to image data.
Pack int16 into three uint8 channels (r, g, b)
# Parameters
image
Image (opens new window) A Cornerstone Image Object
Returns Uint8Array (opens new window) The image data for use by the WebGL shader
# storedPixelDataToImageData
Convert stored pixel data to image data.
Store data in Uint8Array
# Parameters
image
Image (opens new window) A Cornerstone Image Object
Returns Uint8Array (opens new window) The image data for use by the WebGL shader
# storedPixelDataToImageData
Convert stored pixel data to image data.
Pack RGB images into a 3-channel RGB texture
# Parameters
image
Image (opens new window) A Cornerstone Image Object
Returns Uint8Array (opens new window) The image data for use by the WebGL shader
# storedPixelDataToImageData
Convert stored pixel data to image data.
For uint16 pack uint16 into two uint8 channels (r and a).
# Parameters
image
Image (opens new window) A Cornerstone Image Object
Returns Uint8Array (opens new window) The image data for use by the WebGL shader
# storedPixelDataToImageData
Convert stored pixel data to image data. Here we will store all data in the alpha channel.
# Parameters
image
Image (opens new window) A Cornerstone Image Object
Returns Uint8Array (opens new window) The image data for use by the WebGL shader
# compileShader
Creates and compiles a shader.
# Parameters
gl
The WebGL Context.shaderSource
string (opens new window) The GLSL source code for the shader.shaderType
number (opens new window) The type of shader, VERTEX_SHADER or FRAGMENT_SHADER.
Returns The shader.
# createProgram
Creates a program from 2 shaders.
# Parameters
gl
The WebGL context.vertexShader
A vertex shader.fragmentShader
A fragment shader.
Returns A program.
# createProgramFromString
Creates a program from 2 shaders source (Strings)
# Parameters
gl
The WebGL context.vertexShaderSrc
Vertex shader stringfragShaderSrc
Fragment shader string
Returns A program
# Polyfills
# EventTarget
EventTarget - Provides the EventTarget (opens new window) interface
# now
Use the performance.now() method if possible, and if not, use Date.now()
Returns number (opens new window) Time elapsed since the time origin
# requestAnimationFrame
Polyfills requestAnimationFrame for older browsers.
# Parameters
callback
Function (opens new window) A parameter specifying a function to call when it's time to update your animation for the next repaint. The callback has one single argument, a DOMHighResTimeStamp, which indicates the current time (the time returned from performance.now() ) for when requestAnimationFrame starts to fire callbacks.
Returns Number (opens new window) A long integer value, the request id, that uniquely identifies the entry in the callback list. This is a non-zero value, but you may not make any other assumptions about its value. You can pass this value to window.cancelAnimationFrame() to cancel the refresh callback request.
# purgeLayers
Purge the layers
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstone
Returns void
# getPixelValues
Retrieves the minimum and maximum pixel values from an Array of pixel data
# Parameters
pixelData
Array (opens new window) The input pixel data array
Returns {minPixelValue: Number (opens new window), maxPixelValue: Number (opens new window)} The minimum and maximum pixel values in the input Array
# getRestoreImageMethod
Retrieve a function that will allow an image object to be reset to its original form after a false color mapping transformation
# Parameters
image
Image (opens new window) A Cornerstone Image Object
Returns Function (opens new window) A function for resetting an Image Object to its original form
# ensuresColormap
User can pass a colormap or its id as string to some of these public functions. Then we need to make sure it will be converted into a colormap object if it's a string.
# Parameters
colormap
any A colormap ID or Object
Returns any The colormap
# restoreImage
Restores a false color image to its original version
# Parameters
image
Image (opens new window) A Cornerstone Image Object
Returns Boolean (opens new window) True if the image object had a valid restore function, which was run. Otherwise, false.
# convertImageToFalseColorImage
Convert an image to a false color image
# Parameters
image
Image (opens new window) A Cornerstone Image Objectcolormap
(String (opens new window) | Object (opens new window)) it can be a colormap object or a colormap id (string)
Returns Boolean (opens new window) Whether or not the image has been converted to a false color image
# convertToFalseColorImage
Convert the image of a element to a false color image
# Parameters
element
HTMLElement (opens new window) The Cornerstone elementcolormap
any it can be a colormap object or a colormap id (string)
Returns void
# linspace
Generate linearly spaced vectors http://cens.ioc.ee/local/man/matlab/techdoc/ref/linspace.html (opens new window)
# Parameters
a
Number (opens new window) A number representing the first vectorb
Number (opens new window) A number representing the second vectorn
Number (opens new window) The number of linear spaced vectors to generate
Returns Array (opens new window) An array of points representing linear spaced vectors.
# getRank
Returns the "rank/index" of the element in a sorted array if found or the highest index if not. Uses (binary search)
# Parameters
array
Array (opens new window) A sorted array to search inelem
any the element in the array to search for
Returns number (opens new window) The rank/index of the element in the given array
# searchSorted
Find the indices into a sorted array a such that, if the corresponding elements In v were inserted before the indices, the order of a would be preserved. http://lagrange.univ-lyon1.fr/docs/numpy/1.11.0/reference/generated/numpy.searchsorted.html (opens new window)
# Parameters
inputArray
Array (opens new window) The array where the values will be insertedvalues
Array (opens new window) An array of the values to be inserted into the inputArray
Returns Array (opens new window) The indices where elements should be inserted to maintain order.
# makeMappingArray
Creates an N -element 1-d lookup table
# Parameters
N
Number (opens new window) The number of elements in the result lookup tabledata
Array (opens new window) represented by a list of x,y0,y1 mapping correspondences. Each element in this List represents how a value between 0 and 1 (inclusive) represented by x is mapped to A corresponding value between 0 and 1 (inclusive). The two values of y are to allow for Discontinuous mapping functions (say as might be found in a sawtooth) where y0 represents The value of y for values of x <= to that given, and y1 is the value to be used for x > Than that given). The list must start with x=0, end with x=1, and all values of x must be In increasing order. Values between the given mapping points are determined by simple linear Interpolation.gamma
any value denotes a "gamma curve" value which adjusts the brightness at the bottom and top of the map.
Returns Array (opens new window)<any> an array "result" where result[x*(N-1)] gives the closest value for Values of x between 0 and 1.
# createLinearSegmentedColormap
The lookup table is generated using linear interpolation for each Primary color, with the 0-1 domain divided into any number of Segments. https://github.com/stefanv/matplotlib/blob/3f1a23755e86fef97d51e30e106195f34425c9e3/lib/matplotlib/colors.py#L663 (opens new window)
# Parameters
segmentedData
{red: Array (opens new window), green: Array (opens new window), blue: Array (opens new window)} An object with a red, green and blue entries. Each entry should be a list of x, y0, y1 tuples, forming rows in a table.N
Number (opens new window) The number of elements in the result Colormapgamma
any value denotes a "gamma curve" value which adjusts the brightness at the bottom and top of the Colormap.
Returns Array (opens new window) The created Colormap object
# getColormapsList
Return all available colormaps (id and name)
Returns Array (opens new window)<{id, key}> An array of colormaps with an object containing the "id" and display "name"
# getColormap
Return a colorMap object with the provided id and colormapData if the Id matches existent colorMap objects (check colormapsData) the colormapData is ignored. if the colormapData is not empty, the colorMap will be added to the colormapsData list. Otherwise, an empty colorMap object is returned.
# Parameters
id
string (opens new window) The ID of the colormapcolormapData
Object (opens new window) An object that can contain a name, numColors, gama, segmentedData and/or colors
Returns any The Colormap Object
# linearIndexLookupMain
Maps a value to an index in the table
# Parameters
v
Number (opens new window) A double value which table index will be returned.p
any An object that contains the Table "Range", the table "MaxIndex", A "Shift" from first value in the table and the table "Scale" value
Returns Number (opens new window) The mapped index in the table
# setNumberOfTableValues
Specify the number of values (i.e., colors) in the lookup table.
# Parameters
number
Number (opens new window) The number of colors in he LookupTable
Returns void
# setRamp
Set the shape of the table ramp to either 'linear', 'scurve' or 'sqrt'
# Parameters
ramp
String (opens new window) A string value representing the shape of the table. Allowed values are 'linear', 'scurve' or 'sqrt'
Returns void
# setTableRange
Sets the minimum/maximum scalar values for scalar mapping. Scalar values less than minimum range value are clamped to minimum range value. Scalar values greater than maximum range value are clamped to maximum range value.
# Parameters
start
Number (opens new window) A double representing the minimum scaler value of the LookupTableend
any A double representing the maximum scaler value of the LookupTable
Returns void
# setHueRange
Set the range in hue (using automatic generation). Hue ranges between [0,1].
# Parameters
start
Number (opens new window) A double representing the minimum hue value in a range. Min. is 0end
Number (opens new window) A double representing the maximum hue value in a range. Max. is 1
Returns void
# setSaturationRange
Set the range in saturation (using automatic generation). Saturation ranges between [0,1].
# Parameters
start
Number (opens new window) A double representing the minimum Saturation value in a range. Min. is 0end
Number (opens new window) A double representing the maximum Saturation value in a range. Max. is 1
Returns void
# setValueRange
Set the range in value (using automatic generation). Value ranges between [0,1].
# Parameters
start
Numeber A double representing the minimum value in a range. Min. is 0end
Numeber A double representing the maximum value in a range. Max. is 1
Returns void
# setRange
(Not Used) Sets the range of scalars which will be mapped.
# Parameters
start
Number (opens new window) the minimum scalar value in the rangeend
Number (opens new window) the maximum scalar value in the range
Returns void
# setAlphaRange
Set the range in alpha (using automatic generation). Alpha ranges from [0,1].
# Parameters
start
Number (opens new window) A double representing the minimum alpha valueend
Number (opens new window) A double representing the maximum alpha value
Returns void
# getColor
Map one value through the lookup table and return the color as an RGBA array of doubles between 0 and 1.
# Parameters
scalar
Number (opens new window) A double scalar value which will be mapped to a color in the LookupTable
Returns Array (opens new window)<Number (opens new window)> An RGBA array of doubles between 0 and 1
# build
Generate lookup table from hue, saturation, value, alpha min/max values. Table is built from linear ramp of each value.
# Parameters
force
Boolean (opens new window) true to force the build of the LookupTable. Otherwie, false. This is useful if a lookup table has been defined manually (using SetTableValue) and then an application decides to rebuild the lookup table using the implicit process.
Returns void
# buildSpecialColors
Ensures the out-of-range colors (Below range and Above range) are set correctly.
Returns void
# mapValue
Similar to GetColor - Map one value through the lookup table and return the color as an RGBA array of doubles between 0 and 1.
# Parameters
v
Numeber A double scalar value which will be mapped to a color in the LookupTable
Returns Array (opens new window)<Number (opens new window)> An RGBA array of doubles between 0 and 1
# getIndex
Return the table index associated with a particular value.
# Parameters
v
Number (opens new window) A double value which table index will be returned.
Returns Number (opens new window) The index in the LookupTable
# setTableValue
Directly load color into lookup table. Use [0,1] double values for color component specification. Make sure that you've either used the Build() method or used SetNumberOfTableValues() prior to using this method.
# Parameters
index
Number (opens new window) The index in the LookupTable of where to insert the color valuergba
Array (opens new window)<Number (opens new window)> An array of [0,1] double values for an RGBA color component
Returns void
# getElementData
Retrieves any data for a Cornerstone enabledElement for a specific string dataType
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for CornerstonedataType
string (opens new window) A string name for an arbitrary set of data
Returns any Whatever data is stored for this enabled element
# removeElementData
Clears any data for a Cornerstone enabledElement for a specific string dataType
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for CornerstonedataType
string (opens new window) A string name for an arbitrary set of data
Returns void
# canvasToPixel
Converts a point in the canvas coordinate system to the pixel coordinate system system. This can be used to reset tools' image coordinates after modifications have been made in canvas space (e.g. moving a tool by a few cm, independent of image resolution).
# Parameters
element
HTMLElement (opens new window) The Cornerstone element within which the input point liespt
{x: Number (opens new window), y: Number (opens new window)} The input point in the canvas coordinate system
Returns {x: Number (opens new window), y: Number (opens new window)} The transformed point in the pixel coordinate system
# pixelToCanvas
Converts a point in the pixel coordinate system to the canvas coordinate system system. This can be used to render using canvas context without having the weird side effects that come from scaling and non square pixels
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for Cornerstonept
{x: Number (opens new window), y: Number (opens new window)} The transformed point in the pixel coordinate system
Returns {x: Number (opens new window), y: Number (opens new window)} The input point in the canvas coordinate system
# HSVToRGB
Converts an HSV (Hue, Saturation, Value) color to RGB (Red, Green, Blue) color value
# Parameters
hue
Number (opens new window) A number representing the hue color valuesat
any A number representing the saturation color valueval
any A number representing the value color value
Returns Array (opens new window)<Numberp> An RGB color array
# LookupTable
Maps scalar values into colors via a lookup table LookupTable is an object that is used by mapper objects to map scalar values into rgba (red-green-blue-alpha transparency) color specification, or rgba into scalar values. The color table can be created by direct insertion of color values, or by specifying hue, saturation, value, and alpha range and generating a table
# disable
Disable an HTML element for further use in Cornerstone
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for Cornerstone
Returns void
# hasImageOrLayers
Returns whether or not an Enabled Element has either a currently active image or a non-empty Array of Enabled Element Layers.
# Parameters
enabledElement
EnabledElement An Enabled Element
Returns Boolean (opens new window) Whether or not the Enabled Element has an active image or valid set of layers
# enable
Enable an HTML Element for use in Cornerstone
- If there is a Canvas already present within the HTMLElement, and it has the class 'cornerstone-canvas', this function will use this existing Canvas instead of creating a new one. This may be helpful when using libraries (e.g. React, Vue) which don't want third parties to change the DOM.
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for Cornerstoneoptions
Object (opens new window) Options for the enabledElement
Returns void
# displayImage
Sets a new image object for a given element.
Will also apply an optional viewport setting.
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for Cornerstoneimage
Object (opens new window) An Image loaded by a Cornerstone Image Loaderviewport
Object (opens new window)? A set of Cornerstone viewport parameters
Returns void
# draw
Immediately draws the enabled element
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for Cornerstone
Returns void
# draw
Draw the image immediately
# Parameters
timestamp
DOMHighResTimeStamp The current time for when requestAnimationFrame starts to fire callbacks
Returns void
# drawInvalidated
Draws all invalidated enabled elements and clears the invalid flag after drawing it
Returns void
# invalidate
Sets the invalid flag on the enabled element and fires an event
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstone
Returns void
# invalidateImageId
Forces the image to be updated/redrawn for all enabled elements displaying the specified imageId
# Parameters
imageId
string (opens new window) The imageId of the Cornerstone Image Object to redraw
Returns void
# updateImage
Forces the image to be updated/redrawn for the specified enabled element
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for Cornerstoneinvalidated
Boolean (opens new window) Whether or not the image pixel data has been changed, necessitating a redraw (optional, defaultfalse
)
Returns void
# getEnabledElements
This module is responsible for drawing invalidated enabled elements
# hasImageOrLayers
# Parameters
enabledElement
# drawCompositeImage
Internal API function to draw a composite image to a given enabled element
# Parameters
enabledElement
EnabledElement An enabled element to draw intoinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# tryEnableWebgl
Checks if webGL is supported and initializes the rendering engine.
# Parameters
options
any Options to check if webgl rendering is requested (e.g. enable webgl by passing {renderer: 'webgl'})
Returns Boolean (opens new window) true if webgl rendering has been successfully initialized. Otherwise, false.
# generateUUID
Generates a UUID for the enabledElement.
Returns String (opens new window) the UUID.
# createCanvas
Create a canvas and append it to the element
# Parameters
element
HTMLElement (opens new window) An HTML Element
Returns HTMLElement (opens new window) canvas A Canvas DOM element
# getCanvas
Create a canvas or returns the one that already exists for a given element
# Parameters
element
HTMLElement (opens new window) An HTML Element
Returns HTMLElement (opens new window) canvas A Canvas DOM element
# fitToWindow
Adjusts an image's scale and translation so the image is centered and all pixels in the image are viewable.
# Parameters
element
HTMLElement (opens new window) The Cornerstone element to update
Returns void
# validateParameterUndefined
Check if the supplied parameter is undefined and throws and error
# Parameters
checkParam
any the parameter to validate for undefinederrorMsg
any the error message to be thrown
Returns void
# validateParameterUndefinedOrNull
Check if the supplied parameter is undefined or null and throws and error
# Parameters
checkParam
any the parameter to validate for undefinederrorMsg
any the error message to be thrown
Returns void
# generateLinearVOILUT
# Parameters
windowWidth
windowCenter
# generateLinearVOILUT
# Parameters
windowWidth
Number (opens new window) Window WidthwindowCenter
Number (opens new window) Window Center
Returns VOILUTFunction VOI LUT mapping function
# generateNonLinearVOILUT
Generate a non-linear volume of interest lookup table
# Parameters
voiLUT
LUT Volume of Interest Lookup Table Object
Returns VOILUTFunction VOI LUT mapping function
# getVOILut
Retrieve a VOI LUT mapping function given the current windowing settings and the VOI LUT for the image
# Parameters
windowWidth
Number (opens new window) Window WidthwindowCenter
Number (opens new window) Window CentervoiLUT
LUT? Volume of Interest Lookup Table Object
Returns VOILUTFunction VOI LUT mapping function
# getDefaultViewportForImage
Returns a default viewport for display the specified image on the specified enabled element. The default viewport is fit to window
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstoneimage
Image (opens new window) A Cornerstone Image Object
Returns Viewport The default viewport for the image
# getImage
Returns the currently displayed image for an element or undefined if no image has been displayed yet
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstone
Returns Image (opens new window) The Cornerstone Image Object displayed in this element
# getPixels
Retrieves an array of pixels from a rectangular region with modality LUT transformation applied
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstonex
Number (opens new window) The x coordinate of the top left corner of the sampling rectangle in image coordinatesy
Number (opens new window) The y coordinate of the top left corner of the sampling rectangle in image coordinateswidth
Number (opens new window) The width of the of the sampling rectangle in image coordinatesheight
Number (opens new window) The height of the of the sampling rectangle in image coordinates
Returns Array (opens new window) The modality pixel value of the pixels in the sampling rectangle
# getStoredPixels
Retrieves an array of stored pixel values from a rectangular region of an image
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstonex
Number (opens new window) The x coordinate of the top left corner of the sampling rectangle in image coordinatesy
Number (opens new window) The y coordinate of the top left corner of the sampling rectangle in image coordinateswidth
Number (opens new window) The width of the of the sampling rectangle in image coordinatesheight
Number (opens new window) The height of the of the sampling rectangle in image coordinates
Returns Array (opens new window) The stored pixel value of the pixels in the sampling rectangle
# getViewport
Retrieves the viewport for the specified enabled element
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstone
Returns (Viewport | undefined (opens new window)) The Cornerstone Viewport settings for this element, if they exist. Otherwise, undefined
# setViewport
Sets/updates viewport of a given enabled element
# Parameters
element
HTMLElement (opens new window) DOM element of the enabled elementviewport
Viewport? Object containing the viewport properties
Returns void
# setMaximumSizeBytes
Sets the maximum size of cache and purges cache contents if necessary.
# Parameters
numBytes
number (opens new window) The maximun size that the cache should occupy.
Returns void
# purgeCacheIfNecessary
Purges the cache if size exceeds maximum
Returns void
# putImageLoadObject
Puts a new image loader into the cache
# Parameters
imageId
string (opens new window) ImageId of the image loaderimageLoadObject
Object (opens new window) The object that is loading or loaded the image
Returns void
# getImageLoadObject
Retuns the object that is loading a given imageId
# Parameters
imageId
string (opens new window) Image ID
Returns void
# removeImageLoadObject
Removes the image loader associated with a given Id from the cache
# Parameters
imageId
string (opens new window) Image ID
Returns void
# CacheInformation
Type: Object (opens new window)
# Properties
maximumSizeInBytes
number (opens new window) The maximum size of the cache in bytescacheSizeInBytes
number (opens new window) Currently occupied space in the cache in bytesnumberOfImagesCached
number (opens new window) Number of ImageLoaders in the cache
Returns void
# getCacheInfo
Gets the current state of the cache
Returns void
# decache
INTERNAL: Removes and ImageLoader from the cache
# Parameters
imageLoadObject
Object (opens new window) Image Loader Object to remove
Returns void
# purgeCache
Removes all images from cache
Returns void
# changeImageIdCacheSize
Updates the space than an image is using in the cache
# Parameters
imageId
string (opens new window) Image IDnewCacheSize
number (opens new window) New image size
Returns void
# pageToPixel
Converts a point in the page coordinate system to the pixel coordinate system
# Parameters
element
HTMLElement (opens new window) The Cornerstone element within which the input point liespageX
Number (opens new window) The x value in the page coordinate systempageY
Number (opens new window) The y value in the page coordinate system
Returns {x: Number (opens new window), y: Number (opens new window)} The transformed point in the pixel coordinate system
# pixelDataToFalseColorData
Converts the image pixel data into a false color data
# Parameters
image
Image (opens new window) A Cornerstone Image ObjectlookupTable
Object (opens new window) A lookup table Object
Returns void
Meta
- deprecated: This function is superseded by the ability to set the Viewport parameters to include colormaps.
# addGrayscaleLayer
API function to draw a grayscale image to a given layer
# Parameters
layer
EnabledElementLayer The layer that the image will be added toinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be useduseAlphaChannel
Boolean (opens new window)? Whether or not to render the grayscale image using only the alpha channel. This does not work if this layer is not the first layer in the enabledElement. (optional, defaultfalse
)
Returns void
# addLabelMapLayer
API function to draw a pseudo-color image to a given layer
# Parameters
layer
EnabledElementLayer The layer that the image will be added toinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# addPseudoColorLayer
API function to draw a pseudo-color image to a given layer
# Parameters
layer
EnabledElementLayer The layer that the image will be added toinvalidated
Boolean (opens new window) true if pixel data has been invalidated and cached rendering should not be used
Returns void
# reset
Resets the viewport to the default settings
# Parameters
element
HTMLElement (opens new window) An HTML Element enabled for Cornerstone
Returns void
# setCanvasSize
This module is responsible for enabling an element to display images with cornerstone
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for Cornerstonecanvas
HTMLElement (opens new window) The Canvas DOM element within the DOM element enabled for Cornerstone
Returns void
# wasFitToWindow
Checks if the image of a given enabled element fitted the window before the resize
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled ElementoldCanvasWidth
number (opens new window) The width of the canvas before the resizeoldCanvasHeight
number (opens new window) The height of the canvas before the resize
Returns Boolean (opens new window) true if it fitted the windows, false otherwise
# relativeRescale
Rescale the image relative to the changed size of the canvas
# Parameters
enabledElement
EnabledElement The Cornerstone Enabled ElementoldCanvasWidth
number (opens new window) The width of the canvas before the resizeoldCanvasHeight
number (opens new window) The height of the canvas before the resize
Returns void
# resize
Resizes an enabled element and optionally fits the image to window
# Parameters
element
HTMLElement (opens new window) The DOM element enabled for CornerstoneforceFitToWindow
Boolean (opens new window) true to to force a refit, false to rescale accordingly
Returns void
# setDefaultViewport
Sets new default values for getDefaultViewport
# Parameters
viewport
Object (opens new window) Object that sets new default values for getDefaultViewport
Returns undefined (opens new window)
# setToPixelCoordinateSystem
Sets the canvas context transformation matrix to the pixel coordinate system. This allows geometry to be driven using the canvas context using coordinates in the pixel coordinate system
# Parameters
enabledElement
EnabledElement Thecontext
CanvasRenderingContext2D (opens new window) The CanvasRenderingContext2D for the enabledElement's Canvasscale
Number (opens new window)? Optional scale to apply
Returns void
# triggerEvent
Trigger a CustomEvent
# Parameters
el
EventTarget The element or EventTarget to trigger the event upontype
String (opens new window) The event type namedetail
(Object (opens new window) | null) =null The event data to be sent (optional, defaultnull
)
Returns Boolean (opens new window) The return value is false if at least one event listener called preventDefault(). Otherwise it returns true.
# WebGLTextureCache
This module deals with caching image textures in VRAM for WebGL