@dcmjs-org/dcmjs 1.0.0-beta.16 → 1.0.0-beta.18

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dcmjs = require('./dcmjs.shared-D1MD8zKQ.cjs');
5
+ var dcmjs = require('./dcmjs.shared-CKG7Js9d.cjs');
6
6
  var core = require('@dcmjs-org/core');
7
7
 
8
8
 
package/build/dcmjs.es.js CHANGED
@@ -1,3 +1,3 @@
1
- export { D as DICOMWEB, j as adapters, k as anonymizer, l as async, m as constants, n as data, o as default, p as derivations, q as normalizers, s as sr, u as utilities } from './dcmjs.shared-B2D8KPlB.js';
1
+ export { D as DICOMWEB, j as adapters, k as anonymizer, l as async, m as constants, n as data, o as default, p as derivations, q as normalizers, s as sr, u as utilities } from './dcmjs.shared-BLrcKS2A.js';
2
2
  export { log } from '@dcmjs-org/core';
3
3
  //# sourceMappingURL=dcmjs.es.js.map
package/build/dcmjs.js CHANGED
@@ -7759,7 +7759,12 @@
7759
7759
  value: function slice() {
7760
7760
  var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
7761
7761
  var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;
7762
- if (start === end) {
7762
+ // Clamp to the data held, as ArrayBuffer.prototype.slice does.
7763
+ // https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
7764
+ if (end > this.byteLength) {
7765
+ end = this.byteLength;
7766
+ }
7767
+ if (end <= start) {
7763
7768
  return new Uint8Array(0).buffer;
7764
7769
  }
7765
7770
  var index = this.findStart(start);
@@ -10495,6 +10500,14 @@
10495
10500
  } else if (this.type == 'OB') {
10496
10501
  bytes = stream.readUint8Array(length);
10497
10502
  }*/
10503
+ // A declared length longer than the data present means a
10504
+ // truncated or malformed file: read the bytes that are present.
10505
+ // https://github.com/dcmjs-org/dcmjs/security/advisories/GHSA-xwvm-687g-rm36
10506
+ var available = stream.endOffset - stream.offset;
10507
+ if (length > available) {
10508
+ validationLog.warn("".concat(this.type, " value declares ").concat(length, " bytes but only ").concat(available, " are available - reading the available bytes"));
10509
+ length = available;
10510
+ }
10498
10511
  bytes = stream.getBuffer(stream.offset, stream.offset + length);
10499
10512
  stream.increment(length);
10500
10513
  return [bytes];
@@ -11136,6 +11149,8 @@
11136
11149
  throw new Error("SequenceOfItems.read needs readOptions.readItem to parse the items");
11137
11150
  }
11138
11151
  elements.push(readOptions.readItem(itemStream, syntax));
11152
+ } else {
11153
+ elements.push({});
11139
11154
  }
11140
11155
  if (!undefLength && read == sqlength) {
11141
11156
  break;
@@ -16410,25 +16425,65 @@
16410
16425
  //
16411
16426
  // Handle DICOM and CIELAB colors
16412
16427
  // based on:
16413
- // https://github.com/michaelonken/dcmtk/blob/3c68f0e882e22e6d9e2a42f836332c0ca21b3e7f/dcmiod/libsrc/cielabutil.cc
16428
+ // https://github.com/DCMTK/dcmtk/blob/88105877c3b610e23fc9422ba6a84af85552f5dd/dcmiod/libsrc/cielabutil.cc
16414
16429
  //
16415
16430
  // RGB here refers to sRGB 0-1 per component.
16416
16431
  // dicomlab is CIELAB values as defined in the dicom standard
16417
- // XYZ is CIEXYZ convention
16418
- //
16419
- // TODO: needs a test suite
16420
- // TODO: only dicomlab2RGB tested on real data
16432
+ // XYZ is CIEXYZ convention, relative to the D50 white point (ICC PCS)
16421
16433
  //
16434
+ // DICOM encodes CIELab values in the same way as the ICC Profile Connection
16435
+ // Space (PCS, see PS3.3 C.10.7.1.1), i.e. relative to the D50 illuminant,
16436
+ // whereas the native white point of sRGB is D65. The conversions below
16437
+ // therefore chromatically adapt between the two using the linear Bradford
16438
+ // transform. Matrices and constants are those of the CSS Color Module Level 4
16439
+ // sample code (https://www.w3.org/TR/css-color-4/#color-conversion-code).
16422
16440
  //
16441
+
16442
+ // White points, defined by their 4-figure CIE x,y chromaticities.
16443
+ // D50 is intentionally [0.96430, 1, 0.82510] and not the ICC.1 PCS illuminant
16444
+ // [0.9642, 1, 0.8249]: this matches DCMTK, highdicom and CSS Color 4, and
16445
+ // encodes sRGB white as exactly 0x8080 in a* and b*.
16446
+ var D50_WHITEPOINT_XYZ = [0.3457 / 0.3585, 1.0, (1.0 - 0.3457 - 0.3585) / 0.3585];
16447
+ var D65_WHITEPOINT_XYZ = [0.3127 / 0.329, 1.0, (1.0 - 0.3127 - 0.329) / 0.329];
16448
+ function clamp01(n) {
16449
+ return Math.min(1.0, Math.max(0.0, n));
16450
+ }
16451
+
16452
+ // Rounds to the nearest integer in [0, max]; NaN (invalid input) gives 0
16453
+ function roundClamp(n, max) {
16454
+ if (!(n >= 0.0)) {
16455
+ return 0;
16456
+ }
16457
+ if (n > max) {
16458
+ return max;
16459
+ }
16460
+ return Math.floor(n + 0.5);
16461
+ }
16423
16462
  var Colors = /*#__PURE__*/function () {
16424
16463
  function Colors() {
16425
16464
  _classCallCheck(this, Colors);
16426
16465
  }
16427
16466
  return _createClass(Colors, null, [{
16467
+ key: "d50WhitePointXYZ",
16468
+ value:
16469
+ /**
16470
+ * White point of the D50 illuminant (ICC PCS), the reference white of
16471
+ * DICOM CIELab. Use this white with the XYZ values of rgb2XYZ, xyz2RGB,
16472
+ * lab2XYZ and xyz2LAB.
16473
+ */
16474
+ function d50WhitePointXYZ() {
16475
+ return [].concat(D50_WHITEPOINT_XYZ);
16476
+ }
16477
+
16478
+ /**
16479
+ * White point of the D65 illuminant, the native white of sRGB. No
16480
+ * conversion in this class uses it. Do not combine it with the XYZ
16481
+ * values of this class, which are relative to D50.
16482
+ */
16483
+ }, {
16428
16484
  key: "d65WhitePointXYZ",
16429
16485
  value: function d65WhitePointXYZ() {
16430
- // white points of D65 light point (CIELAB standard white point)
16431
- return [0.950456, 1.0, 1.088754];
16486
+ return [].concat(D65_WHITEPOINT_XYZ);
16432
16487
  }
16433
16488
  }, {
16434
16489
  key: "dicomlab2RGB",
@@ -16440,6 +16495,26 @@
16440
16495
  value: function rgb2DICOMLAB(rgb) {
16441
16496
  return Colors.lab2DICOMLAB(Colors.rgb2LAB(rgb));
16442
16497
  }
16498
+
16499
+ // 16 bit DICOM CIELab -> 8 bit sRGB, rounded and clamped
16500
+ }, {
16501
+ key: "dicomlab2RGB8",
16502
+ value: function dicomlab2RGB8(dicomlab) {
16503
+ return Colors.dicomlab2RGB(dicomlab).map(function (n) {
16504
+ return roundClamp(n * 255.0, 255);
16505
+ });
16506
+ }
16507
+
16508
+ // 8 bit sRGB (array or typed array) -> 16 bit DICOM CIELab, rounded and clamped
16509
+ }, {
16510
+ key: "rgb82DICOMLAB",
16511
+ value: function rgb82DICOMLAB(rgb) {
16512
+ return Colors.rgb2DICOMLAB(Array.from(rgb, function (n) {
16513
+ return n / 255.0;
16514
+ })).map(function (n) {
16515
+ return roundClamp(n, 65535);
16516
+ });
16517
+ }
16443
16518
  }, {
16444
16519
  key: "dicomlab2LAB",
16445
16520
  value: function dicomlab2LAB(dicomlab) {
@@ -16468,7 +16543,8 @@
16468
16543
  }, {
16469
16544
  key: "gammaCorrection",
16470
16545
  value: function gammaCorrection(n) {
16471
- if (n <= 0.0031306684425005883) {
16546
+ // sRGB transfer function (IEC 61966-2-1), linear to gamma-encoded
16547
+ if (n <= 0.0031308) {
16472
16548
  return 12.92 * n;
16473
16549
  } else {
16474
16550
  return 1.055 * Math.pow(n, 1 / 2.4) - 0.055;
@@ -16477,27 +16553,39 @@
16477
16553
  }, {
16478
16554
  key: "invGammaCorrection",
16479
16555
  value: function invGammaCorrection(n) {
16480
- if (n <= 0.0404482362771076) {
16556
+ // sRGB transfer function (IEC 61966-2-1), gamma-encoded to linear
16557
+ if (n <= 0.04045) {
16481
16558
  return n / 12.92;
16482
16559
  } else {
16483
16560
  return Math.pow((n + 0.055) / 1.055, 2.4);
16484
16561
  }
16485
16562
  }
16563
+
16564
+ // sRGB -> CIE XYZ relative to D50, as DICOM CIELab requires (not D65)
16486
16565
  }, {
16487
16566
  key: "rgb2XYZ",
16488
16567
  value: function rgb2XYZ(rgb) {
16568
+ // sRGB to linear RGB
16489
16569
  var R = Colors.invGammaCorrection(rgb[0]);
16490
16570
  var G = Colors.invGammaCorrection(rgb[1]);
16491
16571
  var B = Colors.invGammaCorrection(rgb[2]);
16492
- return [0.4123955889674142161 * R + 0.3575834307637148171 * G + 0.1804926473817015735 * B, 0.2125862307855955516 * R + 0.7151703037034108499 * G + 0.07220049864333622685 * B, 0.01929721549174694484 * R + 0.1191838645808485318 * G + 0.950497125131579766 * B];
16572
+
16573
+ // linear RGB to CIE XYZ (D65)
16574
+ var X65 = 506752.0 / 1228815.0 * R + 87881.0 / 245763.0 * G + 12673.0 / 70218.0 * B;
16575
+ var Y65 = 87098.0 / 409605.0 * R + 175762.0 / 245763.0 * G + 12673.0 / 175545.0 * B;
16576
+ var Z65 = 7918.0 / 409605.0 * R + 87881.0 / 737289.0 * G + 1001167.0 / 1053270.0 * B;
16577
+
16578
+ // chromatic adaptation D65 to D50 (linear Bradford)
16579
+ 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];
16493
16580
  }
16581
+
16582
+ // CIE XYZ relative to D50 -> CIELab
16494
16583
  }, {
16495
16584
  key: "xyz2LAB",
16496
16585
  value: function xyz2LAB(xyz) {
16497
- var whitePoint = Colors.d65WhitePointXYZ();
16498
- var X = xyz[0] / whitePoint[0];
16499
- var Y = xyz[1] / whitePoint[1];
16500
- var Z = xyz[2] / whitePoint[2];
16586
+ var X = xyz[0] / D50_WHITEPOINT_XYZ[0];
16587
+ var Y = xyz[1] / D50_WHITEPOINT_XYZ[1];
16588
+ var Z = xyz[2] / D50_WHITEPOINT_XYZ[2];
16501
16589
  X = Colors.labf(X);
16502
16590
  Y = Colors.labf(Y);
16503
16591
  Z = Colors.labf(Z);
@@ -16508,50 +16596,58 @@
16508
16596
  value: function lab2RGB(lab) {
16509
16597
  return Colors.xyz2RGB(Colors.lab2XYZ(lab));
16510
16598
  }
16599
+
16600
+ // CIELab -> CIE XYZ relative to D50
16511
16601
  }, {
16512
16602
  key: "lab2XYZ",
16513
16603
  value: function lab2XYZ(lab) {
16514
16604
  var L = (lab[0] + 16) / 116;
16515
16605
  var a = L + lab[1] / 500;
16516
16606
  var b = L - lab[2] / 200;
16517
- var whitePoint = Colors.d65WhitePointXYZ();
16518
- return [whitePoint[0] * Colors.labfInv(a), whitePoint[1] * Colors.labfInv(L), whitePoint[2] * Colors.labfInv(b)];
16607
+ return [D50_WHITEPOINT_XYZ[0] * Colors.labfInv(a), D50_WHITEPOINT_XYZ[1] * Colors.labfInv(L), D50_WHITEPOINT_XYZ[2] * Colors.labfInv(b)];
16519
16608
  }
16609
+
16610
+ // CIE XYZ relative to D50 -> sRGB, clipped per channel to [0, 1]
16520
16611
  }, {
16521
16612
  key: "xyz2RGB",
16522
16613
  value: function xyz2RGB(xyz) {
16523
- var R1 = 3.2406 * xyz[0] - 1.5372 * xyz[1] - 0.4986 * xyz[2];
16524
- var G1 = -0.9689 * xyz[0] + 1.8758 * xyz[1] + 0.0415 * xyz[2];
16525
- var B1 = 0.0557 * xyz[0] - 0.204 * xyz[1] + 1.057 * xyz[2];
16614
+ var _xyz = _slicedToArray(xyz, 3),
16615
+ X = _xyz[0],
16616
+ Y = _xyz[1],
16617
+ Z = _xyz[2];
16526
16618
 
16527
- /* Force nonnegative values so that gamma correction is well-defined. */
16528
- var minimumComponent = Math.min(R1, G1);
16529
- minimumComponent = Math.min(minimumComponent, B1);
16530
- if (minimumComponent < 0) {
16531
- R1 -= minimumComponent;
16532
- G1 -= minimumComponent;
16533
- B1 -= minimumComponent;
16534
- }
16619
+ // chromatic adaptation D50 to D65 (linear Bradford)
16620
+ var X65 = 0.955473421488075 * X - 0.02309845494876471 * Y + 0.06325924320057072 * Z;
16621
+ var Y65 = -0.0283697093338637 * X + 1.0099953980813041 * Y + 0.021041441191917323 * Z;
16622
+ var Z65 = 0.012314014864481998 * X - 0.020507649298898964 * Y + 1.330365926242124 * Z;
16623
+
16624
+ // CIE XYZ (D65) to linear RGB
16625
+ var R1 = 12831.0 / 3959.0 * X65 - 329.0 / 214.0 * Y65 - 1974.0 / 3959.0 * Z65;
16626
+ var G1 = -851781 / 878810.0 * X65 + 1648619.0 / 878810.0 * Y65 + 36519.0 / 878810.0 * Z65;
16627
+ var B1 = 705.0 / 12673.0 * X65 - 2585.0 / 12673.0 * Y65 + 705.0 / 667.0 * Z65;
16535
16628
 
16536
- /* Transform from RGB to R'G'B' */
16537
- return [Colors.gammaCorrection(R1), Colors.gammaCorrection(G1), Colors.gammaCorrection(B1)];
16629
+ // Clip to the sRGB gamut (also makes sure that gamma encoding is
16630
+ // well-defined), then transform from linear RGB to sRGB
16631
+ return [Colors.gammaCorrection(clamp01(R1)), Colors.gammaCorrection(clamp01(G1)), Colors.gammaCorrection(clamp01(B1))];
16538
16632
  }
16539
16633
  }, {
16540
16634
  key: "labf",
16541
16635
  value: function labf(n) {
16542
- if (n >= 8.85645167903563082e-3) {
16543
- return Math.pow(n, 0.333333333333333);
16636
+ // epsilon = (6/29)^3 = 216/24389, kappa = (29/3)^3 = 24389/27
16637
+ if (n > 216.0 / 24389.0) {
16638
+ return Math.cbrt(n);
16544
16639
  } else {
16545
- return 841.0 / 108.0 * n + 4.0 / 29.0;
16640
+ return (24389.0 / 27.0 * n + 16.0) / 116.0;
16546
16641
  }
16547
16642
  }
16548
16643
  }, {
16549
16644
  key: "labfInv",
16550
16645
  value: function labfInv(n) {
16551
- if (n >= 0.206896551724137931) {
16646
+ // n > 6/29 <=> n^3 > epsilon
16647
+ if (n > 6.0 / 29.0) {
16552
16648
  return n * n * n;
16553
16649
  } else {
16554
- return 108.0 / 841.0 * (n - 4.0 / 29.0);
16650
+ return (116.0 * n - 16.0) / (24389.0 / 27.0);
16555
16651
  }
16556
16652
  }
16557
16653
  }]);
@@ -18402,16 +18498,10 @@
18402
18498
  //
18403
18499
  // shared
18404
18500
  var SpacingBetweenSlices = Math.abs(distance1 - distance0);
18405
- ds.SharedFunctionalGroupsSequence = {
18406
- PlaneOrientationSequence: {
18407
- ImageOrientationPatient: dataset0.ImageOrientationPatient
18408
- },
18409
- PixelMeasuresSequence: {
18410
- PixelSpacing: dataset0.PixelSpacing,
18411
- SpacingBetweenSlices: SpacingBetweenSlices,
18412
- SliceThickness: SpacingBetweenSlices
18413
- }
18414
- };
18501
+ ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(dataset0, {
18502
+ SpacingBetweenSlices: SpacingBetweenSlices,
18503
+ SliceThickness: SpacingBetweenSlices
18504
+ });
18415
18505
  ds.ReferencedSeriesSequence = {
18416
18506
  SeriesInstanceUID: dataset0.SeriesInstanceUID,
18417
18507
  ReferencedInstanceSequence: []
@@ -18424,15 +18514,12 @@
18424
18514
  // and set the referenced series uid
18425
18515
  distanceDatasetPairs.forEach(function (pair) {
18426
18516
  var dataset = pair[1];
18427
- ds.PerFrameFunctionalGroupsSequence.push({
18428
- PlanePositionSequence: {
18429
- ImagePositionPatient: dataset.ImagePositionPatient
18430
- },
18517
+ ds.PerFrameFunctionalGroupsSequence.push(_objectSpread2(_objectSpread2({}, ImageNormalizer.planePositionGroup(dataset)), {}, {
18431
18518
  FrameVOILUTSequence: {
18432
18519
  WindowCenter: dataset.WindowCenter,
18433
18520
  WindowWidth: dataset.WindowWidth
18434
18521
  }
18435
- });
18522
+ }));
18436
18523
  ds.ReferencedSeriesSequence.ReferencedInstanceSequence.push({
18437
18524
  ReferencedSOPClassUID: dataset.SOPClassUID,
18438
18525
  ReferencedSOPInstanceUID: dataset.SOPInstanceUID
@@ -18474,7 +18561,11 @@
18474
18561
  ds.PresentationLUTShape = "IDENTITY";
18475
18562
  }
18476
18563
  if (!ds.SharedFunctionalGroupsSequence) {
18477
- log.error("Can only process multiframe data with SharedFunctionalGroupsSequence");
18564
+ log.warn("Missing SharedFunctionalGroupsSequence; using the top-level image plane attributes");
18565
+ ds.SharedFunctionalGroupsSequence = ImageNormalizer.sharedImagePlaneGroups(ds, {
18566
+ SliceThickness: ds.SliceThickness,
18567
+ SpacingBetweenSlices: ds.SpacingBetweenSlices
18568
+ });
18478
18569
  }
18479
18570
 
18480
18571
  // TODO: special case!
@@ -18495,9 +18586,22 @@
18495
18586
  RescaleSlope: rescaleSlope,
18496
18587
  RescaleType: "US"
18497
18588
  };
18498
- var frameNumber = 1;
18499
- this.datasets.forEach(function (dataset) {
18500
- if (ds.NumberOfFrames === 1) ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
18589
+ var frameCount = this.datasets.length;
18590
+ if (!ds.PerFrameFunctionalGroupsSequence) {
18591
+ // One item per declared frame, all at the top-level position
18592
+ frameCount = Math.max(frameCount, Number(ds.NumberOfFrames) || 0);
18593
+ ds.PerFrameFunctionalGroupsSequence = Array.from({
18594
+ length: frameCount
18595
+ }, function () {
18596
+ return ImageNormalizer.planePositionGroup(ds);
18597
+ });
18598
+ } else if (!Array.isArray(ds.PerFrameFunctionalGroupsSequence)) {
18599
+ ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
18600
+ }
18601
+ for (var frameNumber = 1; frameNumber <= frameCount; frameNumber++) {
18602
+ var _ds$PerFrameFunctiona, _ref;
18603
+ var dataset = this.datasets[frameNumber - 1] || {};
18604
+ (_ds$PerFrameFunctiona = ds.PerFrameFunctionalGroupsSequence)[_ref = frameNumber - 1] || (_ds$PerFrameFunctiona[_ref] = {});
18501
18605
  ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence = {
18502
18606
  FrameAcquisitionDuration: 0,
18503
18607
  StackID: 1,
@@ -18510,8 +18614,7 @@
18510
18614
  frameContentSequence.FrameAcquisitionDateTime = frameTime;
18511
18615
  frameContentSequence.FrameReferenceDateTime = frameTime;
18512
18616
  }
18513
- frameNumber++;
18514
- });
18617
+ }
18515
18618
 
18516
18619
  //
18517
18620
  // TODO: convert this to shared functional group not top level element
@@ -18596,6 +18699,27 @@
18596
18699
  value: function vec3Dot(a, b) {
18597
18700
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
18598
18701
  }
18702
+ }, {
18703
+ key: "sharedImagePlaneGroups",
18704
+ value: function sharedImagePlaneGroups(dataset, pixelMeasures) {
18705
+ return {
18706
+ PlaneOrientationSequence: {
18707
+ ImageOrientationPatient: dataset.ImageOrientationPatient
18708
+ },
18709
+ PixelMeasuresSequence: _objectSpread2({
18710
+ PixelSpacing: dataset.PixelSpacing
18711
+ }, pixelMeasures)
18712
+ };
18713
+ }
18714
+ }, {
18715
+ key: "planePositionGroup",
18716
+ value: function planePositionGroup(dataset) {
18717
+ return {
18718
+ PlanePositionSequence: {
18719
+ ImagePositionPatient: dataset.ImagePositionPatient
18720
+ }
18721
+ };
18722
+ }
18599
18723
  }]);
18600
18724
  }(Normalizer);
18601
18725
  var MRImageNormalizer = /*#__PURE__*/function (_ImageNormalizer) {
@@ -21378,7 +21502,7 @@
21378
21502
  var _matrix$shape = _slicedToArray(matrix.shape, 2),
21379
21503
  rows = _matrix$shape[0],
21380
21504
  cols = _matrix$shape[1];
21381
- var result = ndarray(new Uint8Array(rows * cols), [rows, cols]);
21505
+ var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
21382
21506
  for (var i = 0; i < rows; i++) {
21383
21507
  for (var j = 0; j < cols; j++) {
21384
21508
  result.set(i, j, matrix.get(i, cols - 1 - j));
@@ -21397,7 +21521,7 @@
21397
21521
  var _matrix$shape2 = _slicedToArray(matrix.shape, 2),
21398
21522
  rows = _matrix$shape2[0],
21399
21523
  cols = _matrix$shape2[1];
21400
- var result = ndarray(new Uint8Array(rows * cols), [rows, cols]);
21524
+ var result = ndarray(new matrix.data.constructor(rows * cols), [rows, cols]);
21401
21525
  for (var j = 0; j < cols; j++) {
21402
21526
  for (var i = 0; i < rows; i++) {
21403
21527
  result.set(i, j, matrix.get(rows - 1 - i, j));
@@ -21416,7 +21540,7 @@
21416
21540
  var _matrix$shape = _slicedToArray(matrix.shape, 2),
21417
21541
  rows = _matrix$shape[0],
21418
21542
  cols = _matrix$shape[1];
21419
- var result = ndarray(new Uint8Array(rows * cols), [cols, rows]);
21543
+ var result = ndarray(new matrix.data.constructor(rows * cols), [cols, rows]);
21420
21544
  var resultColsMinus1 = result.shape[1] - 1;
21421
21545
  for (var i = 0; i < rows; i++) {
21422
21546
  for (var j = 0; j < cols; j++) {
@@ -27053,12 +27177,8 @@
27053
27177
  CORNERSTONE_3D_TAG: CORNERSTONE_3D_TAG
27054
27178
  };
27055
27179
 
27056
- // TODO: Is there a better name for this? RGBAInt?
27057
- // Should we move it to Colors.js
27058
27180
  function dicomlab2RGBA(cielab) {
27059
- var rgba = Colors.dicomlab2RGB(cielab).map(function (x) {
27060
- return Math.round(x * 255);
27061
- });
27181
+ var rgba = Colors.dicomlab2RGB8(cielab);
27062
27182
  rgba.push(255);
27063
27183
  return rgba;
27064
27184
  }