@dcmjs-org/dcmjs 1.0.0-beta.15 → 1.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dcmjs.cjs +1 -1
- package/build/dcmjs.es.js +1 -1
- package/build/dcmjs.js +1811 -1424
- package/build/dcmjs.js.map +1 -1
- package/build/dcmjs.min.js +2 -2
- package/build/dcmjs.min.js.map +1 -1
- package/build/{dcmjs.shared-DI53lI_H.cjs → dcmjs.shared---E7clvy.cjs} +122 -43
- package/build/dcmjs.shared---E7clvy.cjs.map +1 -0
- package/build/{dcmjs.shared-CP8p6SfT.js → dcmjs.shared-Cy_BdC0f.js} +122 -43
- package/build/dcmjs.shared-Cy_BdC0f.js.map +1 -0
- package/build/eventStream.cjs +40 -12
- package/build/eventStream.cjs.map +1 -1
- package/build/eventStream.es.js +41 -13
- package/build/eventStream.es.js.map +1 -1
- package/package.json +8 -8
- package/build/dcmjs.shared-CP8p6SfT.js.map +0 -1
- package/build/dcmjs.shared-DI53lI_H.cjs.map +0 -1
|
@@ -936,7 +936,7 @@ var DicomMessage = /*#__PURE__*/function () {
|
|
|
936
936
|
// issue #93 opt-in: accept preamble-less / meta-less inputs
|
|
937
937
|
allowMissingHeader: false
|
|
938
938
|
};
|
|
939
|
-
var stream = new core.ReadBufferStream(buffer,
|
|
939
|
+
var stream = new core.ReadBufferStream(buffer, {
|
|
940
940
|
noCopy: options.noCopy
|
|
941
941
|
}),
|
|
942
942
|
useSyntax = core.EXPLICIT_LITTLE_ENDIAN;
|
|
@@ -1355,25 +1355,65 @@ var ValueRepresentation = /*#__PURE__*/function (_CoreValueRepresentat) {
|
|
|
1355
1355
|
//
|
|
1356
1356
|
// Handle DICOM and CIELAB colors
|
|
1357
1357
|
// based on:
|
|
1358
|
-
// https://github.com/
|
|
1358
|
+
// https://github.com/DCMTK/dcmtk/blob/88105877c3b610e23fc9422ba6a84af85552f5dd/dcmiod/libsrc/cielabutil.cc
|
|
1359
1359
|
//
|
|
1360
1360
|
// RGB here refers to sRGB 0-1 per component.
|
|
1361
1361
|
// dicomlab is CIELAB values as defined in the dicom standard
|
|
1362
|
-
// XYZ is CIEXYZ convention
|
|
1363
|
-
//
|
|
1364
|
-
// TODO: needs a test suite
|
|
1365
|
-
// TODO: only dicomlab2RGB tested on real data
|
|
1362
|
+
// XYZ is CIEXYZ convention, relative to the D50 white point (ICC PCS)
|
|
1366
1363
|
//
|
|
1364
|
+
// DICOM encodes CIELab values in the same way as the ICC Profile Connection
|
|
1365
|
+
// Space (PCS, see PS3.3 C.10.7.1.1), i.e. relative to the D50 illuminant,
|
|
1366
|
+
// whereas the native white point of sRGB is D65. The conversions below
|
|
1367
|
+
// therefore chromatically adapt between the two using the linear Bradford
|
|
1368
|
+
// transform. Matrices and constants are those of the CSS Color Module Level 4
|
|
1369
|
+
// sample code (https://www.w3.org/TR/css-color-4/#color-conversion-code).
|
|
1367
1370
|
//
|
|
1371
|
+
|
|
1372
|
+
// White points, defined by their 4-figure CIE x,y chromaticities.
|
|
1373
|
+
// D50 is intentionally [0.96430, 1, 0.82510] and not the ICC.1 PCS illuminant
|
|
1374
|
+
// [0.9642, 1, 0.8249]: this matches DCMTK, highdicom and CSS Color 4, and
|
|
1375
|
+
// encodes sRGB white as exactly 0x8080 in a* and b*.
|
|
1376
|
+
var D50_WHITEPOINT_XYZ = [0.3457 / 0.3585, 1.0, (1.0 - 0.3457 - 0.3585) / 0.3585];
|
|
1377
|
+
var D65_WHITEPOINT_XYZ = [0.3127 / 0.329, 1.0, (1.0 - 0.3127 - 0.329) / 0.329];
|
|
1378
|
+
function clamp01(n) {
|
|
1379
|
+
return Math.min(1.0, Math.max(0.0, n));
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
// Rounds to the nearest integer in [0, max]; NaN (invalid input) gives 0
|
|
1383
|
+
function roundClamp(n, max) {
|
|
1384
|
+
if (!(n >= 0.0)) {
|
|
1385
|
+
return 0;
|
|
1386
|
+
}
|
|
1387
|
+
if (n > max) {
|
|
1388
|
+
return max;
|
|
1389
|
+
}
|
|
1390
|
+
return Math.floor(n + 0.5);
|
|
1391
|
+
}
|
|
1368
1392
|
var Colors = /*#__PURE__*/function () {
|
|
1369
1393
|
function Colors() {
|
|
1370
1394
|
_classCallCheck(this, Colors);
|
|
1371
1395
|
}
|
|
1372
1396
|
return _createClass(Colors, null, [{
|
|
1397
|
+
key: "d50WhitePointXYZ",
|
|
1398
|
+
value:
|
|
1399
|
+
/**
|
|
1400
|
+
* White point of the D50 illuminant (ICC PCS), the reference white of
|
|
1401
|
+
* DICOM CIELab. Use this white with the XYZ values of rgb2XYZ, xyz2RGB,
|
|
1402
|
+
* lab2XYZ and xyz2LAB.
|
|
1403
|
+
*/
|
|
1404
|
+
function d50WhitePointXYZ() {
|
|
1405
|
+
return [].concat(D50_WHITEPOINT_XYZ);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* White point of the D65 illuminant, the native white of sRGB. No
|
|
1410
|
+
* conversion in this class uses it. Do not combine it with the XYZ
|
|
1411
|
+
* values of this class, which are relative to D50.
|
|
1412
|
+
*/
|
|
1413
|
+
}, {
|
|
1373
1414
|
key: "d65WhitePointXYZ",
|
|
1374
1415
|
value: function d65WhitePointXYZ() {
|
|
1375
|
-
|
|
1376
|
-
return [0.950456, 1.0, 1.088754];
|
|
1416
|
+
return [].concat(D65_WHITEPOINT_XYZ);
|
|
1377
1417
|
}
|
|
1378
1418
|
}, {
|
|
1379
1419
|
key: "dicomlab2RGB",
|
|
@@ -1385,6 +1425,26 @@ var Colors = /*#__PURE__*/function () {
|
|
|
1385
1425
|
value: function rgb2DICOMLAB(rgb) {
|
|
1386
1426
|
return Colors.lab2DICOMLAB(Colors.rgb2LAB(rgb));
|
|
1387
1427
|
}
|
|
1428
|
+
|
|
1429
|
+
// 16 bit DICOM CIELab -> 8 bit sRGB, rounded and clamped
|
|
1430
|
+
}, {
|
|
1431
|
+
key: "dicomlab2RGB8",
|
|
1432
|
+
value: function dicomlab2RGB8(dicomlab) {
|
|
1433
|
+
return Colors.dicomlab2RGB(dicomlab).map(function (n) {
|
|
1434
|
+
return roundClamp(n * 255.0, 255);
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// 8 bit sRGB (array or typed array) -> 16 bit DICOM CIELab, rounded and clamped
|
|
1439
|
+
}, {
|
|
1440
|
+
key: "rgb82DICOMLAB",
|
|
1441
|
+
value: function rgb82DICOMLAB(rgb) {
|
|
1442
|
+
return Colors.rgb2DICOMLAB(Array.from(rgb, function (n) {
|
|
1443
|
+
return n / 255.0;
|
|
1444
|
+
})).map(function (n) {
|
|
1445
|
+
return roundClamp(n, 65535);
|
|
1446
|
+
});
|
|
1447
|
+
}
|
|
1388
1448
|
}, {
|
|
1389
1449
|
key: "dicomlab2LAB",
|
|
1390
1450
|
value: function dicomlab2LAB(dicomlab) {
|
|
@@ -1413,7 +1473,8 @@ var Colors = /*#__PURE__*/function () {
|
|
|
1413
1473
|
}, {
|
|
1414
1474
|
key: "gammaCorrection",
|
|
1415
1475
|
value: function gammaCorrection(n) {
|
|
1416
|
-
|
|
1476
|
+
// sRGB transfer function (IEC 61966-2-1), linear to gamma-encoded
|
|
1477
|
+
if (n <= 0.0031308) {
|
|
1417
1478
|
return 12.92 * n;
|
|
1418
1479
|
} else {
|
|
1419
1480
|
return 1.055 * Math.pow(n, 1 / 2.4) - 0.055;
|
|
@@ -1422,27 +1483,39 @@ var Colors = /*#__PURE__*/function () {
|
|
|
1422
1483
|
}, {
|
|
1423
1484
|
key: "invGammaCorrection",
|
|
1424
1485
|
value: function invGammaCorrection(n) {
|
|
1425
|
-
|
|
1486
|
+
// sRGB transfer function (IEC 61966-2-1), gamma-encoded to linear
|
|
1487
|
+
if (n <= 0.04045) {
|
|
1426
1488
|
return n / 12.92;
|
|
1427
1489
|
} else {
|
|
1428
1490
|
return Math.pow((n + 0.055) / 1.055, 2.4);
|
|
1429
1491
|
}
|
|
1430
1492
|
}
|
|
1493
|
+
|
|
1494
|
+
// sRGB -> CIE XYZ relative to D50, as DICOM CIELab requires (not D65)
|
|
1431
1495
|
}, {
|
|
1432
1496
|
key: "rgb2XYZ",
|
|
1433
1497
|
value: function rgb2XYZ(rgb) {
|
|
1498
|
+
// sRGB to linear RGB
|
|
1434
1499
|
var R = Colors.invGammaCorrection(rgb[0]);
|
|
1435
1500
|
var G = Colors.invGammaCorrection(rgb[1]);
|
|
1436
1501
|
var B = Colors.invGammaCorrection(rgb[2]);
|
|
1437
|
-
|
|
1502
|
+
|
|
1503
|
+
// linear RGB to CIE XYZ (D65)
|
|
1504
|
+
var X65 = 506752.0 / 1228815.0 * R + 87881.0 / 245763.0 * G + 12673.0 / 70218.0 * B;
|
|
1505
|
+
var Y65 = 87098.0 / 409605.0 * R + 175762.0 / 245763.0 * G + 12673.0 / 175545.0 * B;
|
|
1506
|
+
var Z65 = 7918.0 / 409605.0 * R + 87881.0 / 737289.0 * G + 1001167.0 / 1053270.0 * B;
|
|
1507
|
+
|
|
1508
|
+
// chromatic adaptation D65 to D50 (linear Bradford)
|
|
1509
|
+
return [1.0479297925449969 * X65 + 0.022946870601609652 * Y65 - 0.05019226628920524 * Z65, 0.02962780877005599 * X65 + 0.9904344267538799 * Y65 - 0.017073799063418826 * Z65, -0.009243040646204504 * X65 + 0.015055191490298152 * Y65 + 0.7518742814281371 * Z65];
|
|
1438
1510
|
}
|
|
1511
|
+
|
|
1512
|
+
// CIE XYZ relative to D50 -> CIELab
|
|
1439
1513
|
}, {
|
|
1440
1514
|
key: "xyz2LAB",
|
|
1441
1515
|
value: function xyz2LAB(xyz) {
|
|
1442
|
-
var
|
|
1443
|
-
var
|
|
1444
|
-
var
|
|
1445
|
-
var Z = xyz[2] / whitePoint[2];
|
|
1516
|
+
var X = xyz[0] / D50_WHITEPOINT_XYZ[0];
|
|
1517
|
+
var Y = xyz[1] / D50_WHITEPOINT_XYZ[1];
|
|
1518
|
+
var Z = xyz[2] / D50_WHITEPOINT_XYZ[2];
|
|
1446
1519
|
X = Colors.labf(X);
|
|
1447
1520
|
Y = Colors.labf(Y);
|
|
1448
1521
|
Z = Colors.labf(Z);
|
|
@@ -1453,50 +1526,58 @@ var Colors = /*#__PURE__*/function () {
|
|
|
1453
1526
|
value: function lab2RGB(lab) {
|
|
1454
1527
|
return Colors.xyz2RGB(Colors.lab2XYZ(lab));
|
|
1455
1528
|
}
|
|
1529
|
+
|
|
1530
|
+
// CIELab -> CIE XYZ relative to D50
|
|
1456
1531
|
}, {
|
|
1457
1532
|
key: "lab2XYZ",
|
|
1458
1533
|
value: function lab2XYZ(lab) {
|
|
1459
1534
|
var L = (lab[0] + 16) / 116;
|
|
1460
1535
|
var a = L + lab[1] / 500;
|
|
1461
1536
|
var b = L - lab[2] / 200;
|
|
1462
|
-
|
|
1463
|
-
return [whitePoint[0] * Colors.labfInv(a), whitePoint[1] * Colors.labfInv(L), whitePoint[2] * Colors.labfInv(b)];
|
|
1537
|
+
return [D50_WHITEPOINT_XYZ[0] * Colors.labfInv(a), D50_WHITEPOINT_XYZ[1] * Colors.labfInv(L), D50_WHITEPOINT_XYZ[2] * Colors.labfInv(b)];
|
|
1464
1538
|
}
|
|
1539
|
+
|
|
1540
|
+
// CIE XYZ relative to D50 -> sRGB, clipped per channel to [0, 1]
|
|
1465
1541
|
}, {
|
|
1466
1542
|
key: "xyz2RGB",
|
|
1467
1543
|
value: function xyz2RGB(xyz) {
|
|
1468
|
-
var
|
|
1469
|
-
|
|
1470
|
-
|
|
1544
|
+
var _xyz = _slicedToArray(xyz, 3),
|
|
1545
|
+
X = _xyz[0],
|
|
1546
|
+
Y = _xyz[1],
|
|
1547
|
+
Z = _xyz[2];
|
|
1471
1548
|
|
|
1472
|
-
|
|
1473
|
-
var
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
R1 -= minimumComponent;
|
|
1477
|
-
G1 -= minimumComponent;
|
|
1478
|
-
B1 -= minimumComponent;
|
|
1479
|
-
}
|
|
1549
|
+
// chromatic adaptation D50 to D65 (linear Bradford)
|
|
1550
|
+
var X65 = 0.955473421488075 * X - 0.02309845494876471 * Y + 0.06325924320057072 * Z;
|
|
1551
|
+
var Y65 = -0.0283697093338637 * X + 1.0099953980813041 * Y + 0.021041441191917323 * Z;
|
|
1552
|
+
var Z65 = 0.012314014864481998 * X - 0.020507649298898964 * Y + 1.330365926242124 * Z;
|
|
1480
1553
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1554
|
+
// CIE XYZ (D65) to linear RGB
|
|
1555
|
+
var R1 = 12831.0 / 3959.0 * X65 - 329.0 / 214.0 * Y65 - 1974.0 / 3959.0 * Z65;
|
|
1556
|
+
var G1 = -851781 / 878810.0 * X65 + 1648619.0 / 878810.0 * Y65 + 36519.0 / 878810.0 * Z65;
|
|
1557
|
+
var B1 = 705.0 / 12673.0 * X65 - 2585.0 / 12673.0 * Y65 + 705.0 / 667.0 * Z65;
|
|
1558
|
+
|
|
1559
|
+
// Clip to the sRGB gamut (also makes sure that gamma encoding is
|
|
1560
|
+
// well-defined), then transform from linear RGB to sRGB
|
|
1561
|
+
return [Colors.gammaCorrection(clamp01(R1)), Colors.gammaCorrection(clamp01(G1)), Colors.gammaCorrection(clamp01(B1))];
|
|
1483
1562
|
}
|
|
1484
1563
|
}, {
|
|
1485
1564
|
key: "labf",
|
|
1486
1565
|
value: function labf(n) {
|
|
1487
|
-
|
|
1488
|
-
|
|
1566
|
+
// epsilon = (6/29)^3 = 216/24389, kappa = (29/3)^3 = 24389/27
|
|
1567
|
+
if (n > 216.0 / 24389.0) {
|
|
1568
|
+
return Math.cbrt(n);
|
|
1489
1569
|
} else {
|
|
1490
|
-
return
|
|
1570
|
+
return (24389.0 / 27.0 * n + 16.0) / 116.0;
|
|
1491
1571
|
}
|
|
1492
1572
|
}
|
|
1493
1573
|
}, {
|
|
1494
1574
|
key: "labfInv",
|
|
1495
1575
|
value: function labfInv(n) {
|
|
1496
|
-
|
|
1576
|
+
// n > 6/29 <=> n^3 > epsilon
|
|
1577
|
+
if (n > 6.0 / 29.0) {
|
|
1497
1578
|
return n * n * n;
|
|
1498
1579
|
} else {
|
|
1499
|
-
return
|
|
1580
|
+
return (116.0 * n - 16.0) / (24389.0 / 27.0);
|
|
1500
1581
|
}
|
|
1501
1582
|
}
|
|
1502
1583
|
}]);
|
|
@@ -1521,9 +1602,11 @@ var AsyncDicomReader = /*#__PURE__*/function () {
|
|
|
1521
1602
|
this.isLittleEndian = options === null || options === void 0 ? void 0 : options.isLittleEndian;
|
|
1522
1603
|
// Default maxFragmentSize is 128 MB (128 * 1024 * 1024 bytes)
|
|
1523
1604
|
this.maxFragmentSize = (_options$maxFragmentS = options === null || options === void 0 ? void 0 : options.maxFragmentSize) !== null && _options$maxFragmentS !== void 0 ? _options$maxFragmentS : 128 * 1024 * 1024;
|
|
1524
|
-
this.stream = new core.ReadBufferStream(null,
|
|
1605
|
+
this.stream = new core.ReadBufferStream(null, _objectSpread2(_objectSpread2({
|
|
1525
1606
|
clearBuffers: true
|
|
1526
|
-
}, options)
|
|
1607
|
+
}, options), {}, {
|
|
1608
|
+
littleEndian: this.isLittleEndian
|
|
1609
|
+
}));
|
|
1527
1610
|
}
|
|
1528
1611
|
|
|
1529
1612
|
/** Sentinel returned when stream is Part 10 but has no preamble (starts with meta). */
|
|
@@ -12002,12 +12085,8 @@ var Cornerstone3D = {
|
|
|
12002
12085
|
CORNERSTONE_3D_TAG: CORNERSTONE_3D_TAG
|
|
12003
12086
|
};
|
|
12004
12087
|
|
|
12005
|
-
// TODO: Is there a better name for this? RGBAInt?
|
|
12006
|
-
// Should we move it to Colors.js
|
|
12007
12088
|
function dicomlab2RGBA(cielab) {
|
|
12008
|
-
var rgba = Colors.
|
|
12009
|
-
return Math.round(x * 255);
|
|
12010
|
-
});
|
|
12089
|
+
var rgba = Colors.dicomlab2RGB8(cielab);
|
|
12011
12090
|
rgba.push(255);
|
|
12012
12091
|
return rgba;
|
|
12013
12092
|
}
|
|
@@ -15852,4 +15931,4 @@ exports.derivations = derivations;
|
|
|
15852
15931
|
exports.normalizers = normalizers;
|
|
15853
15932
|
exports.sr = sr;
|
|
15854
15933
|
exports.utilities = utilities;
|
|
15855
|
-
//# sourceMappingURL=dcmjs.shared
|
|
15934
|
+
//# sourceMappingURL=dcmjs.shared---E7clvy.cjs.map
|