Constructor
new Image(geometry, buffer, imageUidsopt)
Name | Type | Attributes | Description |
---|---|---|---|
geometry | Geometry | The geometry of the image. | |
buffer | TypedArray | The image data as a one dimensional buffer. | |
imageUids | Array.<string> | <optional> | An array of Uids indexed to slice number. |
- Source
// XMLHttpRequest onload callback
const onload = function (event) {
// parse the dicom buffer
const dicomParser = new dwv.DicomParser();
dicomParser.parse(event.target.response);
// create the image object
const image = dwv.createImage(dicomParser.getDicomElements());
// result div
const div = document.getElementById('dwv');
// display the image size
const size = image.getGeometry().getSize();
div.appendChild(document.createTextNode(
'Size: ' + size.toString() +
' (should be 256,256,1)'));
// break line
div.appendChild(document.createElement('br'));
// display a pixel value
div.appendChild(document.createTextNode(
'Pixel @ [128,40,0]: ' +
image.getRescaledValue(128,40,0) +
' (should be 101)'));
};
// DICOM file request
const request = new XMLHttpRequest();
const url = 'https://raw.githubusercontent.com/ivmartel/dwv/master/tests/data/bbmri-53323851.dcm';
request.open('GET', url);
request.responseType = 'arraybuffer';
request.onload = onload;
request.send();
Classes
Methods
addEventListener(type, callback)
Add an event listener to this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type, will be called with the fired event. |
- Source
appendFrame(time, origin)
Append a frame to the image.
Name | Type | Description |
---|---|---|
time | number | The frame time value. |
origin | Point3D | The origin of the frame. |
- Source
appendFrameBuffer(frameBuffer, frameIndex)
Append a frame buffer to the image.
Name | Type | Description |
---|---|---|
frameBuffer | object | The frame buffer to append. |
frameIndex | number | The frame index. |
- Source
appendSlice(rhs)
Append a slice to the image.
Name | Type | Description |
---|---|---|
rhs | Image | The slice to append. |
- Source
calculateDataRange() → {object}
Calculate the data range of the image. WARNING: for speed reasons, only calculated on the first frame...
- Source
The range {min, max}.
- Type:
- object
calculateHistogram() → {object}
Calculate the histogram of the image.
- Source
The histogram, data range and rescaled data range.
- Type:
- object
calculateRescaledDataRange() → {object}
Calculate the rescaled data range of the image. WARNING: for speed reasons, only calculated on the first frame...
- Source
The range {min, max}.
- Type:
- object
canQuantify() → {boolean}
Can the image values be quantified?
- Source
True if only one component.
- Type:
- boolean
canScroll(viewOrientation) → {boolean}
Can the data be scrolled?
Name | Type | Description |
---|---|---|
viewOrientation | Matrix33 | The view orientation. |
- Source
True if the data has a third dimension greater than one after applying the view orientation.
- Type:
- boolean
canWindowLevel() → {boolean}
Can window and level be applied to the data?
- Deprecated
- Since v0.33, please use isMonochrome instead.
- Source
True if the data is monochrome.
- Type:
- boolean
clone() → {Image}
Clone the image.
- Source
A clone of this image.
- Type:
- Image
compose(rhs, operator) → {Image}
Compose this image with another one and using a specific operator. WARNING: no size check!
Name | Type | Description |
---|---|---|
rhs | Image | The image to compose with. |
operator | function | The operator to use when composing. |
- Source
The composed image. Note: Uses the raw buffer values.
- Type:
- Image
containsImageUids(uids) → {boolean}
Check if this image includes the input uids.
Name | Type | Description |
---|---|---|
uids | Array.<string> | UIDs to test for presence. |
- Source
True if all uids are in this image uids.
- Type:
- boolean
convolute2D(weights) → {Image}
Convolute the image with a given 2D kernel.
Note: Uses raw buffer values.
Name | Type | Description |
---|---|---|
weights | Array.<number> | The weights of the 2D kernel as a 3x3 matrix. |
- Source
The convoluted image.
- Type:
- Image
convoluteBuffer(weights, buffer, startOffset)
Convolute an image buffer with a given 2D kernel.
Note: Uses raw buffer values.
Name | Type | Description |
---|---|---|
weights | Array.<number> | The weights of the 2D kernel as a 3x3 matrix. |
buffer | TypedArray | The buffer to convolute. |
startOffset | number | The index to start at. |
- Source
getBuffer() → {TypedArray}
Get the data buffer of the image.
- Source
- To Do
- Dangerous...
The data buffer of the image.
- Type:
- TypedArray
getDataRange() → {NumberRange}
Get the data range.
- Source
The data range.
- Type:
- NumberRange
getGeometry() → {Geometry}
Get the geometry of the image.
- Source
The geometry.
- Type:
- Geometry
getHistogram() → {Array}
Get the histogram.
- Source
The histogram.
- Type:
- Array
getImageUid(indexopt) → {string}
Get the image UID at a given index.
Name | Type | Attributes | Description |
---|---|---|---|
index | Index | <optional> | The index at which to get the id. |
- Source
The UID.
- Type:
- string
getMeta() → {Object.<string, any>}
Get the meta information of the image.
- Source
The meta information of the image.
- Type:
- Object.<string, any>
getNumberOfComponents() → {number}
Get the numberOfComponents of the image.
- Source
The numberOfComponents of the image.
- Type:
- number
getOffsets(value) → {Array.<number>}
Get the offsets where the buffer equals the input value. Loops through the whole volume, can get long for big data...
Name | Type | Description |
---|---|---|
value | number | | The value to check. |
- Source
The list of offsets.
- Type:
- Array.<number>
getOriginForImageUid(uid) → {Point3D|undefined}
Get the image origin for a image UID.
Name | Type | Description |
---|---|---|
uid | string | The UID. |
- Source
The origin.
- Type:
- Point3D |
undefined
getPhotometricInterpretation() → {string}
Get the photometricInterpretation of the image.
- Source
The photometricInterpretation of the image.
- Type:
- string
getPlanarConfiguration() → {number}
Get the planarConfiguration of the image.
- Source
The planarConfiguration of the image.
- Type:
- number
getRescaleSlopeAndIntercept(indexopt) → {RescaleSlopeAndIntercept}
Get the rescale slope and intercept.
Name | Type | Attributes | Description |
---|---|---|---|
index | Index | <optional> | The index (only needed for non constant rsi). |
- Source
The rescale slope and intercept.
- Type:
- RescaleSlopeAndIntercept
getRescaledDataRange() → {NumberRange}
Get the rescaled data range.
- Source
The rescaled data range.
- Type:
- NumberRange
getRescaledValue(i, j, k, f) → {number}
Get the rescaled value of the image at a specific position.
Name | Type | Description |
---|---|---|
i | number | The X index. |
j | number | The Y index. |
k | number | The Z index. |
f | number | The frame number. |
- Source
The rescaled value at the desired position. Warning: No size check...
- Type:
- number
getRescaledValueAtIndex(index) → {number}
Get the rescaled value of the image at a specific index.
Name | Type | Description |
---|---|---|
index | Index | The index. |
- Source
The rescaled value at the desired position. Warning: No size check...
- Type:
- number
getRescaledValueAtOffset(offset) → {number}
Get the rescaled value of the image at a specific offset.
Name | Type | Description |
---|---|---|
offset | number | The desired offset. |
- Source
The rescaled value at the desired offset. Warning: No size check...
- Type:
- number
getSecondaryOffset(index) → {number}
Get the secondary offset: an offset that takes into account the slice and above dimension numbers.
Name | Type | Description |
---|---|---|
index | Index | The index. |
- Source
The offset.
- Type:
- number
getValue(i, j, k, f) → {number}
Get the value of the image at a specific coordinate.
Name | Type | Description |
---|---|---|
i | number | The X index. |
j | number | The Y index. |
k | number | The Z index. |
f | number | The frame number. |
- Source
The value at the desired position. Warning: No size check...
- Type:
- number
getValueAtIndex(index) → {number}
Get the value of the image at a specific index.
Name | Type | Description |
---|---|---|
index | Index | The index. |
- Source
The value at the desired position. Warning: No size check...
- Type:
- number
getValueAtOffset(offset) → {number}
Get value at offset. Warning: No size check...
Name | Type | Description |
---|---|---|
offset | number | The desired offset. |
- Source
The value at offset.
- Type:
- number
hasValues(values) → {Array.<boolean>}
Check if the input values are in the buffer. Could loop through the whole volume, can get long for big data...
Name | Type | Description |
---|---|---|
values | Array | The values to check. |
- Source
A list of booleans for each input value, set to true if the value is present in the buffer.
- Type:
- Array.<boolean>
includesImageUid(uid) → {boolean}
Check if the image includes an UID.
Name | Type | Description |
---|---|---|
uid | string | The UID. |
- Source
True if present.
- Type:
- boolean
isConstantRSI() → {boolean}
Are all the RSIs equal.
- Source
True if they are.
- Type:
- boolean
isIdentityRSI() → {boolean}
Are all the RSIs identity (1,0).
- Source
True if they are.
- Type:
- boolean
isMonochrome() → {boolean}
Is the data monochrome.
- Source
True if the data is monochrome.
- Type:
- boolean
removeEventListener(type, callback)
Remove an event listener from this class.
Name | Type | Description |
---|---|---|
type | string | The event type. |
callback | function | The function associated with the provided event type. |
- Source
setAtOffsets(offsets, value)
Set the inner buffer values at given offsets.
Name | Type | Description |
---|---|---|
offsets | Array.<number> | List of offsets where to set the data. |
value | number | | The value to set at the given offsets. |
- Source
setAtOffsetsAndGetOriginals(offsetsLists, value) → {Array}
Set the inner buffer values at given offsets.
Name | Type | Description |
---|---|---|
offsetsLists | Array.<Array.<number>> | List of offset lists where to set the data. |
value | RGB | The value to set at the given offsets. |
- Source
A list of objects representing the original values before replacing them.
- Type:
- Array
setAtOffsetsWithIterator(offsetsLists, value)
Set the inner buffer values at given offsets.
Name | Type | Description |
---|---|---|
offsetsLists | Array.<Array.<number>> | List of offset lists where to set the data. |
value | RGB | | The value to set at the given offsets. |
- Source
setMeta(rhs)
Set the meta information of the image.
Name | Type | Description |
---|---|---|
rhs | Object.<string, any> | The meta information of the image. |
- Source
setPhotometricInterpretation(interp)
Set the photometricInterpretation of the image.
Name | Type | Description |
---|---|---|
interp | string | The photometricInterpretation of the image. |
- Source
setPlanarConfiguration(config)
Set the planarConfiguration of the image.
Name | Type | Description |
---|---|---|
config | number | The planarConfiguration of the image. |
- Source
setRescaleSlopeAndIntercept(inRsi, offsetopt)
Set the rescale slope and intercept.
Name | Type | Attributes | Description |
---|---|---|---|
inRsi | RescaleSlopeAndIntercept | The input rescale slope and intercept. | |
offset | number | <optional> | The rsi offset (only needed for non constant rsi). |
- Source
transform(operator) → {Image}
Transform an image using a specific operator. WARNING: no size check!
Name | Type | Description |
---|---|---|
operator | function | The operator to use when transforming. |
- Source
The transformed image. Note: Uses the raw buffer values.
- Type:
- Image
Events
appendframe
Append frame event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
- Source
imagecontentchange
Image content change event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
- Source
imagegeometrychange
Image geometry change event.
- object
Name | Type | Description |
---|---|---|
type | string | The event type. |
- Source