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