| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 |
9×
9×
9×
9×
1×
8×
1×
7×
1×
6×
6×
1×
5×
1×
1×
4×
4×
4×
2×
2×
2×
| import webWorkerManager from './webWorkerManager.js';
import decodeJPEGBaseline8BitColor from './decodeJPEGBaseline8BitColor.js';
function addDecodeTask (imageFrame, transferSyntax, pixelData, options) {
const priority = options.priority || undefined;
const transferList = options.transferPixelData ? [pixelData.buffer] : undefined;
return webWorkerManager.addTask(
'decodeTask',
{
imageFrame,
transferSyntax,
pixelData,
options
}, priority, transferList).promise;
}
function decodeImageFrame (imageFrame, transferSyntax, pixelData, canvas, options = {}) {
// TODO: Turn this into a switch statement instead
if (transferSyntax === '1.2.840.10008.1.2') {
// Implicit VR Little Endian
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else if (transferSyntax === '1.2.840.10008.1.2.1') {
// Explicit VR Little Endian
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else if (transferSyntax === '1.2.840.10008.1.2.2') {
// Explicit VR Big Endian (retired)
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else Iif (transferSyntax === '1.2.840.10008.1.2.1.99') {
// Deflate transfer syntax (deflated by dicomParser)
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else if (transferSyntax === '1.2.840.10008.1.2.5') {
// RLE Lossless
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else if (transferSyntax === '1.2.840.10008.1.2.4.50') {
// JPEG Baseline lossy process 1 (8 bit)
// Handle 8-bit JPEG Baseline color images using the browser's built-in
// JPEG decoding
Iif (imageFrame.bitsAllocated === 8 &&
(imageFrame.samplesPerPixel === 3 || imageFrame.samplesPerPixel === 4)) {
return decodeJPEGBaseline8BitColor(imageFrame, pixelData, canvas);
}
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else Iif (transferSyntax === '1.2.840.10008.1.2.4.51') {
// JPEG Baseline lossy process 2 & 4 (12 bit)
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else Iif (transferSyntax === '1.2.840.10008.1.2.4.57') {
// JPEG Lossless, Nonhierarchical (Processes 14)
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else if (transferSyntax === '1.2.840.10008.1.2.4.70') {
// JPEG Lossless, Nonhierarchical (Processes 14 [Selection 1])
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else Eif (transferSyntax === '1.2.840.10008.1.2.4.80') {
// JPEG-LS Lossless Image Compression
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else if (transferSyntax === '1.2.840.10008.1.2.4.81') {
// JPEG-LS Lossy (Near-Lossless) Image Compression
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else if (transferSyntax === '1.2.840.10008.1.2.4.90') {
// JPEG 2000 Lossless
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
} else if (transferSyntax === '1.2.840.10008.1.2.4.91') {
// JPEG 2000 Lossy
return addDecodeTask(imageFrame, transferSyntax, pixelData, options);
}
/* Don't know if these work...
// JPEG 2000 Part 2 Multicomponent Image Compression (Lossless Only)
else if(transferSyntax === "1.2.840.10008.1.2.4.92")
{
return cornerstoneWADOImageLoader.decodeJPEG2000(dataSet, frame);
}
// JPEG 2000 Part 2 Multicomponent Image Compression
else if(transferSyntax === "1.2.840.10008.1.2.4.93")
{
return cornerstoneWADOImageLoader.decodeJPEG2000(dataSet, frame);
}
*/
return new Promise((resolve, reject) => {
reject(new Error(`No decoder for transfer syntax ${transferSyntax}`));
});
}
export default decodeImageFrame;
|