image-js 1.0.0 → 1.2.0
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/dist/image-js.esm.js +1041 -245
- package/dist/image-js.esm.js.map +1 -1
- package/dist/image-js.esm.min.js +2 -2
- package/dist/image-js.esm.min.js.map +1 -1
- package/dist/image-js.umd.js +1009 -211
- package/dist/image-js.umd.js.map +1 -1
- package/dist/image-js.umd.min.js +2 -2
- package/dist/image-js.umd.min.js.map +1 -1
- package/dist-types/image-js.d.ts +4 -5
- package/lib/Mask.d.ts +1 -1
- package/lib/Mask.js +1 -1
- package/lib/draw/drawLineOnImage.d.ts.map +1 -1
- package/lib/draw/drawLineOnImage.js.map +1 -1
- package/lib/extra/draw/draw_text.d.ts +47 -0
- package/lib/extra/draw/draw_text.d.ts.map +1 -0
- package/lib/extra/draw/draw_text.js +108 -0
- package/lib/extra/draw/draw_text.js.map +1 -0
- package/lib/extra/draw/index.d.ts +3 -0
- package/lib/extra/draw/index.d.ts.map +1 -0
- package/lib/extra/draw/index.js +3 -0
- package/lib/extra/draw/index.js.map +1 -0
- package/lib/{ssim → extra/ssim}/compute_dssim.d.ts +2 -2
- package/lib/extra/ssim/compute_dssim.d.ts.map +1 -0
- package/lib/{ssim → extra/ssim}/compute_dssim.js +1 -1
- package/lib/extra/ssim/compute_dssim.js.map +1 -0
- package/lib/{ssim → extra/ssim}/compute_ssim.d.ts +1 -1
- package/lib/extra/ssim/compute_ssim.d.ts.map +1 -0
- package/lib/{ssim → extra/ssim}/compute_ssim.js +2 -2
- package/lib/extra/ssim/compute_ssim.js.map +1 -0
- package/lib/extra/ssim/index.d.ts +3 -0
- package/lib/extra/ssim/index.d.ts.map +1 -0
- package/lib/extra/ssim/index.js +3 -0
- package/lib/extra/ssim/index.js.map +1 -0
- package/lib/featureMatching/matching/filterEuclideanDistance.d.ts.map +1 -1
- package/lib/featureMatching/matching/filterEuclideanDistance.js +6 -7
- package/lib/featureMatching/matching/filterEuclideanDistance.js.map +1 -1
- package/lib/featureMatching/matching/filterSmallestDistanceMatches.d.ts.map +1 -1
- package/lib/featureMatching/matching/filterSmallestDistanceMatches.js +6 -3
- package/lib/featureMatching/matching/filterSmallestDistanceMatches.js.map +1 -1
- package/lib/featureMatching/utils/sortByDistance.d.ts.map +1 -1
- package/lib/featureMatching/utils/sortByDistance.js +3 -1
- package/lib/featureMatching/utils/sortByDistance.js.map +1 -1
- package/lib/featureMatching/utils/sortBySourceDest.d.ts.map +1 -1
- package/lib/featureMatching/utils/sortBySourceDest.js +6 -2
- package/lib/featureMatching/utils/sortBySourceDest.js.map +1 -1
- package/lib/index_browser.d.ts +3 -0
- package/lib/index_browser.d.ts.map +1 -0
- package/lib/index_browser.js +5 -0
- package/lib/index_browser.js.map +1 -0
- package/lib/index_full.d.ts +4 -0
- package/lib/index_full.d.ts.map +1 -0
- package/lib/index_full.js +5 -0
- package/lib/index_full.js.map +1 -0
- package/lib/load/decode.d.ts.map +1 -1
- package/lib/load/decode.js +2 -0
- package/lib/load/decode.js.map +1 -1
- package/lib/load/decodeBmp.d.ts +8 -0
- package/lib/load/decodeBmp.d.ts.map +1 -0
- package/lib/load/decodeBmp.js +36 -0
- package/lib/load/decodeBmp.js.map +1 -0
- package/lib/load/decodePng.d.ts.map +1 -1
- package/lib/load/decodePng.js +29 -5
- package/lib/load/decodePng.js.map +1 -1
- package/lib/load/decodeTiff.d.ts.map +1 -1
- package/lib/load/decodeTiff.js +44 -21
- package/lib/load/decodeTiff.js.map +1 -1
- package/lib/load/read.d.ts +1 -1
- package/lib/load/read.js +1 -1
- package/lib/maskAnalysis/utils/getMbrAngle.d.ts.map +1 -1
- package/lib/maskAnalysis/utils/getMbrAngle.js +2 -1
- package/lib/maskAnalysis/utils/getMbrAngle.js.map +1 -1
- package/lib/maskAnalysis/utils/monotoneChainConvexHull.d.ts.map +1 -1
- package/lib/maskAnalysis/utils/monotoneChainConvexHull.js +2 -1
- package/lib/maskAnalysis/utils/monotoneChainConvexHull.js.map +1 -1
- package/lib/save/encodeBmp.d.ts +4 -4
- package/lib/save/encodeBmp.d.ts.map +1 -1
- package/lib/save/encodeBmp.js +22 -14
- package/lib/save/encodeBmp.js.map +1 -1
- package/lib/save/write.d.ts +1 -1
- package/lib/save/write.js +1 -1
- package/lib/stack/load/decodeApng.d.ts +8 -0
- package/lib/stack/load/decodeApng.d.ts.map +1 -0
- package/lib/stack/load/decodeApng.js +60 -0
- package/lib/stack/load/decodeApng.js.map +1 -0
- package/lib/stack/load/decodeStack.d.ts.map +1 -1
- package/lib/stack/load/decodeStack.js +2 -0
- package/lib/stack/load/decodeStack.js.map +1 -1
- package/lib/utils/cross_platform.d.ts +8 -0
- package/lib/utils/cross_platform.d.ts.map +1 -1
- package/lib/utils/cross_platform.js +34 -2
- package/lib/utils/cross_platform.js.map +1 -1
- package/lib/utils/geometry/points.d.ts.map +1 -1
- package/lib/utils/geometry/points.js +3 -1
- package/lib/utils/geometry/points.js.map +1 -1
- package/lib/utils/geometry/removeClosePoints.d.ts.map +1 -1
- package/lib/utils/geometry/removeClosePoints.js +2 -1
- package/lib/utils/geometry/removeClosePoints.js.map +1 -1
- package/lib/utils/setBlendedPixel.d.ts +1 -1
- package/lib/utils/setBlendedPixel.js +1 -1
- package/lib/utils/setBlendedVisiblePixel.d.ts +1 -1
- package/lib/utils/setBlendedVisiblePixel.js +1 -1
- package/package.json +43 -29
- package/src/Mask.ts +1 -1
- package/src/draw/drawLineOnImage.ts +0 -1
- package/src/extra/draw/draw_text.ts +194 -0
- package/src/extra/draw/index.ts +2 -0
- package/src/{ssim → extra/ssim}/compute_dssim.ts +3 -3
- package/src/{ssim → extra/ssim}/compute_ssim.ts +3 -3
- package/src/extra/ssim/index.ts +2 -0
- package/src/featureMatching/matching/filterEuclideanDistance.ts +6 -13
- package/src/featureMatching/matching/filterSmallestDistanceMatches.ts +6 -9
- package/src/featureMatching/utils/sortByDistance.ts +3 -1
- package/src/featureMatching/utils/sortBySourceDest.ts +6 -2
- package/src/index_browser.ts +4 -0
- package/src/index_full.ts +4 -0
- package/src/load/decode.ts +2 -1
- package/src/load/decodeBmp.ts +37 -0
- package/src/load/decodePng.ts +39 -7
- package/src/load/decodeTiff.ts +53 -22
- package/src/load/read.ts +1 -1
- package/src/maskAnalysis/utils/getMbrAngle.ts +2 -1
- package/src/maskAnalysis/utils/monotoneChainConvexHull.ts +2 -1
- package/src/save/encodeBmp.ts +22 -15
- package/src/save/write.ts +1 -1
- package/src/stack/load/decodeApng.ts +71 -0
- package/src/stack/load/decodeStack.ts +2 -0
- package/src/utils/cross_platform.ts +47 -4
- package/src/utils/geometry/points.ts +3 -1
- package/src/utils/geometry/removeClosePoints.ts +2 -1
- package/src/utils/setBlendedPixel.ts +1 -1
- package/src/utils/setBlendedVisiblePixel.ts +1 -1
- package/lib/ssim/compute_dssim.d.ts.map +0 -1
- package/lib/ssim/compute_dssim.js.map +0 -1
- package/lib/ssim/compute_ssim.d.ts.map +0 -1
- package/lib/ssim/compute_ssim.js.map +0 -1
- package/lib/ssim/index.d.ts +0 -3
- package/lib/ssim/index.d.ts.map +0 -1
- package/lib/ssim/index.js +0 -3
- package/lib/ssim/index.js.map +0 -1
- package/src/ssim/index.ts +0 -2
package/dist/image-js.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* image-js v1.
|
|
2
|
+
* image-js v1.2.0
|
|
3
3
|
* Image processing and manipulation in JavaScript
|
|
4
4
|
* https://github.com/image-js/image-js#readme
|
|
5
5
|
*
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.IJS = {}));
|
|
12
12
|
})(this, (function (exports) { 'use strict';
|
|
13
13
|
|
|
14
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
14
15
|
function getDefaultExportFromCjs (x) {
|
|
15
16
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
16
17
|
}
|
|
@@ -5700,11 +5701,13 @@ ${indent}columns: ${matrix.columns}
|
|
|
5700
5701
|
* @returns Sorted points.
|
|
5701
5702
|
*/
|
|
5702
5703
|
function sortByColumnRow(points) {
|
|
5703
|
-
|
|
5704
|
+
const sortedPoints = points.slice();
|
|
5705
|
+
sortedPoints.sort((point1, point2) => {
|
|
5704
5706
|
if (point1.column < point2.column) return -1;
|
|
5705
5707
|
if (point1.column > point2.column) return 1;
|
|
5706
5708
|
return point1.row - point2.row;
|
|
5707
5709
|
});
|
|
5710
|
+
return sortedPoints;
|
|
5708
5711
|
}
|
|
5709
5712
|
|
|
5710
5713
|
/**
|
|
@@ -5796,35 +5799,35 @@ ${indent}columns: ${matrix.columns}
|
|
|
5796
5799
|
if (!Array.isArray(s)) return false;
|
|
5797
5800
|
let t = [],
|
|
5798
5801
|
r = [],
|
|
5799
|
-
|
|
5802
|
+
u = [];
|
|
5800
5803
|
for (const o of n.keys()) {
|
|
5801
5804
|
const s = n[o];
|
|
5802
|
-
i$2(s) && s[e$2] ?
|
|
5805
|
+
i$2(s) && s[e$2] ? u.push(s) : u.length ? r.push(s) : t.push(s);
|
|
5803
5806
|
}
|
|
5804
|
-
if (
|
|
5805
|
-
if (
|
|
5807
|
+
if (u.length) {
|
|
5808
|
+
if (u.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
5806
5809
|
if (s.length < t.length + r.length) return false;
|
|
5807
5810
|
const e = s.slice(0, t.length),
|
|
5808
5811
|
n = 0 === r.length ? [] : s.slice(-r.length),
|
|
5809
5812
|
i = s.slice(t.length, 0 === r.length ? Infinity : -r.length);
|
|
5810
|
-
return t.every((t, n) => o$2(t, e[n], c)) && r.every((t, e) => o$2(t, n[e], c)) && (0 ===
|
|
5813
|
+
return t.every((t, n) => o$2(t, e[n], c)) && r.every((t, e) => o$2(t, n[e], c)) && (0 === u.length || o$2(u[0], i, c));
|
|
5811
5814
|
}
|
|
5812
5815
|
return n.length === s.length && n.every((t, e) => o$2(t, s[e], c));
|
|
5813
5816
|
}
|
|
5814
5817
|
return Reflect.ownKeys(n).every(e => {
|
|
5815
5818
|
const r = n[e];
|
|
5816
|
-
return (e in s || i$2(
|
|
5817
|
-
var
|
|
5819
|
+
return (e in s || i$2(u = r) && "optional" === u[t$2]().matcherType) && o$2(r, s[e], c);
|
|
5820
|
+
var u;
|
|
5818
5821
|
});
|
|
5819
5822
|
}
|
|
5820
5823
|
return Object.is(s, n);
|
|
5821
5824
|
},
|
|
5822
5825
|
s$1 = e => {
|
|
5823
|
-
var n, o,
|
|
5824
|
-
return r$2(e) ? i$2(e) ? null != (n = null == (o = (
|
|
5826
|
+
var n, o, u;
|
|
5827
|
+
return r$2(e) ? i$2(e) ? null != (n = null == (o = (u = e[t$2]()).getSelectionKeys) ? void 0 : o.call(u)) ? n : [] : Array.isArray(e) ? c$1(e, s$1) : c$1(Object.values(e), s$1) : [];
|
|
5825
5828
|
},
|
|
5826
5829
|
c$1 = (t, e) => t.reduce((t, n) => t.concat(e(n)), []);
|
|
5827
|
-
function
|
|
5830
|
+
function u$2(...t) {
|
|
5828
5831
|
if (1 === t.length) {
|
|
5829
5832
|
const [e] = t;
|
|
5830
5833
|
return t => o$2(e, t, () => {});
|
|
@@ -5835,15 +5838,15 @@ ${indent}columns: ${matrix.columns}
|
|
|
5835
5838
|
}
|
|
5836
5839
|
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
|
|
5837
5840
|
}
|
|
5838
|
-
function
|
|
5841
|
+
function a$2(t) {
|
|
5839
5842
|
return Object.assign(t, {
|
|
5840
|
-
optional: () =>
|
|
5841
|
-
and: e =>
|
|
5842
|
-
or: e =>
|
|
5843
|
-
select: e => void 0 === e ?
|
|
5843
|
+
optional: () => h$2(t),
|
|
5844
|
+
and: e => d$1(t, e),
|
|
5845
|
+
or: e => y$1(t, e),
|
|
5846
|
+
select: e => void 0 === e ? v$1(t) : v$1(e, t)
|
|
5844
5847
|
});
|
|
5845
5848
|
}
|
|
5846
|
-
function
|
|
5849
|
+
function l$2(t) {
|
|
5847
5850
|
return Object.assign((t => Object.assign(t, {
|
|
5848
5851
|
[Symbol.iterator]() {
|
|
5849
5852
|
let n = 0;
|
|
@@ -5864,12 +5867,12 @@ ${indent}columns: ${matrix.columns}
|
|
|
5864
5867
|
};
|
|
5865
5868
|
}
|
|
5866
5869
|
}))(t), {
|
|
5867
|
-
optional: () =>
|
|
5868
|
-
select: e =>
|
|
5870
|
+
optional: () => l$2(h$2(t)),
|
|
5871
|
+
select: e => l$2(void 0 === e ? v$1(t) : v$1(e, t))
|
|
5869
5872
|
});
|
|
5870
5873
|
}
|
|
5871
|
-
function
|
|
5872
|
-
return
|
|
5874
|
+
function h$2(e) {
|
|
5875
|
+
return a$2({
|
|
5873
5876
|
[t$2]: () => ({
|
|
5874
5877
|
match: t => {
|
|
5875
5878
|
let n = {};
|
|
@@ -5896,9 +5899,14 @@ ${indent}columns: ${matrix.columns}
|
|
|
5896
5899
|
g$1 = (t, e) => {
|
|
5897
5900
|
for (const [n, r] of t.entries()) if (!e(r, n)) return false;
|
|
5898
5901
|
return true;
|
|
5902
|
+
},
|
|
5903
|
+
m$1 = (t, e) => {
|
|
5904
|
+
const n = Reflect.ownKeys(t);
|
|
5905
|
+
for (const r of n) if (!e(r, t[r])) return false;
|
|
5906
|
+
return true;
|
|
5899
5907
|
};
|
|
5900
|
-
function
|
|
5901
|
-
return
|
|
5908
|
+
function d$1(...e) {
|
|
5909
|
+
return a$2({
|
|
5902
5910
|
[t$2]: () => ({
|
|
5903
5911
|
match: t => {
|
|
5904
5912
|
let n = {};
|
|
@@ -5915,8 +5923,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
5915
5923
|
})
|
|
5916
5924
|
});
|
|
5917
5925
|
}
|
|
5918
|
-
function
|
|
5919
|
-
return
|
|
5926
|
+
function y$1(...e) {
|
|
5927
|
+
return a$2({
|
|
5920
5928
|
[t$2]: () => ({
|
|
5921
5929
|
match: t => {
|
|
5922
5930
|
let n = {};
|
|
@@ -5942,10 +5950,10 @@ ${indent}columns: ${matrix.columns}
|
|
|
5942
5950
|
})
|
|
5943
5951
|
};
|
|
5944
5952
|
}
|
|
5945
|
-
function
|
|
5953
|
+
function v$1(...e) {
|
|
5946
5954
|
const r = "string" == typeof e[0] ? e[0] : void 0,
|
|
5947
5955
|
i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
|
|
5948
|
-
return
|
|
5956
|
+
return a$2({
|
|
5949
5957
|
[t$2]: () => ({
|
|
5950
5958
|
match: t => {
|
|
5951
5959
|
let e = {
|
|
@@ -5962,81 +5970,83 @@ ${indent}columns: ${matrix.columns}
|
|
|
5962
5970
|
})
|
|
5963
5971
|
});
|
|
5964
5972
|
}
|
|
5965
|
-
function
|
|
5973
|
+
function b$2(t) {
|
|
5974
|
+
return true;
|
|
5975
|
+
}
|
|
5976
|
+
function w$2(t) {
|
|
5966
5977
|
return "number" == typeof t;
|
|
5967
5978
|
}
|
|
5968
|
-
function
|
|
5979
|
+
function S$1(t) {
|
|
5969
5980
|
return "string" == typeof t;
|
|
5970
5981
|
}
|
|
5971
|
-
function
|
|
5982
|
+
function j$1(t) {
|
|
5972
5983
|
return "bigint" == typeof t;
|
|
5973
5984
|
}
|
|
5974
|
-
const
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
j$1 = t => Object.assign(u$2(t), {
|
|
5985
|
+
const K = a$2(p$2(b$2)),
|
|
5986
|
+
O = a$2(p$2(b$2)),
|
|
5987
|
+
E = K,
|
|
5988
|
+
x$1 = t => Object.assign(a$2(t), {
|
|
5979
5989
|
startsWith: e => {
|
|
5980
|
-
return
|
|
5990
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.startsWith(n)))));
|
|
5981
5991
|
var n;
|
|
5982
5992
|
},
|
|
5983
5993
|
endsWith: e => {
|
|
5984
|
-
return
|
|
5994
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.endsWith(n)))));
|
|
5985
5995
|
var n;
|
|
5986
5996
|
},
|
|
5987
|
-
minLength: e =>
|
|
5988
|
-
length: e =>
|
|
5989
|
-
maxLength: e =>
|
|
5997
|
+
minLength: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length >= t))(e))),
|
|
5998
|
+
length: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length === t))(e))),
|
|
5999
|
+
maxLength: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length <= t))(e))),
|
|
5990
6000
|
includes: e => {
|
|
5991
|
-
return
|
|
6001
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.includes(n)))));
|
|
5992
6002
|
var n;
|
|
5993
6003
|
},
|
|
5994
6004
|
regex: e => {
|
|
5995
|
-
return
|
|
6005
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && Boolean(t.match(n))))));
|
|
5996
6006
|
var n;
|
|
5997
6007
|
}
|
|
5998
6008
|
}),
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
between: (e, n) =>
|
|
6002
|
-
lt: e =>
|
|
6003
|
-
gt: e =>
|
|
6004
|
-
lte: e =>
|
|
6005
|
-
gte: e =>
|
|
6006
|
-
int: () =>
|
|
6007
|
-
finite: () =>
|
|
6008
|
-
positive: () =>
|
|
6009
|
-
negative: () =>
|
|
6009
|
+
A = x$1(p$2(S$1)),
|
|
6010
|
+
N$1 = t => Object.assign(a$2(t), {
|
|
6011
|
+
between: (e, n) => N$1(d$1(t, ((t, e) => p$2(n => w$2(n) && t <= n && e >= n))(e, n))),
|
|
6012
|
+
lt: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e < t))(e))),
|
|
6013
|
+
gt: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e > t))(e))),
|
|
6014
|
+
lte: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e <= t))(e))),
|
|
6015
|
+
gte: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e >= t))(e))),
|
|
6016
|
+
int: () => N$1(d$1(t, p$2(t => w$2(t) && Number.isInteger(t)))),
|
|
6017
|
+
finite: () => N$1(d$1(t, p$2(t => w$2(t) && Number.isFinite(t)))),
|
|
6018
|
+
positive: () => N$1(d$1(t, p$2(t => w$2(t) && t > 0))),
|
|
6019
|
+
negative: () => N$1(d$1(t, p$2(t => w$2(t) && t < 0)))
|
|
6010
6020
|
}),
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
between: (e, n) =>
|
|
6014
|
-
lt: e =>
|
|
6015
|
-
gt: e =>
|
|
6016
|
-
lte: e =>
|
|
6017
|
-
gte: e =>
|
|
6018
|
-
positive: () =>
|
|
6019
|
-
negative: () =>
|
|
6021
|
+
P = N$1(p$2(w$2)),
|
|
6022
|
+
k$1 = t => Object.assign(a$2(t), {
|
|
6023
|
+
between: (e, n) => k$1(d$1(t, ((t, e) => p$2(n => j$1(n) && t <= n && e >= n))(e, n))),
|
|
6024
|
+
lt: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e < t))(e))),
|
|
6025
|
+
gt: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e > t))(e))),
|
|
6026
|
+
lte: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e <= t))(e))),
|
|
6027
|
+
gte: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e >= t))(e))),
|
|
6028
|
+
positive: () => k$1(d$1(t, p$2(t => j$1(t) && t > 0))),
|
|
6029
|
+
negative: () => k$1(d$1(t, p$2(t => j$1(t) && t < 0)))
|
|
6020
6030
|
}),
|
|
6021
|
-
|
|
6022
|
-
|
|
6031
|
+
T = k$1(p$2(j$1)),
|
|
6032
|
+
B = a$2(p$2(function (t) {
|
|
6023
6033
|
return "boolean" == typeof t;
|
|
6024
6034
|
})),
|
|
6025
|
-
|
|
6035
|
+
_ = a$2(p$2(function (t) {
|
|
6026
6036
|
return "symbol" == typeof t;
|
|
6027
6037
|
})),
|
|
6028
|
-
|
|
6038
|
+
W = a$2(p$2(function (t) {
|
|
6029
6039
|
return null == t;
|
|
6030
6040
|
})),
|
|
6031
|
-
|
|
6041
|
+
$$1 = a$2(p$2(function (t) {
|
|
6032
6042
|
return null != t;
|
|
6033
6043
|
}));
|
|
6034
|
-
var
|
|
6044
|
+
var z = {
|
|
6035
6045
|
__proto__: null,
|
|
6036
6046
|
matcher: t$2,
|
|
6037
|
-
optional:
|
|
6047
|
+
optional: h$2,
|
|
6038
6048
|
array: function (...e) {
|
|
6039
|
-
return
|
|
6049
|
+
return l$2({
|
|
6040
6050
|
[t$2]: () => ({
|
|
6041
6051
|
match: t => {
|
|
6042
6052
|
if (!Array.isArray(t)) return {
|
|
@@ -6066,7 +6076,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6066
6076
|
});
|
|
6067
6077
|
},
|
|
6068
6078
|
set: function (...e) {
|
|
6069
|
-
return
|
|
6079
|
+
return a$2({
|
|
6070
6080
|
[t$2]: () => ({
|
|
6071
6081
|
match: t => {
|
|
6072
6082
|
if (!(t instanceof Set)) return {
|
|
@@ -6094,7 +6104,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6094
6104
|
});
|
|
6095
6105
|
},
|
|
6096
6106
|
map: function (...e) {
|
|
6097
|
-
return
|
|
6107
|
+
return a$2({
|
|
6098
6108
|
[t$2]: () => ({
|
|
6099
6109
|
match: t => {
|
|
6100
6110
|
if (!(t instanceof Map)) return {
|
|
@@ -6127,10 +6137,39 @@ ${indent}columns: ${matrix.columns}
|
|
|
6127
6137
|
})
|
|
6128
6138
|
});
|
|
6129
6139
|
},
|
|
6130
|
-
|
|
6131
|
-
|
|
6140
|
+
record: function (...e) {
|
|
6141
|
+
return a$2({
|
|
6142
|
+
[t$2]: () => ({
|
|
6143
|
+
match: t => {
|
|
6144
|
+
if (null === t || "object" != typeof t || Array.isArray(t)) return {
|
|
6145
|
+
matched: false
|
|
6146
|
+
};
|
|
6147
|
+
var n;
|
|
6148
|
+
if (0 === e.length) throw new Error(`\`P.record\` wasn't given enough arguments. Expected (value) or (key, value), received ${null == (n = e[0]) ? void 0 : n.toString()}`);
|
|
6149
|
+
let r = {};
|
|
6150
|
+
const i = (t, e) => {
|
|
6151
|
+
r[t] = (r[t] || []).concat([e]);
|
|
6152
|
+
},
|
|
6153
|
+
[s, c] = 1 === e.length ? [A, e[0]] : e;
|
|
6154
|
+
return {
|
|
6155
|
+
matched: m$1(t, (t, e) => {
|
|
6156
|
+
const n = "string" != typeof t || Number.isNaN(Number(t)) ? null : Number(t),
|
|
6157
|
+
r = null !== n && o$2(s, n, i),
|
|
6158
|
+
u = o$2(s, t, i),
|
|
6159
|
+
a = o$2(c, e, i);
|
|
6160
|
+
return (u || r) && a;
|
|
6161
|
+
}),
|
|
6162
|
+
selections: r
|
|
6163
|
+
};
|
|
6164
|
+
},
|
|
6165
|
+
getSelectionKeys: () => 0 === e.length ? [] : [...s$1(e[0]), ...s$1(e[1])]
|
|
6166
|
+
})
|
|
6167
|
+
});
|
|
6168
|
+
},
|
|
6169
|
+
intersection: d$1,
|
|
6170
|
+
union: y$1,
|
|
6132
6171
|
not: function (e) {
|
|
6133
|
-
return
|
|
6172
|
+
return a$2({
|
|
6134
6173
|
[t$2]: () => ({
|
|
6135
6174
|
match: t => ({
|
|
6136
6175
|
matched: !o$2(e, t, () => {})
|
|
@@ -6141,26 +6180,27 @@ ${indent}columns: ${matrix.columns}
|
|
|
6141
6180
|
});
|
|
6142
6181
|
},
|
|
6143
6182
|
when: p$2,
|
|
6144
|
-
select:
|
|
6145
|
-
any:
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6183
|
+
select: v$1,
|
|
6184
|
+
any: K,
|
|
6185
|
+
unknown: O,
|
|
6186
|
+
_: E,
|
|
6187
|
+
string: A,
|
|
6188
|
+
number: P,
|
|
6189
|
+
bigint: T,
|
|
6190
|
+
boolean: B,
|
|
6191
|
+
symbol: _,
|
|
6192
|
+
nullish: W,
|
|
6193
|
+
nonNullable: $$1,
|
|
6154
6194
|
instanceOf: function (t) {
|
|
6155
|
-
return
|
|
6195
|
+
return a$2(p$2(function (t) {
|
|
6156
6196
|
return e => e instanceof t;
|
|
6157
6197
|
}(t)));
|
|
6158
6198
|
},
|
|
6159
6199
|
shape: function (t) {
|
|
6160
|
-
return
|
|
6200
|
+
return a$2(p$2(u$2(t)));
|
|
6161
6201
|
}
|
|
6162
6202
|
};
|
|
6163
|
-
class
|
|
6203
|
+
class I extends Error {
|
|
6164
6204
|
constructor(t) {
|
|
6165
6205
|
let e;
|
|
6166
6206
|
try {
|
|
@@ -6171,14 +6211,14 @@ ${indent}columns: ${matrix.columns}
|
|
|
6171
6211
|
super(`Pattern matching error: no pattern matches value ${e}`), this.input = void 0, this.input = t;
|
|
6172
6212
|
}
|
|
6173
6213
|
}
|
|
6174
|
-
const
|
|
6214
|
+
const L = {
|
|
6175
6215
|
matched: false,
|
|
6176
6216
|
value: void 0
|
|
6177
6217
|
};
|
|
6178
|
-
function
|
|
6179
|
-
return new
|
|
6218
|
+
function M$2(t) {
|
|
6219
|
+
return new R(t, L);
|
|
6180
6220
|
}
|
|
6181
|
-
class
|
|
6221
|
+
class R {
|
|
6182
6222
|
constructor(t, e) {
|
|
6183
6223
|
this.input = void 0, this.state = void 0, this.input = t, this.state = e;
|
|
6184
6224
|
}
|
|
@@ -6190,27 +6230,27 @@ ${indent}columns: ${matrix.columns}
|
|
|
6190
6230
|
3 === t.length && "function" == typeof t[1] ? i = t[1] : t.length > 2 && r.push(...t.slice(1, t.length - 1));
|
|
6191
6231
|
let s = false,
|
|
6192
6232
|
c = {};
|
|
6193
|
-
const
|
|
6233
|
+
const u = (t, e) => {
|
|
6194
6234
|
s = true, c[t] = e;
|
|
6195
6235
|
},
|
|
6196
|
-
|
|
6236
|
+
a = !r.some(t => o$2(t, this.input, u)) || i && !Boolean(i(this.input)) ? L : {
|
|
6197
6237
|
matched: true,
|
|
6198
6238
|
value: e(s ? n$2 in c ? c[n$2] : c : this.input, this.input)
|
|
6199
6239
|
};
|
|
6200
|
-
return new
|
|
6240
|
+
return new R(this.input, a);
|
|
6201
6241
|
}
|
|
6202
6242
|
when(t, e) {
|
|
6203
6243
|
if (this.state.matched) return this;
|
|
6204
6244
|
const n = Boolean(t(this.input));
|
|
6205
|
-
return new
|
|
6245
|
+
return new R(this.input, n ? {
|
|
6206
6246
|
matched: true,
|
|
6207
6247
|
value: e(this.input, this.input)
|
|
6208
|
-
} :
|
|
6248
|
+
} : L);
|
|
6209
6249
|
}
|
|
6210
6250
|
otherwise(t) {
|
|
6211
6251
|
return this.state.matched ? this.state.value : t(this.input);
|
|
6212
6252
|
}
|
|
6213
|
-
exhaustive(t =
|
|
6253
|
+
exhaustive(t = F) {
|
|
6214
6254
|
return this.state.matched ? this.state.value : t(this.input);
|
|
6215
6255
|
}
|
|
6216
6256
|
run() {
|
|
@@ -6223,34 +6263,377 @@ ${indent}columns: ${matrix.columns}
|
|
|
6223
6263
|
return this;
|
|
6224
6264
|
}
|
|
6225
6265
|
}
|
|
6226
|
-
function
|
|
6227
|
-
throw new
|
|
6228
|
-
}
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6266
|
+
function F(t) {
|
|
6267
|
+
throw new I(t);
|
|
6268
|
+
}
|
|
6269
|
+
|
|
6270
|
+
var index_umd$1 = {exports: {}};
|
|
6271
|
+
|
|
6272
|
+
var index_umd = index_umd$1.exports;
|
|
6273
|
+
(function (module, exports$1) {
|
|
6274
|
+
(function (N, J) {
|
|
6275
|
+
J(exports$1) ;
|
|
6276
|
+
})(index_umd, function (N) {
|
|
6277
|
+
|
|
6278
|
+
function J(f, a, o, t, e) {
|
|
6279
|
+
const h = Math.abs(o - f),
|
|
6280
|
+
r = f < o ? 1 : -1,
|
|
6281
|
+
l = -Math.abs(t - a),
|
|
6282
|
+
M = a < t ? 1 : -1;
|
|
6283
|
+
let i = h + l,
|
|
6284
|
+
n;
|
|
6285
|
+
for (;;) {
|
|
6286
|
+
if (e(f, a), n = 2 * i, n >= l) {
|
|
6287
|
+
if (f === o) break;
|
|
6288
|
+
i += l, f += r;
|
|
6289
|
+
}
|
|
6290
|
+
if (n <= h) {
|
|
6291
|
+
if (a === t) break;
|
|
6292
|
+
i += h, a += M;
|
|
6293
|
+
}
|
|
6294
|
+
}
|
|
6295
|
+
}
|
|
6296
|
+
function U(f, a, o, t, e) {
|
|
6297
|
+
const h = f < o ? 1 : -1,
|
|
6298
|
+
r = a < t ? 1 : -1;
|
|
6299
|
+
let l,
|
|
6300
|
+
M = Math.abs(o - f),
|
|
6301
|
+
i = Math.abs(t - a),
|
|
6302
|
+
n = M * M + i * i,
|
|
6303
|
+
c = n === 0 ? 1 : 1 / Math.sqrt(n);
|
|
6304
|
+
for (M *= c, i *= c, n = M - i;;) {
|
|
6305
|
+
if (e(f, a, Math.abs(n - (M + i)) >> 16), c = n, l = f, 2 * c >= -M) {
|
|
6306
|
+
if (f === o) break;
|
|
6307
|
+
c + i < 16711680 && e(f, a + r, c + i >> 16), n -= i, f += h;
|
|
6308
|
+
}
|
|
6309
|
+
if (2 * c <= i) {
|
|
6310
|
+
if (a === t) break;
|
|
6311
|
+
M - c < 16711680 && e(l + h, a, M - c >> 16), n += M, a += r;
|
|
6312
|
+
}
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
function w(f, a, o, t, e, h) {
|
|
6316
|
+
let r = Math.abs(o - f),
|
|
6317
|
+
l = f < o ? 1 : -1,
|
|
6318
|
+
M = Math.abs(t - a),
|
|
6319
|
+
i = a < t ? 1 : -1,
|
|
6320
|
+
n = r - M,
|
|
6321
|
+
c,
|
|
6322
|
+
q,
|
|
6323
|
+
d,
|
|
6324
|
+
b = r + M == 0 ? 1 : Math.sqrt(r * r + M * M);
|
|
6325
|
+
for (e = (e + 1) / 2;;) {
|
|
6326
|
+
if (h(f, a, Math.max(0, 255 * (Math.abs(n - r + M) / b - e + 1))), c = n, q = f, 2 * c >= -r) {
|
|
6327
|
+
for (c += M, d = a; c < b * e && (t != d || r > M); c += r) h(f, d += i, Math.max(0, 255 * (Math.abs(c) / b - e + 1)));
|
|
6328
|
+
if (f == o) break;
|
|
6329
|
+
c = n, n -= M, f += l;
|
|
6330
|
+
}
|
|
6331
|
+
if (2 * c <= M) {
|
|
6332
|
+
for (c = r - c; c < b * e && (o != q || r < M); c += M) h(q += l, a, Math.max(0, 255 * (Math.abs(c) / b - e + 1)));
|
|
6333
|
+
if (a == t) break;
|
|
6334
|
+
n += r, a += i;
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6337
|
+
}
|
|
6338
|
+
function I(f, a = "assert error") {
|
|
6339
|
+
if (!f) throw new Error(a);
|
|
6340
|
+
}
|
|
6341
|
+
function P(f, a, o, t, e, h, r, l) {
|
|
6342
|
+
var M = f - 2 * o + e,
|
|
6343
|
+
i = a - 2 * t + h,
|
|
6344
|
+
n = f - o,
|
|
6345
|
+
c = a - t,
|
|
6346
|
+
q,
|
|
6347
|
+
d,
|
|
6348
|
+
b;
|
|
6349
|
+
I(r >= 0, "width is negative"), n * (e - o) > 0 && (c * (h - t) > 0 && Math.abs(n * i) > Math.abs(c * M) && (f = e, e = n + o, a = h, h = c + t), f == e || r == 1 ? d = (f - o) / M : (b = Math.sqrt(4 * r * r * (f - o) * (e - o) + (e - f) * (e - f)), o < f && (b = -b), d = (2 * r * (f - o) - f + e + b) / (2 * (1 - r) * (e - f))), b = 1 / (2 * d * (1 - d) * (r - 1) + 1), n = (d * d * (f - 2 * r * o + e) + 2 * d * (r * o - f) + f) * b, c = (d * d * (a - 2 * r * t + h) + 2 * d * (r * t - a) + a) * b, q = d * (r - 1) + 1, q *= q * b, r = ((1 - d) * (r - 1) + 1) * Math.sqrt(b), M = Math.floor(n + .5), i = Math.floor(c + .5), c = (n - f) * (t - a) / (o - f) + a, H(f, a, M, Math.floor(c + .5), M, i, q, l), c = (n - e) * (t - h) / (o - e) + h, t = Math.floor(c + .5), f = o = M, a = i), (a - t) * (h - t) > 0 && (a == h || r == 1 ? d = (a - t) / (a - 2 * t + h) : (b = Math.sqrt(4 * r * r * (a - t) * (h - t) + (h - a) * (h - a)), t < a && (b = -b), d = (2 * r * (a - t) - a + h + b) / (2 * (1 - r) * (h - a))), b = 1 / (2 * d * (1 - d) * (r - 1) + 1), n = (d * d * (f - 2 * r * o + e) + 2 * d * (r * o - f) + f) * b, c = (d * d * (a - 2 * r * t + h) + 2 * d * (r * t - a) + a) * b, q = d * (r - 1) + 1, q *= q * b, r = ((1 - d) * (r - 1) + 1) * Math.sqrt(b), M = Math.floor(n + .5), i = Math.floor(c + .5), n = (o - f) * (c - a) / (t - a) + f, H(f, a, Math.floor(n + .5), i, M, i, q, l), n = (o - e) * (c - h) / (t - h) + e, o = Math.floor(n + .5), f = M, a = t = i), H(f, a, o, t, e, h, r * r, l);
|
|
6350
|
+
}
|
|
6351
|
+
function H(f, a, o, t, e, h, r, l) {
|
|
6352
|
+
var M = e - o,
|
|
6353
|
+
i = h - t,
|
|
6354
|
+
n = f - e,
|
|
6355
|
+
c = a - h,
|
|
6356
|
+
q = f - o,
|
|
6357
|
+
d = a - t,
|
|
6358
|
+
b = q * i + d * M,
|
|
6359
|
+
s = q * i - d * M,
|
|
6360
|
+
u;
|
|
6361
|
+
if (I(q * M <= 0 && d * i <= 0, "sign of gradient must not change"), s != 0 && r > 0) {
|
|
6362
|
+
if (M * M + i * i > q * q + d * d && (e = f, f -= n, h = a, a -= c, s = -s), q = 2 * (4 * r * M * q + n * n), d = 2 * (4 * r * i * d + c * c), M = f < e ? 1 : -1, i = a < h ? 1 : -1, b = -2 * M * i * (2 * r * b + n * c), s * M * i < 0 && (q = -q, d = -d, b = -b, s = -s), n = 4 * r * (o - f) * i * s + q / 2 + b, c = 4 * r * (a - t) * M * s + d / 2 + b, r < .5 && (c > b || n < b)) {
|
|
6363
|
+
s = (r + 1) / 2, r = Math.sqrt(r), b = 1 / (r + 1), M = Math.floor((f + 2 * r * o + e) * b / 2 + .5), i = Math.floor((a + 2 * r * t + h) * b / 2 + .5), n = Math.floor((r * o + f) * b + .5), c = Math.floor((t * r + a) * b + .5), H(f, a, n, c, M, i, s, l), n = Math.floor((r * o + e) * b + .5), c = Math.floor((t * r + h) * b + .5), H(M, i, n, c, e, h, s, l);
|
|
6364
|
+
return;
|
|
6365
|
+
}
|
|
6366
|
+
u = n + c - b;
|
|
6367
|
+
do {
|
|
6368
|
+
if (l(f, a), f == e && a == h) return;
|
|
6369
|
+
o = 2 * u > c ? 1 : 0, t = 2 * (u + d) < -c ? 1 : 0, (2 * u < n || t) && (a += i, c += b, u += n += q), (2 * u > n || o) && (f += M, n += b, u += c += d);
|
|
6370
|
+
} while (c <= b && n >= b);
|
|
6371
|
+
}
|
|
6372
|
+
J(f, a, e, h, l);
|
|
6373
|
+
}
|
|
6374
|
+
function V(f, a, o, t, e, h, r, l) {
|
|
6375
|
+
var M = e - o,
|
|
6376
|
+
i = h - t,
|
|
6377
|
+
n = f - e,
|
|
6378
|
+
c = a - h,
|
|
6379
|
+
q = f - o,
|
|
6380
|
+
d = a - t,
|
|
6381
|
+
b = q * i + d * M,
|
|
6382
|
+
s = q * i - d * M,
|
|
6383
|
+
u,
|
|
6384
|
+
z,
|
|
6385
|
+
j;
|
|
6386
|
+
if (I(q * M <= 0 && d * i <= 0), s != 0 && r > 0) {
|
|
6387
|
+
if (M * M + i * i > q * q + d * d && (e = f, f -= n, h = a, a -= c, s = -s), q = 2 * (4 * r * M * q + n * n), d = 2 * (4 * r * i * d + c * c), M = f < e ? 1 : -1, i = a < h ? 1 : -1, b = -2 * M * i * (2 * r * b + n * c), s * M * i < 0 && (q = -q, d = -d, s = -s, b = -b), n = 4 * r * (o - f) * i * s + q / 2 + b, c = 4 * r * (a - t) * M * s + d / 2 + b, r < .5 && c > n) return s = (r + 1) / 2, r = Math.sqrt(r), b = 1 / (r + 1), M = Math.floor((f + 2 * r * o + e) * b / 2 + .5), i = Math.floor((a + 2 * r * t + h) * b / 2 + .5), n = Math.floor((r * o + f) * b + .5), c = Math.floor((t * r + a) * b + .5), V(f, a, n, c, M, i, s, l), n = Math.floor((r * o + e) * b + .5), c = Math.floor((t * r + h) * b + .5), V(M, i, n, c, e, h, s, l);
|
|
6388
|
+
u = n + c - b;
|
|
6389
|
+
do {
|
|
6390
|
+
if (s = Math.min(n - b, b - c), z = Math.max(n - b, b - c), z += 2 * z * s * s / (4 * z * z + s * s), o = 255 * Math.abs(u - n - c + b) / z, o < 256 && l(f, a, o), j = 2 * u + c < 0) {
|
|
6391
|
+
if (a == h) return;
|
|
6392
|
+
n - u < z && l(f + M, a, 255 * Math.abs(n - u) / z);
|
|
6393
|
+
}
|
|
6394
|
+
if (2 * u + n > 0) {
|
|
6395
|
+
if (f == e) return;
|
|
6396
|
+
u - c < z && l(f, a + i, 255 * Math.abs(u - c) / z), f += M, n += b, u += c += d;
|
|
6397
|
+
}
|
|
6398
|
+
j && (a += i, c += b, u += n += q);
|
|
6399
|
+
} while (c < n);
|
|
6400
|
+
}
|
|
6401
|
+
U(f, a, e, h, l);
|
|
6402
|
+
}
|
|
6403
|
+
function y(f, a, o, t, e) {
|
|
6404
|
+
let h = -o,
|
|
6405
|
+
r = 0,
|
|
6406
|
+
l = t * t,
|
|
6407
|
+
M = h * (2 * l + h) + l;
|
|
6408
|
+
do e(f - h, a + r), e(f + h, a + r), e(f + h, a - r), e(f - h, a - r), l = 2 * M, l >= (h * 2 + 1) * t * t && (M += (++h * 2 + 1) * t * t), l <= (r * 2 + 1) * o * o && (M += (++r * 2 + 1) * o * o); while (h <= 0);
|
|
6409
|
+
for (; r++ < t;) e(f, a + r), e(f, a - r);
|
|
6410
|
+
}
|
|
6411
|
+
function x(f, a, o, t, e, h) {
|
|
6412
|
+
let r = o * o,
|
|
6413
|
+
l = t * t;
|
|
6414
|
+
const M = Math.sin(e);
|
|
6415
|
+
let i = (r - l) * M;
|
|
6416
|
+
r = Math.sqrt(r - i * M), l = Math.sqrt(l + i * M), o = r + .5, t = l + .5, i = i * o * t / (r * l), Y(f - o, a - t, f + o, a + t, 4 * i * Math.cos(e), h);
|
|
6417
|
+
}
|
|
6418
|
+
function Y(f, a, o, t, e, h) {
|
|
6419
|
+
let r = o - f,
|
|
6420
|
+
l = t - a,
|
|
6421
|
+
M = r * l;
|
|
6422
|
+
if (e === 0) return Z(f, a, o, t, h);
|
|
6423
|
+
M !== 0 && (M = (M - e) / (M + M)), I(M <= 1 && M >= 0, "limit angle to |zd|<=xd*yd"), r = Math.floor(r * M + .5), l = Math.floor(l * M + .5), H(f, a + l, f, a, f + r, a, 1 - M, h), H(f, a + l, f, t, o - r, t, M, h), H(o, t - l, o, t, o - r, t, 1 - M, h), H(o, t - l, o, a, f + r, a, M, h);
|
|
6424
|
+
}
|
|
6425
|
+
function Z(f, a, o, t, e) {
|
|
6426
|
+
let h = Math.abs(o - f),
|
|
6427
|
+
r = Math.abs(t - a),
|
|
6428
|
+
l = r & 1,
|
|
6429
|
+
M = 4 * (1 - h) * r * r,
|
|
6430
|
+
i = 4 * (l + 1) * h * h,
|
|
6431
|
+
n = M + i + l * h * h,
|
|
6432
|
+
c;
|
|
6433
|
+
f > o && (f = o, o += h), a > t && (a = t), a += (r + 1) / 2, t = a - l, h = 8 * h * h, l = 8 * r * r;
|
|
6434
|
+
do e(o, a), e(f, a), e(f, t), e(o, t), c = 2 * n, c <= i && (a++, t--, n += i += h), (c >= M || 2 * n > i) && (f++, o--, n += M += l); while (f <= o);
|
|
6435
|
+
for (; a - t <= r;) e(f - 1, a), e(o + 1, a++), e(f - 1, t), e(o + 1, t--);
|
|
6436
|
+
}
|
|
6437
|
+
function aa(f, a, o, t) {
|
|
6438
|
+
var e = -o,
|
|
6439
|
+
h = 0,
|
|
6440
|
+
r = 2 - 2 * o;
|
|
6441
|
+
do t(f - e, a + h), t(f - h, a - e), t(f + e, a - h), t(f + h, a + e), o = r, o <= h && (r += ++h * 2 + 1), (o > e || r > h) && (r += ++e * 2 + 1); while (e < 0);
|
|
6442
|
+
}
|
|
6443
|
+
function fa(f, a, o, t) {
|
|
6444
|
+
var e = -o,
|
|
6445
|
+
h = 0,
|
|
6446
|
+
r,
|
|
6447
|
+
l,
|
|
6448
|
+
M,
|
|
6449
|
+
i = 2 - 2 * o;
|
|
6450
|
+
o = 1 - i;
|
|
6451
|
+
do r = 255 * Math.abs(i - 2 * (e + h) - 2) / o, t(f - e, a + h, r), t(f - h, a - e, r), t(f + e, a - h, r), t(f + h, a + e, r), M = i, l = e, i + h > 0 && (r = 255 * (i - 2 * e - 1) / o, r < 256 && (t(f - e, a + h + 1, r), t(f - h - 1, a - e, r), t(f + e, a - h - 1, r), t(f + h + 1, a + e, r)), i += ++e * 2 + 1), M + l <= 0 && (r = 255 * (2 * h + 3 - M) / o, r < 256 && (t(f - l - 1, a + h, r), t(f - h, a - l - 1, r), t(f + l + 1, a - h, r), t(f + h, a + l + 1, r)), i += ++h * 2 + 1); while (e < 0);
|
|
6452
|
+
}
|
|
6453
|
+
function ta(f, a, o, t, e, h, r) {
|
|
6454
|
+
var l = f - o,
|
|
6455
|
+
M = a - t,
|
|
6456
|
+
i = f - 2 * o + e,
|
|
6457
|
+
n;
|
|
6458
|
+
l * (e - o) > 0 && (M * (h - t) > 0 && Math.abs((a - 2 * t + h) / i * l) > Math.abs(M) && (f = e, e = l + o, a = h, h = M + t), i = (f - o) / i, n = (1 - i) * ((1 - i) * a + 2 * i * t) + i * i * h, i = (f * e - o * o) * i / (f - o), l = Math.floor(i + .5), M = Math.floor(n + .5), n = (t - a) * (i - f) / (o - f) + a, L(f, a, l, Math.floor(n + .5), l, M, r), n = (t - h) * (i - e) / (o - e) + h, f = o = l, a = M, t = Math.floor(n + .5)), (a - t) * (h - t) > 0 && (i = a - 2 * t + h, i = (a - t) / i, n = (1 - i) * ((1 - i) * f + 2 * i * o) + i * i * e, i = (a * h - t * t) * i / (a - t), l = Math.floor(n + .5), M = Math.floor(i + .5), n = (o - f) * (i - a) / (t - a) + f, L(f, a, Math.floor(n + .5), M, l, M, r), n = (o - e) * (i - h) / (t - h) + e, f = l, o = Math.floor(n + .5), a = t = M), L(f, a, o, t, e, h, r);
|
|
6459
|
+
}
|
|
6460
|
+
function L(f, a, o, t, e, h, r) {
|
|
6461
|
+
var l = e - o,
|
|
6462
|
+
M = h - t,
|
|
6463
|
+
i = f - o,
|
|
6464
|
+
n = a - t,
|
|
6465
|
+
c,
|
|
6466
|
+
q,
|
|
6467
|
+
d,
|
|
6468
|
+
b,
|
|
6469
|
+
s = i * M - n * l;
|
|
6470
|
+
if (I(i * l <= 0 && n * M <= 0, "sign of gradient must not change"), l * l + M * M > i * i + n * n && (e = f, f = l + o, h = a, a = M + t, s = -s), s != 0) {
|
|
6471
|
+
i += l, i *= l = f < e ? 1 : -1, n += M, n *= M = a < h ? 1 : -1, c = 2 * i * n, i *= i, n *= n, s * l * M < 0 && (i = -i, n = -n, c = -c, s = -s), q = 4 * M * s * (o - f) + i - c, d = 4 * l * s * (a - t) + n - c, i += i, n += n, b = q + d + c;
|
|
6472
|
+
do {
|
|
6473
|
+
if (r(f, a), f == e && a == h) return;
|
|
6474
|
+
t = +(2 * b < q), 2 * b > d && (f += l, q -= c, b += d += n), t && (a += M, d -= c, b += q += i);
|
|
6475
|
+
} while (d < 0 && q > 0);
|
|
6476
|
+
}
|
|
6477
|
+
J(f, a, e, h, r);
|
|
6478
|
+
}
|
|
6479
|
+
function ia(f, a, o, t, e, h, r) {
|
|
6480
|
+
var l = f - o,
|
|
6481
|
+
M = a - t,
|
|
6482
|
+
i = f - 2 * o + e,
|
|
6483
|
+
n;
|
|
6484
|
+
l * (e - o) > 0 && (M * (h - t) > 0 && Math.abs((a - 2 * t + h) / i * l) > Math.abs(M) && (f = e, e = l + o, a = h, h = M + t), i = (f - o) / i, n = (1 - i) * ((1 - i) * a + 2 * i * t) + i * i * h, i = (f * e - o * o) * i / (f - o), l = Math.floor(i + .5), M = Math.floor(n + .5), n = (t - a) * (i - f) / (o - f) + a, Q(f, a, l, Math.floor(n + .5), l, M, r), n = (t - h) * (i - e) / (o - e) + h, f = o = l, a = M, t = Math.floor(n + .5)), (a - t) * (h - t) > 0 && (i = a - 2 * t + h, i = (a - t) / i, n = (1 - i) * ((1 - i) * f + 2 * i * o) + i * i * e, i = (a * h - t * t) * i / (a - t), l = Math.floor(n + .5), M = Math.floor(i + .5), n = (o - f) * (i - a) / (t - a) + f, Q(f, a, Math.floor(n + .5), M, l, M, r), n = (o - e) * (i - h) / (t - h) + e, f = l, o = Math.floor(n + .5), a = t = M), Q(f, a, o, t, e, h, r);
|
|
6485
|
+
}
|
|
6486
|
+
function Q(f, a, o, t, e, h, r) {
|
|
6487
|
+
var l = e - o,
|
|
6488
|
+
M = h - t,
|
|
6489
|
+
i = f - o,
|
|
6490
|
+
n = a - t,
|
|
6491
|
+
c,
|
|
6492
|
+
q,
|
|
6493
|
+
d,
|
|
6494
|
+
b,
|
|
6495
|
+
s,
|
|
6496
|
+
u = i * M - n * l;
|
|
6497
|
+
if (l * l + M * M > i * i + n * n && (e = f, f = l + o, h = a, a = M + t, u = -u), u != 0) {
|
|
6498
|
+
i += l, i *= l = f < e ? 1 : -1, n += M, n *= M = a < h ? 1 : -1, c = 2 * i * n, i *= i, n *= n, u * l * M < 0 && (i = -i, n = -n, c = -c, u = -u), q = 4 * M * (o - f) * u + i - c, d = 4 * l * (a - t) * u + n - c, i += i, n += n, b = q + d + c;
|
|
6499
|
+
do {
|
|
6500
|
+
if (u = Math.min(q + c, -c - d), s = Math.max(q + c, -c - d), s += 2 * s * u * u / (4 * s * s + u * u), r(f, a, 255 * Math.abs(b - q - d - c) / s), f == e || a == h) break;
|
|
6501
|
+
o = f, u = q - b, t = +(2 * b + d < 0), 2 * b + q > 0 && (b - d < s && r(f, a + M, 255 * Math.abs(b - d) / s), f += l, q -= c, b += d += n), t && (u < s && r(o + l, a, 255 * Math.abs(u) / s), a += M, d -= c, b += q += i);
|
|
6502
|
+
} while (d < q);
|
|
6503
|
+
}
|
|
6504
|
+
U(f, a, e, h, r);
|
|
6505
|
+
}
|
|
6506
|
+
function _(f, a, o, t, e, h, r, l, M) {
|
|
6507
|
+
var i,
|
|
6508
|
+
n,
|
|
6509
|
+
c,
|
|
6510
|
+
q = 1;
|
|
6511
|
+
let d = f < r ? 1 : -1,
|
|
6512
|
+
b = a < l ? 1 : -1,
|
|
6513
|
+
s = -Math.abs(f + o - e - r),
|
|
6514
|
+
u = s - 4 * d * (o - e),
|
|
6515
|
+
z = d * (f - o - e + r),
|
|
6516
|
+
j = -Math.abs(a + t - h - l),
|
|
6517
|
+
B = j - 4 * b * (t - h),
|
|
6518
|
+
R = b * (a - t - h + l),
|
|
6519
|
+
p,
|
|
6520
|
+
S,
|
|
6521
|
+
W,
|
|
6522
|
+
T,
|
|
6523
|
+
G,
|
|
6524
|
+
E,
|
|
6525
|
+
O,
|
|
6526
|
+
v,
|
|
6527
|
+
g,
|
|
6528
|
+
k,
|
|
6529
|
+
F,
|
|
6530
|
+
D = .01;
|
|
6531
|
+
if (I((o - f) * (e - r) < D && ((r - f) * (o - e) < D || z * z < u * s + D), "slope change"), I((t - a) * (h - l) < D && ((l - a) * (t - h) < D || R * R < B * j + D), "slope change"), u == 0 && B == 0) return d = Math.floor((3 * o - f + 1) / 2), b = Math.floor((3 * t - a + 1) / 2), L(f, a, d, b, r, l, M);
|
|
6532
|
+
o = (o - f) * (o - f) + (t - a) * (t - a) + 1, e = (e - r) * (e - r) + (h - l) * (h - l) + 1;
|
|
6533
|
+
do {
|
|
6534
|
+
p = u * R - z * B, S = u * j - s * B, W = z * j - s * R, k = p * (p + S - 3 * W) + S * S, i = k > 0 ? 1 : Math.sqrt(1 + 1024 / o), p *= i, S *= i, W *= i, k *= i * i, E = 9 * (p + S + W) / 8, T = 8 * (u - B), v = 27 * (8 * p * (R * R - B * j) + k * (B + 2 * R + j)) / 64 - B * B * (E - B), g = 27 * (8 * p * (z * z - u * s) - k * (u + 2 * z + s)) / 64 - u * u * (E + u), G = 3 * (3 * p * (3 * R * R - B * B - 2 * B * j) - B * (3 * S * (B + R) + B * T)) / 4, O = 3 * (3 * p * (3 * z * z - u * u - 2 * u * s) - u * (3 * S * (u + z) + u * T)) / 4, E = u * B * (6 * p + 6 * S - 3 * W + T), S = B * B, T = u * u, E = 3 * (E + 9 * i * (T * R * j - z * s * S) - 18 * z * R * p) / 8, k < 0 && (v = -v, g = -g, G = -G, O = -O, E = -E, S = -S, T = -T), p = 6 * B * S, S = -6 * u * S, W = 6 * B * T, T = -6 * u * T, v += E, k = v + g, g += E;
|
|
6535
|
+
a: for (F = E, n = c = i; f != r && a != l;) {
|
|
6536
|
+
M(f, a);
|
|
6537
|
+
do {
|
|
6538
|
+
if (v > F || g < F) break a;
|
|
6539
|
+
t = 2 * k - g, 2 * k >= v && (n--, k += v += G, g += E += S, O += W, G += p), t <= 0 && (c--, k += g += O, v += E += W, G += S, O += T);
|
|
6540
|
+
} while (n > 0 && c > 0);
|
|
6541
|
+
2 * n <= i && (f += d, n += i), 2 * c <= i && (a += b, c += i), F == E && v < 0 && g > 0 && (F = D);
|
|
6542
|
+
}
|
|
6543
|
+
G = f, f = r, r = G, d = -d, z = -z, O = a, a = l, l = O, b = -b, R = -R, o = e;
|
|
6544
|
+
} while (q--);
|
|
6545
|
+
J(f, a, r, l, M);
|
|
6546
|
+
}
|
|
6547
|
+
function $(f, a, o, t, e, h, r, l, M) {
|
|
6548
|
+
let i,
|
|
6549
|
+
n,
|
|
6550
|
+
c,
|
|
6551
|
+
q = 1,
|
|
6552
|
+
d = f < r ? 1 : -1,
|
|
6553
|
+
b = a < l ? 1 : -1,
|
|
6554
|
+
s = -Math.abs(f + o - e - r),
|
|
6555
|
+
u = s - 4 * d * (o - e),
|
|
6556
|
+
z = d * (f - o - e + r),
|
|
6557
|
+
j = -Math.abs(a + t - h - l),
|
|
6558
|
+
B = j - 4 * b * (t - h),
|
|
6559
|
+
R = b * (a - t - h + l),
|
|
6560
|
+
p,
|
|
6561
|
+
S,
|
|
6562
|
+
W,
|
|
6563
|
+
T,
|
|
6564
|
+
G,
|
|
6565
|
+
E,
|
|
6566
|
+
O,
|
|
6567
|
+
v,
|
|
6568
|
+
g,
|
|
6569
|
+
k,
|
|
6570
|
+
F,
|
|
6571
|
+
D,
|
|
6572
|
+
C,
|
|
6573
|
+
A;
|
|
6574
|
+
const K = .01;
|
|
6575
|
+
if (I((o - f) * (e - r) < K && ((r - f) * (o - e) < K || z * z < u * s + K)), I((t - a) * (h - l) < K && ((l - a) * (t - h) < K || R * R < B * j + K)), u === 0 && B === 0) return d = Math.floor((3 * o - f + 1) / 2), b = Math.floor((3 * t - a + 1) / 2), Q(f, a, d, b, r, l, M);
|
|
6576
|
+
o = (o - f) * (o - f) + (t - a) * (t - a) + 1, e = (e - r) * (e - r) + (h - l) * (h - l) + 1;
|
|
6577
|
+
do {
|
|
6578
|
+
p = u * R - z * B, S = u * j - s * B, W = z * j - s * R, A = 4 * p * W - S * S, k = p * (p + S - 3 * W) + S * S, i = k > 0 ? 1 : Math.sqrt(1 + 1024 / o), p *= i, S *= i, W *= i, k *= i * i, E = 9 * (p + S + W) / 8, T = 8 * (u - B), v = 27 * (8 * p * (R * R - B * j) + k * (B + 2 * R + j)) / 64 - B * B * (E - B), g = 27 * (8 * p * (z * z - u * s) - k * (u + 2 * z + s)) / 64 - u * u * (E + u), G = 3 * (3 * p * (3 * R * R - B * B - 2 * B * j) - B * (3 * S * (B + R) + B * T)) / 4, O = 3 * (3 * p * (3 * z * z - u * u - 2 * u * s) - u * (3 * S * (u + z) + u * T)) / 4, E = u * B * (6 * p + 6 * S - 3 * W + T), S = B * B, T = u * u, E = 3 * (E + 9 * i * (T * R * j - z * s * S) - 18 * z * R * p) / 8, k < 0 && (v = -v, g = -g, G = -G, O = -O, E = -E, S = -S, T = -T), p = 6 * B * S, S = -6 * u * S, W = 6 * B * T, T = -6 * u * T, v += E, k = v + g, g += E;
|
|
6579
|
+
let X = false;
|
|
6580
|
+
a: for (n = c = i; f !== r && a !== l;) {
|
|
6581
|
+
t = Math.min(Math.abs(E - v), Math.abs(g - E)), C = Math.max(Math.abs(E - v), Math.abs(g - E)), C = i * (C + 2 * C * t * t / (4 * C * C + t * t)), t = 255 * Math.abs(k - (i - n + 1) * v - (i - c + 1) * g + i * E) / C, t < 256 && M(f, a, t), F = Math.abs(k - (i - n + 1) * v + (c - 1) * g), D = Math.abs(k + (n - 1) * v - (i - c + 1) * g), h = a;
|
|
6582
|
+
do {
|
|
6583
|
+
if (A >= -K && (v + G > E || g + O < E)) {
|
|
6584
|
+
X = true;
|
|
6585
|
+
break a;
|
|
6586
|
+
}
|
|
6587
|
+
if (t = 2 * k + v, 2 * k + g > 0) n--, k += v += G, g += E += S, O += W, G += p;else if (t > 0) {
|
|
6588
|
+
X = true;
|
|
6589
|
+
break a;
|
|
6590
|
+
}
|
|
6591
|
+
t <= 0 && (c--, k += g += O, v += E += W, G += S, O += T);
|
|
6592
|
+
} while (n > 0 && c > 0);
|
|
6593
|
+
2 * c <= i && (D < C && M(f + d, a, 255 * D / C), a += b, c += i), 2 * n <= i && (F < C && M(f, h + b, 255 * F / C), f += d, n += i);
|
|
6594
|
+
}
|
|
6595
|
+
X && (2 * k < g && 2 * c <= i + 2 && (D < C && M(f + d, a, 255 * D / C), a += b), 2 * k > v && 2 * n <= i + 2 && (F < C && M(f, h + b, 255 * F / C), f += d), G = f, f = r, r = G, d = -d, z = -z, O = a, a = l, l = O, b = -b, R = -R, o = e);
|
|
6596
|
+
break;
|
|
6597
|
+
} while (q--);
|
|
6598
|
+
U(Math.floor(f), Math.floor(a), Math.floor(r), Math.floor(l), M);
|
|
6599
|
+
}
|
|
6600
|
+
function m(f, a, o, t, e, h, r, l, M, i) {
|
|
6601
|
+
let n = 0,
|
|
6602
|
+
c = 0,
|
|
6603
|
+
q = f + o - e - r,
|
|
6604
|
+
d = q - 4 * (o - e),
|
|
6605
|
+
b = f - o - e + r,
|
|
6606
|
+
s = b + 4 * (o + e),
|
|
6607
|
+
u = a + t - h - l,
|
|
6608
|
+
z = u - 4 * (t - h),
|
|
6609
|
+
j = a - t - h + l,
|
|
6610
|
+
B = j + 4 * (t + h);
|
|
6611
|
+
var R = f,
|
|
6612
|
+
p,
|
|
6613
|
+
S,
|
|
6614
|
+
W,
|
|
6615
|
+
T = a,
|
|
6616
|
+
G,
|
|
6617
|
+
E,
|
|
6618
|
+
O;
|
|
6619
|
+
let v = b * b - d * q,
|
|
6620
|
+
g;
|
|
6621
|
+
const k = [0, 0, 0, 0, 0];
|
|
6622
|
+
for (d == 0 ? Math.abs(q) < 2 * Math.abs(b) && (k[n++] = q / (2 * b)) : v > 0 && (g = Math.sqrt(v), v = (b - g) / d, Math.abs(v) < 1 && (k[n++] = v), v = (b + g) / d, Math.abs(v) < 1 && (k[n++] = v)), v = j * j - z * u, z == 0 ? Math.abs(u) < 2 * Math.abs(j) && (k[n++] = u / (2 * j)) : v > 0 && (g = Math.sqrt(v), v = (j - g) / z, Math.abs(v) < 1 && (k[n++] = v), v = (j + g) / z, Math.abs(v) < 1 && (k[n++] = v)), c = 1; c < n; c++) (v = k[c - 1]) > k[c] && (k[c - 1] = k[c], k[c] = v, c = 0);
|
|
6623
|
+
for (v = -1, k[n] = 1, c = 0; c <= n; c++) g = k[c], p = (v * (v * b - 2 * q) - g * (v * (v * d - 2 * b) + q) + s) / 8 - R, G = (v * (v * j - 2 * u) - g * (v * (v * z - 2 * j) + u) + B) / 8 - T, S = (g * (g * b - 2 * q) - v * (g * (g * d - 2 * b) + q) + s) / 8 - R, E = (g * (g * j - 2 * u) - v * (g * (g * z - 2 * j) + u) + B) / 8 - T, R -= W = (g * (g * (3 * b - g * d) - 3 * q) + s) / 8, T -= O = (g * (g * (3 * j - g * z) - 3 * u) + B) / 8, r = Math.floor(W + .5), l = Math.floor(O + .5), R != 0 && (p *= R = (f - r) / R, S *= R), T != 0 && (G *= T = (a - l) / T, E *= T), (f != r || a != l) && M(f, a, f + p, a + G, f + S, a + E, r, l, i), f = r, a = l, R = W, T = O, v = g;
|
|
6624
|
+
}
|
|
6625
|
+
function ra(f, a, o, t, e, h, r, l, M) {
|
|
6626
|
+
m(f, a, o, t, e, h, r, l, _, M);
|
|
6627
|
+
}
|
|
6628
|
+
function oa(f, a, o, t, e, h, r, l, M) {
|
|
6629
|
+
m(f, a, o, t, e, h, r, l, $, M);
|
|
6630
|
+
}
|
|
6631
|
+
N.circle = aa, N.circleAA = fa, N.cubicBezier = ra, N.cubicBezierAA = oa, N.cubicBezierSegment = _, N.cubicBezierSegmentAA = $, N.ellipse = y, N.ellipseRect = Z, N.line = J, N.lineAA = U, N.lineWidth = w, N.quadBezier = ta, N.quadBezierAA = ia, N.quadBezierSegment = L, N.quadBezierSegmentAA = Q, N.quadRationalBezier = P, N.quadRationalBezierSegment = H, N.quadRationalBezierSegmentAA = V, N.rotatedEllipse = x, N.rotatedEllipseRect = Y, Object.defineProperty(N, Symbol.toStringTag, {
|
|
6632
|
+
value: "Module"
|
|
6633
|
+
});
|
|
6634
|
+
});
|
|
6635
|
+
})(index_umd$1, index_umd$1.exports);
|
|
6636
|
+
var index_umdExports = index_umd$1.exports;
|
|
6254
6637
|
|
|
6255
6638
|
/**
|
|
6256
6639
|
* Remove duplicate points from array.
|
|
@@ -6277,7 +6660,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6277
6660
|
*/
|
|
6278
6661
|
function getCirclePoints(radius) {
|
|
6279
6662
|
const circlePoints = [];
|
|
6280
|
-
|
|
6663
|
+
index_umdExports.circle(radius, radius, radius, (column, row) => {
|
|
6281
6664
|
circlePoints.push({
|
|
6282
6665
|
row: row - radius,
|
|
6283
6666
|
column: column - radius
|
|
@@ -6313,7 +6696,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6313
6696
|
if (radius === 1) {
|
|
6314
6697
|
circlePoints.push(center);
|
|
6315
6698
|
}
|
|
6316
|
-
|
|
6699
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
6317
6700
|
circlePoints.push({
|
|
6318
6701
|
row,
|
|
6319
6702
|
column
|
|
@@ -6347,7 +6730,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6347
6730
|
*/
|
|
6348
6731
|
function getLinePoints(from, to) {
|
|
6349
6732
|
const linePoints = [];
|
|
6350
|
-
|
|
6733
|
+
index_umdExports.line(from.column, from.row, to.column, to.row, (column, row) => {
|
|
6351
6734
|
linePoints.push({
|
|
6352
6735
|
row,
|
|
6353
6736
|
column
|
|
@@ -6362,7 +6745,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6362
6745
|
* @returns The coordinates of the compass points.
|
|
6363
6746
|
*/
|
|
6364
6747
|
function getCompassPoints(radius) {
|
|
6365
|
-
|
|
6748
|
+
index_umdExports.circle(radius, radius, radius, (column, row) => {
|
|
6366
6749
|
});
|
|
6367
6750
|
return [{
|
|
6368
6751
|
row: 0,
|
|
@@ -6673,7 +7056,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6673
7056
|
channels: [1],
|
|
6674
7057
|
alpha: false
|
|
6675
7058
|
});
|
|
6676
|
-
const getScore =
|
|
7059
|
+
const getScore = M$2(scoreAlgorithm).with('HARRIS', () => {
|
|
6677
7060
|
return (image, corner) => getHarrisScore(image, corner, harrisScoreOptions);
|
|
6678
7061
|
}).with('FAST', () => {
|
|
6679
7062
|
return (image, corner) => getFastScore(image, corner, threshold, circlePoints);
|
|
@@ -8055,11 +8438,13 @@ ${indent}columns: ${matrix.columns}
|
|
|
8055
8438
|
* @returns Sorted copy of the array of matches.
|
|
8056
8439
|
*/
|
|
8057
8440
|
function sortBySourceDest(matches) {
|
|
8058
|
-
|
|
8441
|
+
const sorted = matches.slice();
|
|
8442
|
+
sorted.sort((match1, match2) => {
|
|
8059
8443
|
if (match1.sourceIndex < match2.sourceIndex) return -1;
|
|
8060
8444
|
if (match1.sourceIndex > match2.sourceIndex) return 1;
|
|
8061
8445
|
return match1.destinationIndex - match2.destinationIndex;
|
|
8062
8446
|
});
|
|
8447
|
+
return sorted;
|
|
8063
8448
|
}
|
|
8064
8449
|
/**
|
|
8065
8450
|
* Sort array of matches by destination index and then source index.
|
|
@@ -8067,11 +8452,13 @@ ${indent}columns: ${matrix.columns}
|
|
|
8067
8452
|
* @returns Sorted copy of the array of matches.
|
|
8068
8453
|
*/
|
|
8069
8454
|
function sortByDestSource(matches) {
|
|
8070
|
-
|
|
8455
|
+
const sorted = matches.slice();
|
|
8456
|
+
sorted.sort((match1, match2) => {
|
|
8071
8457
|
if (match1.destinationIndex < match2.destinationIndex) return -1;
|
|
8072
8458
|
if (match1.destinationIndex > match2.destinationIndex) return 1;
|
|
8073
8459
|
return match1.sourceIndex - match2.sourceIndex;
|
|
8074
8460
|
});
|
|
8461
|
+
return sorted;
|
|
8075
8462
|
}
|
|
8076
8463
|
|
|
8077
8464
|
/**
|
|
@@ -8274,7 +8661,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8274
8661
|
* @returns Default color.
|
|
8275
8662
|
*/
|
|
8276
8663
|
function getDefaultColor(image) {
|
|
8277
|
-
return
|
|
8664
|
+
return M$2(image.colorModel).with('GREY', () => [0]).with('GREYA', () => [0, image.maxValue]).with('RGB', () => [0, 0, 0]).with('RGBA', () => [0, 0, 0, image.maxValue]).with('BINARY', () => [1]).exhaustive();
|
|
8278
8665
|
}
|
|
8279
8666
|
|
|
8280
8667
|
/**
|
|
@@ -8282,7 +8669,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8282
8669
|
* @param image - The image with which to blend.
|
|
8283
8670
|
* @param column - Column of the target pixel.
|
|
8284
8671
|
* @param row - Row of the target pixel.
|
|
8285
|
-
* @param color - Color with which to blend the image pixel.
|
|
8672
|
+
* @param color - Color with which to blend the image pixel. Default: `Opaque black`.
|
|
8286
8673
|
*/
|
|
8287
8674
|
function setBlendedPixel(image, column, row, color) {
|
|
8288
8675
|
color = color ?? getDefaultColor(image);
|
|
@@ -8312,7 +8699,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8312
8699
|
* @param image - The image with which to blend.
|
|
8313
8700
|
* @param column - Column of the target pixel.
|
|
8314
8701
|
* @param row - Row of the target pixel.
|
|
8315
|
-
* @param color - Color with which to blend the image pixel.
|
|
8702
|
+
* @param color - Color with which to blend the image pixel. Default: `Opaque black`.
|
|
8316
8703
|
*/
|
|
8317
8704
|
function setBlendedVisiblePixel(image, column, row, color) {
|
|
8318
8705
|
if (column >= 0 && column < image.width && row >= 0 && row < image.height) {
|
|
@@ -8362,7 +8749,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8362
8749
|
return newImage;
|
|
8363
8750
|
}
|
|
8364
8751
|
if (!fillColor) {
|
|
8365
|
-
|
|
8752
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
8366
8753
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8367
8754
|
});
|
|
8368
8755
|
} else {
|
|
@@ -8372,7 +8759,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8372
8759
|
//Starting points for the top and bottom row of the circle.
|
|
8373
8760
|
let prevRow = center.row + radius;
|
|
8374
8761
|
let index = 0;
|
|
8375
|
-
|
|
8762
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
8376
8763
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8377
8764
|
// Filling the first line of the circle.
|
|
8378
8765
|
if (index === 0) {
|
|
@@ -8445,7 +8832,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8445
8832
|
checkProcessable$1(newImage, {
|
|
8446
8833
|
bitDepth: [8, 16]
|
|
8447
8834
|
});
|
|
8448
|
-
|
|
8835
|
+
index_umdExports.line(Math.round(origin.column + from.column), Math.round(origin.row + from.row), Math.round(origin.column + to.column), Math.round(origin.row + to.row), (column, row) => {
|
|
8449
8836
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8450
8837
|
});
|
|
8451
8838
|
return newImage;
|
|
@@ -8469,7 +8856,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8469
8856
|
const newMask = maskToOutputMask(mask, options, {
|
|
8470
8857
|
clone: true
|
|
8471
8858
|
});
|
|
8472
|
-
|
|
8859
|
+
index_umdExports.line(Math.round(origin.column + from.column), Math.round(origin.row + from.row), Math.round(origin.column + to.column), Math.round(origin.row + to.row), (column, row) => {
|
|
8473
8860
|
newMask.setVisiblePixel(column, row, [1]);
|
|
8474
8861
|
});
|
|
8475
8862
|
return newMask;
|
|
@@ -9575,7 +9962,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
9575
9962
|
* @returns The border interpolation function.
|
|
9576
9963
|
*/
|
|
9577
9964
|
function getBorderInterpolation(type, value) {
|
|
9578
|
-
return
|
|
9965
|
+
return M$2(type).with('constant', () => getInterpolateConstant(value)).with('replicate', () => interpolateReplicate).with('reflect', () => interpolateReflect).with('reflect101', () => interpolateReflect101).with('wrap', () => interpolateWrap).exhaustive();
|
|
9579
9966
|
}
|
|
9580
9967
|
function checkRange(point, length) {
|
|
9581
9968
|
if (point <= 0 - length || point >= length + length - 1) {
|
|
@@ -9975,7 +10362,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
9975
10362
|
const {
|
|
9976
10363
|
filter = 'sobel'
|
|
9977
10364
|
} = options;
|
|
9978
|
-
const kernels =
|
|
10365
|
+
const kernels = M$2(filter).with('sobel', () => ({
|
|
9979
10366
|
kernelX: SOBEL_X,
|
|
9980
10367
|
kernelY: SOBEL_Y
|
|
9981
10368
|
})).with('scharr', () => ({
|
|
@@ -11559,7 +11946,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
11559
11946
|
slots
|
|
11560
11947
|
});
|
|
11561
11948
|
const scale = slots ? 2 ** image.bitDepth / slots : 1;
|
|
11562
|
-
return
|
|
11949
|
+
return M$2(algorithm).with('huang', () => huang(histogram) * scale).with('intermodes', () => intermodes(histogram) * scale).with('isodata', () => isodata(histogram) * scale).with('li', () => li(histogram, image.size) * scale).with('maxEntropy', () => maxEntropy(histogram, image.size) * scale).with('mean', () => mean$1(histogram, image.size) * scale).with('minimum', () => minimum(histogram) * scale).with('minError', () => minError(histogram, image.size) * scale).with('moments', () => moments(histogram, image.size) * scale).with('otsu', () => otsu(histogram, image.size) * scale).with('percentile', () => percentile(histogram) * scale).with('renyiEntropy', () => renyiEntropy(histogram, image.size) * scale).with('shanbhag', () => shanbhag(histogram, image.size) * scale).with('triangle', () => triangle(histogram) * scale).with('yen', () => yen(histogram, image.size) * scale).exhaustive();
|
|
11563
11950
|
}
|
|
11564
11951
|
// See: https://docs.opencv.org/4.0.1/d7/d1b/group__imgproc__misc.html#gaa9e58d2860d4afa658ef70a9b1115576
|
|
11565
11952
|
/**
|
|
@@ -12070,7 +12457,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
12070
12457
|
* @returns The interpolation function.
|
|
12071
12458
|
*/
|
|
12072
12459
|
function getInterpolationFunction(interpolationType) {
|
|
12073
|
-
return
|
|
12460
|
+
return M$2(interpolationType).with('nearest', () => interpolateNearest).with('bilinear', () => interpolateBilinear).with('bicubic', () => interpolateBicubic).exhaustive();
|
|
12074
12461
|
}
|
|
12075
12462
|
/**
|
|
12076
12463
|
* Interpolate using nearest neighbor.
|
|
@@ -13573,7 +13960,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
13573
13960
|
sorted = false
|
|
13574
13961
|
} = options;
|
|
13575
13962
|
if (!sorted) {
|
|
13576
|
-
points = points.slice()
|
|
13963
|
+
points = points.slice();
|
|
13964
|
+
points.sort(byXThenY);
|
|
13577
13965
|
}
|
|
13578
13966
|
const n = points.length;
|
|
13579
13967
|
const result = new Array(n * 2);
|
|
@@ -13836,7 +14224,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
13836
14224
|
* @returns The angle in degrees.
|
|
13837
14225
|
*/
|
|
13838
14226
|
function getMbrAngle(mbr) {
|
|
13839
|
-
const sorted = mbr.slice()
|
|
14227
|
+
const sorted = mbr.slice();
|
|
14228
|
+
sorted.sort(leftFirst);
|
|
13840
14229
|
const left = sorted.slice(0, 2);
|
|
13841
14230
|
const right = sorted.slice(2, 4);
|
|
13842
14231
|
left.sort(topFirst);
|
|
@@ -15021,7 +15410,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
15021
15410
|
}
|
|
15022
15411
|
/**
|
|
15023
15412
|
* Get the number of pixels that do not have the value 0.
|
|
15024
|
-
* @returns
|
|
15413
|
+
* @returns The number of non-zero pixels.
|
|
15025
15414
|
*/
|
|
15026
15415
|
getNbNonZeroPixels() {
|
|
15027
15416
|
let count = 0;
|
|
@@ -16794,7 +17183,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
16794
17183
|
* @returns Coordinates of the point in the format [column, row].
|
|
16795
17184
|
*/
|
|
16796
17185
|
getCoordinates(coordinates, round = false) {
|
|
16797
|
-
return
|
|
17186
|
+
return M$2(coordinates).with('center', () => {
|
|
16798
17187
|
const centerX = (this.width - 1) / 2;
|
|
16799
17188
|
const centerY = (this.height - 1) / 2;
|
|
16800
17189
|
if (round) {
|
|
@@ -17213,7 +17602,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
17213
17602
|
*/
|
|
17214
17603
|
function createPixelArray(size, channels, alpha, bitDepth, maxValue) {
|
|
17215
17604
|
const length = channels * size;
|
|
17216
|
-
const arr =
|
|
17605
|
+
const arr = M$2(bitDepth).with(8, () => new Uint8Array(length)).with(16, () => new Uint16Array(length)).otherwise(() => {
|
|
17217
17606
|
throw new RangeError(`invalid bitDepth: ${bitDepth}`);
|
|
17218
17607
|
});
|
|
17219
17608
|
// Alpha channel is 100% by default.
|
|
@@ -17542,9 +17931,11 @@ ${indent}columns: ${matrix.columns}
|
|
|
17542
17931
|
* @returns Sorted copy of the array of matches.
|
|
17543
17932
|
*/
|
|
17544
17933
|
function sortByDistance(matches) {
|
|
17545
|
-
|
|
17934
|
+
const sorted = matches.slice();
|
|
17935
|
+
sorted.sort((match1, match2) => {
|
|
17546
17936
|
return match1.distance - match2.distance;
|
|
17547
17937
|
});
|
|
17938
|
+
return sorted;
|
|
17548
17939
|
}
|
|
17549
17940
|
|
|
17550
17941
|
/**
|
|
@@ -17803,7 +18194,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
17803
18194
|
row: 0
|
|
17804
18195
|
}
|
|
17805
18196
|
} = options;
|
|
17806
|
-
const sorted = matches.
|
|
18197
|
+
const sorted = matches.slice();
|
|
18198
|
+
sorted.sort((a, b) => a.destinationIndex - b.destinationIndex);
|
|
17807
18199
|
const result = [];
|
|
17808
18200
|
let sameDestMatches = [];
|
|
17809
18201
|
let currentIndex = sorted[0].destinationIndex;
|
|
@@ -17811,12 +18203,14 @@ ${indent}columns: ${matrix.columns}
|
|
|
17811
18203
|
if (match.destinationIndex === currentIndex) {
|
|
17812
18204
|
sameDestMatches.push(match);
|
|
17813
18205
|
} else {
|
|
17814
|
-
|
|
18206
|
+
sameDestMatches.sort((a, b) => distanceSquared(a) - distanceSquared(b));
|
|
18207
|
+
result.push(...sameDestMatches.slice(0, 1));
|
|
17815
18208
|
currentIndex = match.destinationIndex;
|
|
17816
18209
|
sameDestMatches = [match];
|
|
17817
18210
|
}
|
|
17818
18211
|
}
|
|
17819
|
-
|
|
18212
|
+
sameDestMatches.sort((a, b) => distanceSquared(a) - distanceSquared(b));
|
|
18213
|
+
result.push(...sameDestMatches.slice(0, 1));
|
|
17820
18214
|
return result;
|
|
17821
18215
|
function distanceSquared(match) {
|
|
17822
18216
|
return (sourceKeypoints[match.sourceIndex].origin.row - (destinationKeypoints[match.destinationIndex].origin.row - origin.row)) ** 2 + (sourceKeypoints[match.sourceIndex].origin.column - destinationKeypoints[match.destinationIndex].origin.column - origin.column) ** 2;
|
|
@@ -17829,7 +18223,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
17829
18223
|
* @param encoding - Text encoding
|
|
17830
18224
|
* @returns The decoded text
|
|
17831
18225
|
*/
|
|
17832
|
-
function decode$
|
|
18226
|
+
function decode$4(bytes, encoding = 'utf8') {
|
|
17833
18227
|
const decoder = new TextDecoder(encoding);
|
|
17834
18228
|
return decoder.decode(bytes);
|
|
17835
18229
|
}
|
|
@@ -18225,7 +18619,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
18225
18619
|
* @returns The decoded string.
|
|
18226
18620
|
*/
|
|
18227
18621
|
readUtf8(n = 1) {
|
|
18228
|
-
return decode$
|
|
18622
|
+
return decode$4(this.readBytes(n));
|
|
18229
18623
|
}
|
|
18230
18624
|
/**
|
|
18231
18625
|
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer
|
|
@@ -18236,7 +18630,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
18236
18630
|
* @returns The decoded string.
|
|
18237
18631
|
*/
|
|
18238
18632
|
decodeText(n = 1, encoding = 'utf8') {
|
|
18239
|
-
return decode$
|
|
18633
|
+
return decode$4(this.readBytes(n), encoding);
|
|
18240
18634
|
}
|
|
18241
18635
|
/**
|
|
18242
18636
|
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
|
|
@@ -18457,6 +18851,117 @@ ${indent}columns: ${matrix.columns}
|
|
|
18457
18851
|
}
|
|
18458
18852
|
}
|
|
18459
18853
|
|
|
18854
|
+
class BMPDecoder {
|
|
18855
|
+
bufferData;
|
|
18856
|
+
pixelDataOffset;
|
|
18857
|
+
width;
|
|
18858
|
+
height;
|
|
18859
|
+
bitsPerPixel;
|
|
18860
|
+
xPixelsPerMeter;
|
|
18861
|
+
yPixelsPerMeter;
|
|
18862
|
+
compression;
|
|
18863
|
+
colorMasks;
|
|
18864
|
+
constructor(bufferData) {
|
|
18865
|
+
this.bufferData = new IOBuffer(bufferData);
|
|
18866
|
+
const formatCheck = this.bufferData.readBytes(2);
|
|
18867
|
+
if (formatCheck[0] !== 0x42 && formatCheck[1] !== 0x4d) {
|
|
18868
|
+
throw new Error('This is not a BMP image or the encoding is not correct.');
|
|
18869
|
+
}
|
|
18870
|
+
this.pixelDataOffset = this.bufferData.skip(8).readUint32();
|
|
18871
|
+
this.width = this.bufferData.skip(4).readUint32();
|
|
18872
|
+
this.height = this.bufferData.readUint32();
|
|
18873
|
+
this.bitsPerPixel = this.bufferData.seek(28).readUint16();
|
|
18874
|
+
if (this.bitsPerPixel !== 1 && this.bitsPerPixel !== 8 && this.bitsPerPixel !== 24 && this.bitsPerPixel !== 32) {
|
|
18875
|
+
throw new Error(`Invalid number of bits per pixel. Supported number of bits per pixel: 1, 8, 24, 32. Received: ${this.bitsPerPixel}`);
|
|
18876
|
+
}
|
|
18877
|
+
this.compression = this.bufferData.readUint32();
|
|
18878
|
+
if (this.compression !== 0 && this.compression !== 3) {
|
|
18879
|
+
throw new Error(`Only BI_RGB and BI_BITFIELDS compression methods are allowed. `);
|
|
18880
|
+
}
|
|
18881
|
+
this.colorMasks = [this.bufferData.seek(54).readUint32(), this.bufferData.readUint32(), this.bufferData.readUint32()];
|
|
18882
|
+
if (this.bitsPerPixel === 32 && (this.colorMasks[0] !== 0x00ff0000 || this.colorMasks[1] !== 0x0000ff00 || this.colorMasks[2] !== 0x000000ff)) {
|
|
18883
|
+
throw new Error(`Unsupported color masks detected in 32-bit BMP image. Only standard RGBA (${0x00ff0000.toString(16)}, ${0x0000ff00.toString(16)}, ${0x000000ff.toString(16)}) masks are supported. Received: ${this.colorMasks[0].toString(16)},${this.colorMasks[1].toString(16)},${this.colorMasks[2].toString(16)}.`);
|
|
18884
|
+
}
|
|
18885
|
+
this.bufferData.skip(1); // skipping image size.
|
|
18886
|
+
this.xPixelsPerMeter = this.bufferData.seek(38).readInt32();
|
|
18887
|
+
this.yPixelsPerMeter = this.bufferData.readInt32();
|
|
18888
|
+
this.bufferData.skip(1);
|
|
18889
|
+
}
|
|
18890
|
+
decode() {
|
|
18891
|
+
this.bufferData.seek(this.pixelDataOffset);
|
|
18892
|
+
this.bufferData.setBigEndian();
|
|
18893
|
+
const channels = Math.ceil(this.bitsPerPixel / 8);
|
|
18894
|
+
const components = channels % 2 === 0 ? channels - 1 : channels;
|
|
18895
|
+
const data = this.decodePixelData(channels, components);
|
|
18896
|
+
return {
|
|
18897
|
+
width: this.width,
|
|
18898
|
+
height: this.height,
|
|
18899
|
+
bitsPerPixel: this.bitsPerPixel,
|
|
18900
|
+
compression: this.compression,
|
|
18901
|
+
colorMasks: this.colorMasks,
|
|
18902
|
+
channels,
|
|
18903
|
+
components,
|
|
18904
|
+
data,
|
|
18905
|
+
yPixelsPerMeter: this.yPixelsPerMeter,
|
|
18906
|
+
xPixelsPerMeter: this.xPixelsPerMeter
|
|
18907
|
+
};
|
|
18908
|
+
}
|
|
18909
|
+
decodePixelData(channels, components) {
|
|
18910
|
+
const data = new Uint8Array(this.height * this.width * channels);
|
|
18911
|
+
if (this.bitsPerPixel === 1) {
|
|
18912
|
+
this.decodeBitDepth1Pixels(data);
|
|
18913
|
+
} else if (channels === components) {
|
|
18914
|
+
this.decodeStandardPixels(data, channels);
|
|
18915
|
+
} else {
|
|
18916
|
+
this.decodePixelsWithAlpha(data, channels, components);
|
|
18917
|
+
}
|
|
18918
|
+
return data;
|
|
18919
|
+
}
|
|
18920
|
+
decodeBitDepth1Pixels(data) {
|
|
18921
|
+
let currentNumber = 0;
|
|
18922
|
+
for (let row = 0; row < this.height; row++) {
|
|
18923
|
+
for (let col = 0; col < this.width; col++) {
|
|
18924
|
+
const bitIndex = col % 32;
|
|
18925
|
+
if (bitIndex === 0) {
|
|
18926
|
+
currentNumber = this.bufferData.readUint32();
|
|
18927
|
+
}
|
|
18928
|
+
if (currentNumber & 1 << 31 - bitIndex) {
|
|
18929
|
+
data[(this.height - row - 1) * this.width + col] = 1;
|
|
18930
|
+
}
|
|
18931
|
+
}
|
|
18932
|
+
}
|
|
18933
|
+
}
|
|
18934
|
+
decodeStandardPixels(data, channels) {
|
|
18935
|
+
const padding = this.calculatePadding(channels);
|
|
18936
|
+
for (let row = 0; row < this.height; row++) {
|
|
18937
|
+
const rowOffset = (this.height - row - 1) * this.width;
|
|
18938
|
+
for (let col = 0; col < this.width; col++) {
|
|
18939
|
+
for (let channel = channels - 1; channel >= 0; channel--) {
|
|
18940
|
+
data[(rowOffset + col) * channels + channel] = this.bufferData.readByte();
|
|
18941
|
+
}
|
|
18942
|
+
}
|
|
18943
|
+
this.bufferData.skip(padding);
|
|
18944
|
+
}
|
|
18945
|
+
}
|
|
18946
|
+
decodePixelsWithAlpha(data, channels, components) {
|
|
18947
|
+
for (let row = 0; row < this.height; row++) {
|
|
18948
|
+
const rowOffset = (this.height - row - 1) * this.width;
|
|
18949
|
+
for (let col = 0; col < this.width; col++) {
|
|
18950
|
+
const pixelBaseIndex = (rowOffset + col) * channels;
|
|
18951
|
+
// Decode color components
|
|
18952
|
+
for (let component = components - 1; component >= 0; component--) {
|
|
18953
|
+
data[pixelBaseIndex + component] = this.bufferData.readByte();
|
|
18954
|
+
}
|
|
18955
|
+
// Decode alpha channel
|
|
18956
|
+
data[pixelBaseIndex + components] = this.bufferData.readByte();
|
|
18957
|
+
}
|
|
18958
|
+
}
|
|
18959
|
+
}
|
|
18960
|
+
calculatePadding(channels) {
|
|
18961
|
+
return this.width * channels % 4 === 0 ? 0 : 4 - this.width * channels % 4;
|
|
18962
|
+
}
|
|
18963
|
+
}
|
|
18964
|
+
|
|
18460
18965
|
const BITMAPV5HEADER = {
|
|
18461
18966
|
LogicalColorSpace: {
|
|
18462
18967
|
LCS_sRGB: 0x73524742},
|
|
@@ -18618,25 +19123,41 @@ ${indent}columns: ${matrix.columns}
|
|
|
18618
19123
|
const encoder = new BMPEncoder(data);
|
|
18619
19124
|
return encoder.encode();
|
|
18620
19125
|
}
|
|
19126
|
+
/**
|
|
19127
|
+
* Decodes BMP format image into data.
|
|
19128
|
+
* @param data - Buffer with image data.
|
|
19129
|
+
* @returns - Decoded data.
|
|
19130
|
+
*/
|
|
19131
|
+
function decode$3(data) {
|
|
19132
|
+
const decoder = new BMPDecoder(data);
|
|
19133
|
+
return decoder.decode();
|
|
19134
|
+
}
|
|
18621
19135
|
|
|
18622
19136
|
/**
|
|
18623
19137
|
* Creates a BMP buffer from a mask.
|
|
18624
|
-
* @param
|
|
19138
|
+
* @param image - The mask instance.
|
|
18625
19139
|
* @returns The buffer.
|
|
18626
19140
|
*/
|
|
18627
|
-
function encodeBmp(
|
|
18628
|
-
if (
|
|
18629
|
-
|
|
19141
|
+
function encodeBmp(image) {
|
|
19142
|
+
if (image instanceof Image) {
|
|
19143
|
+
return encode$2({
|
|
19144
|
+
width: image.width,
|
|
19145
|
+
height: image.height,
|
|
19146
|
+
components: image.components,
|
|
19147
|
+
bitsPerPixel: image.channels * image.bitDepth,
|
|
19148
|
+
channels: image.channels,
|
|
19149
|
+
data: image.getRawImage().data
|
|
19150
|
+
});
|
|
19151
|
+
} else {
|
|
19152
|
+
return encode$2({
|
|
19153
|
+
width: image.width,
|
|
19154
|
+
height: image.height,
|
|
19155
|
+
components: 1,
|
|
19156
|
+
bitsPerPixel: 1,
|
|
19157
|
+
channels: 1,
|
|
19158
|
+
data: image.getRawImage().data
|
|
19159
|
+
});
|
|
18630
19160
|
}
|
|
18631
|
-
const imageData = mask.getRawImage();
|
|
18632
|
-
return encode$2({
|
|
18633
|
-
width: imageData.width,
|
|
18634
|
-
height: imageData.height,
|
|
18635
|
-
components: 1,
|
|
18636
|
-
bitsPerPixel: 1,
|
|
18637
|
-
channels: 1,
|
|
18638
|
-
data: imageData.data
|
|
18639
|
-
});
|
|
18640
19161
|
}
|
|
18641
19162
|
|
|
18642
19163
|
var encoder = {exports: {}};
|
|
@@ -28103,6 +28624,10 @@ ${indent}columns: ${matrix.columns}
|
|
|
28103
28624
|
const encoder = new PngEncoder(png, options);
|
|
28104
28625
|
return encoder.encode();
|
|
28105
28626
|
}
|
|
28627
|
+
function decodeApng(data, options) {
|
|
28628
|
+
const decoder = new PngDecoder(data, options);
|
|
28629
|
+
return decoder.decodeApng();
|
|
28630
|
+
}
|
|
28106
28631
|
|
|
28107
28632
|
/**
|
|
28108
28633
|
* Creates a PNG buffer from an image.
|
|
@@ -28140,10 +28665,10 @@ ${indent}columns: ${matrix.columns}
|
|
|
28140
28665
|
* @returns The encoded image.
|
|
28141
28666
|
*/
|
|
28142
28667
|
function encode(image, options = defaultPng) {
|
|
28143
|
-
return
|
|
28668
|
+
return M$2(options).with({
|
|
28144
28669
|
format: 'png'
|
|
28145
28670
|
}, options => encodePng(image, options.encoderOptions)).with({
|
|
28146
|
-
format:
|
|
28671
|
+
format: z.union('jpg', 'jpeg')
|
|
28147
28672
|
}, options => encodeJpeg(image, options.encoderOptions)).with({
|
|
28148
28673
|
format: 'bmp'
|
|
28149
28674
|
}, () => encodeBmp(image)).exhaustive();
|
|
@@ -28155,7 +28680,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
28155
28680
|
* @returns - The `fs`, `path` and `url` Node.js modules.
|
|
28156
28681
|
*/
|
|
28157
28682
|
function getNodeApiOrThrow(methodName) {
|
|
28158
|
-
if (
|
|
28683
|
+
if (!isNode()) {
|
|
28159
28684
|
throw new Error(`${methodName} is only implemented for Node.js`);
|
|
28160
28685
|
}
|
|
28161
28686
|
return {
|
|
@@ -28164,6 +28689,35 @@ ${indent}columns: ${matrix.columns}
|
|
|
28164
28689
|
url: process.getBuiltinModule('node:url')
|
|
28165
28690
|
};
|
|
28166
28691
|
}
|
|
28692
|
+
let CanvasCtorBrowser;
|
|
28693
|
+
let CanvasCtorNode;
|
|
28694
|
+
/**
|
|
28695
|
+
* Returns a 2D canvas context for rendering on the browser or Node.js.
|
|
28696
|
+
* @param width - Width of the canvas.
|
|
28697
|
+
* @param height - Height of the canvas.
|
|
28698
|
+
* @returns The initialised canvas context.
|
|
28699
|
+
*/
|
|
28700
|
+
function getCanvasContext(width, height) {
|
|
28701
|
+
if (isNode()) {
|
|
28702
|
+
CanvasCtorNode ??= getRequireFn()('skia-canvas').Canvas;
|
|
28703
|
+
return new CanvasCtorNode(width, height).getContext('2d');
|
|
28704
|
+
} else {
|
|
28705
|
+
CanvasCtorBrowser ??= globalThis.OffscreenCanvas;
|
|
28706
|
+
const context = new CanvasCtorBrowser(width, height).getContext('2d');
|
|
28707
|
+
if (!context) {
|
|
28708
|
+
throw new Error('Failed to create canvas context');
|
|
28709
|
+
}
|
|
28710
|
+
return context;
|
|
28711
|
+
}
|
|
28712
|
+
}
|
|
28713
|
+
function isNode() {
|
|
28714
|
+
return typeof process !== 'undefined' && typeof process.getBuiltinModule === 'function';
|
|
28715
|
+
}
|
|
28716
|
+
let requireFn;
|
|
28717
|
+
function getRequireFn() {
|
|
28718
|
+
requireFn ??= process.getBuiltinModule('node:module').createRequire((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('image-js.umd.js', document.baseURI).href)));
|
|
28719
|
+
return requireFn;
|
|
28720
|
+
}
|
|
28167
28721
|
|
|
28168
28722
|
/**
|
|
28169
28723
|
* Asynchronously write an image to the disk.
|
|
@@ -28190,7 +28744,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
28190
28744
|
await nodeApi.fs.promises.writeFile(path, toWrite);
|
|
28191
28745
|
}
|
|
28192
28746
|
/**
|
|
28193
|
-
* Synchronous version of
|
|
28747
|
+
* Synchronous version of {@link write}.
|
|
28194
28748
|
* This method is only implemented for Node.js.
|
|
28195
28749
|
* @param path - Path where the image should be written.
|
|
28196
28750
|
* @param image - Image to save.
|
|
@@ -28661,7 +29215,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
28661
29215
|
}
|
|
28662
29216
|
const channel = options?.channel || 0;
|
|
28663
29217
|
const isMax = kind === 'maximum';
|
|
28664
|
-
const sortedPoints = points.slice()
|
|
29218
|
+
const sortedPoints = points.slice();
|
|
29219
|
+
sortedPoints.sort(getSort(image, channel, isMax));
|
|
28665
29220
|
if (distance > 0) {
|
|
28666
29221
|
for (let i = 0; i < sortedPoints.length; i++) {
|
|
28667
29222
|
for (let j = i + 1; j < sortedPoints.length; j++) {
|
|
@@ -29662,6 +30217,38 @@ ${indent}columns: ${matrix.columns}
|
|
|
29662
30217
|
var imageTypeExports = imageType$2.exports;
|
|
29663
30218
|
var imageType$1 = /*@__PURE__*/getDefaultExportFromCjs(imageTypeExports);
|
|
29664
30219
|
|
|
30220
|
+
/**
|
|
30221
|
+
* Decode a BMP. See the fast-bmp npm module.
|
|
30222
|
+
* @param data - The data to decode.
|
|
30223
|
+
* @returns The decoded image or mask.
|
|
30224
|
+
*/
|
|
30225
|
+
function decodeBmp(data) {
|
|
30226
|
+
const decodedData = decode$3(data);
|
|
30227
|
+
if (decodedData.bitsPerPixel === 1) {
|
|
30228
|
+
const mask = new Mask(decodedData.width, decodedData.height, {
|
|
30229
|
+
data: decodedData.data
|
|
30230
|
+
});
|
|
30231
|
+
return mask.convertColor('GREY');
|
|
30232
|
+
} else {
|
|
30233
|
+
let colorModel;
|
|
30234
|
+
switch (decodedData.channels) {
|
|
30235
|
+
case 1:
|
|
30236
|
+
colorModel = 'GREY';
|
|
30237
|
+
break;
|
|
30238
|
+
case 3:
|
|
30239
|
+
colorModel = 'RGB';
|
|
30240
|
+
break;
|
|
30241
|
+
default:
|
|
30242
|
+
colorModel = 'RGBA';
|
|
30243
|
+
break;
|
|
30244
|
+
}
|
|
30245
|
+
return new Image(decodedData.width, decodedData.height, {
|
|
30246
|
+
colorModel,
|
|
30247
|
+
data: decodedData.data
|
|
30248
|
+
});
|
|
30249
|
+
}
|
|
30250
|
+
}
|
|
30251
|
+
|
|
29665
30252
|
const tagsById$2 = {
|
|
29666
30253
|
0x829a: 'ExposureTime',
|
|
29667
30254
|
0x829d: 'FNumber',
|
|
@@ -30380,7 +30967,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
30380
30967
|
return this.get('SamplesPerPixel') || 1;
|
|
30381
30968
|
}
|
|
30382
30969
|
get rowsPerStrip() {
|
|
30383
|
-
return this.get('RowsPerStrip');
|
|
30970
|
+
return this.get('RowsPerStrip') || 2 ** 32 - 1;
|
|
30384
30971
|
}
|
|
30385
30972
|
get stripByteCounts() {
|
|
30386
30973
|
return alwaysArray(this.get('StripByteCounts'));
|
|
@@ -30934,10 +31521,16 @@ ${indent}columns: ${matrix.columns}
|
|
|
30934
31521
|
function decodePng(buffer) {
|
|
30935
31522
|
const png = decodePng$1(buffer);
|
|
30936
31523
|
let colorModel;
|
|
30937
|
-
const bitDepth = png.depth
|
|
31524
|
+
const bitDepth = png.depth;
|
|
30938
31525
|
if (png.palette) {
|
|
30939
31526
|
return loadPalettePng(png);
|
|
30940
31527
|
}
|
|
31528
|
+
if (bitDepth === 1) {
|
|
31529
|
+
return new Image(png.width, png.height, {
|
|
31530
|
+
data: decodeBinary(png),
|
|
31531
|
+
colorModel: 'GREY'
|
|
31532
|
+
});
|
|
31533
|
+
}
|
|
30941
31534
|
switch (png.channels) {
|
|
30942
31535
|
case 1:
|
|
30943
31536
|
colorModel = 'GREY';
|
|
@@ -30968,7 +31561,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
30968
31561
|
function loadPalettePng(png) {
|
|
30969
31562
|
assert(png.palette);
|
|
30970
31563
|
const pixels = png.width * png.height;
|
|
30971
|
-
const data = new Uint8Array(pixels *
|
|
31564
|
+
const data = new Uint8Array(pixels * png.palette[0].length);
|
|
30972
31565
|
const pixelsPerByte = 8 / png.depth;
|
|
30973
31566
|
const factor = png.depth < 8 ? pixelsPerByte : 1;
|
|
30974
31567
|
const mask = Number.parseInt('1'.repeat(png.depth), 2);
|
|
@@ -30980,14 +31573,32 @@ ${indent}columns: ${matrix.columns}
|
|
|
30980
31573
|
value = value >>> png.depth * (pixelsPerByte - 1 - i % pixelsPerByte) & mask;
|
|
30981
31574
|
}
|
|
30982
31575
|
const paletteValue = png.palette[value];
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
|
|
31576
|
+
for (const paletteChannel of paletteValue) {
|
|
31577
|
+
data[dataIndex++] = paletteChannel;
|
|
31578
|
+
}
|
|
30986
31579
|
}
|
|
30987
31580
|
return new Image(png.width, png.height, {
|
|
30988
|
-
data
|
|
31581
|
+
data,
|
|
31582
|
+
colorModel: png.palette[0].length === 4 ? 'RGBA' : 'RGB'
|
|
30989
31583
|
});
|
|
30990
31584
|
}
|
|
31585
|
+
function decodeBinary(png) {
|
|
31586
|
+
const totalPixels = png.width * png.height;
|
|
31587
|
+
const result = new Uint8Array(totalPixels);
|
|
31588
|
+
const pngData = png.data;
|
|
31589
|
+
const padding = png.width % 8;
|
|
31590
|
+
const bytesPerLine = Math.ceil(png.width / 8);
|
|
31591
|
+
let pixelIndex = 0;
|
|
31592
|
+
for (let byteIndex = 0; byteIndex < pngData.length && pixelIndex < totalPixels; byteIndex++) {
|
|
31593
|
+
const byte = pngData[byteIndex];
|
|
31594
|
+
const limit = byteIndex % bytesPerLine === 0 ? 8 - padding : 0;
|
|
31595
|
+
for (let bitIndex = 7; bitIndex >= limit && pixelIndex < totalPixels; bitIndex--) {
|
|
31596
|
+
const bit = byte >> bitIndex & 1;
|
|
31597
|
+
result[pixelIndex++] = bit * 255;
|
|
31598
|
+
}
|
|
31599
|
+
}
|
|
31600
|
+
return result;
|
|
31601
|
+
}
|
|
30991
31602
|
|
|
30992
31603
|
/**
|
|
30993
31604
|
* Decode a TIFF. See the tiff module.
|
|
@@ -30995,9 +31606,10 @@ ${indent}columns: ${matrix.columns}
|
|
|
30995
31606
|
* @returns The decoded image.
|
|
30996
31607
|
*/
|
|
30997
31608
|
function decodeTiff(buffer) {
|
|
30998
|
-
const result = decodeTIFF(buffer
|
|
31609
|
+
const result = decodeTIFF(buffer, {
|
|
31610
|
+
pages: [0]
|
|
31611
|
+
});
|
|
30999
31612
|
return getImageFromIFD(result[0]);
|
|
31000
|
-
// TODO: optimize not to decode whole file
|
|
31001
31613
|
}
|
|
31002
31614
|
/**
|
|
31003
31615
|
* Create image from a single IFD.
|
|
@@ -31005,32 +31617,59 @@ ${indent}columns: ${matrix.columns}
|
|
|
31005
31617
|
* @returns The decoded image.
|
|
31006
31618
|
*/
|
|
31007
31619
|
function getImageFromIFD(ifd) {
|
|
31620
|
+
if (ifd.data instanceof Float32Array || ifd.data instanceof Float64Array) {
|
|
31621
|
+
throw new Error('Float TIFF data is not supported.');
|
|
31622
|
+
}
|
|
31008
31623
|
if (ifd.type === 3) {
|
|
31009
|
-
|
|
31010
|
-
const
|
|
31624
|
+
const hasAlpha = ifd.samplesPerPixel === 2;
|
|
31625
|
+
const pixelLength = hasAlpha ? 4 : 3;
|
|
31626
|
+
const data = new Uint16Array(pixelLength * ifd.width * ifd.height);
|
|
31011
31627
|
const palette = ifd.palette;
|
|
31012
31628
|
let ptr = 0;
|
|
31013
|
-
|
|
31014
|
-
|
|
31015
|
-
|
|
31016
|
-
|
|
31017
|
-
|
|
31629
|
+
if (hasAlpha) {
|
|
31630
|
+
for (let index = 0; index < ifd.data.length; index += ifd.samplesPerPixel) {
|
|
31631
|
+
const color = palette[ifd.data[index]];
|
|
31632
|
+
data[ptr++] = color[0];
|
|
31633
|
+
data[ptr++] = color[1];
|
|
31634
|
+
data[ptr++] = color[2];
|
|
31635
|
+
// To ensure that the value is 16 bits.
|
|
31636
|
+
data[ptr++] = Math.round(ifd.data[index + 1] / 2 ** ifd.bitsPerSample * 65535);
|
|
31637
|
+
}
|
|
31638
|
+
} else {
|
|
31639
|
+
for (let index = 0; index < ifd.data.length; index += ifd.samplesPerPixel) {
|
|
31640
|
+
const color = palette[ifd.data[index]];
|
|
31641
|
+
data[ptr++] = color[0];
|
|
31642
|
+
data[ptr++] = color[1];
|
|
31643
|
+
data[ptr++] = color[2];
|
|
31644
|
+
}
|
|
31018
31645
|
}
|
|
31019
31646
|
return new Image(ifd.width, ifd.height, {
|
|
31020
31647
|
data,
|
|
31021
|
-
|
|
31022
|
-
colorModel: ifd.alpha ? 'RGBA' : 'RGB',
|
|
31023
|
-
// TODO: handle other bit depths
|
|
31648
|
+
colorModel: hasAlpha ? 'RGBA' : 'RGB',
|
|
31024
31649
|
bitDepth: 16,
|
|
31025
31650
|
meta: getMetadata(ifd)
|
|
31026
31651
|
});
|
|
31652
|
+
} else if (ifd.type === 1 || ifd.type === 0) {
|
|
31653
|
+
if (ifd.bitsPerSample !== 1) {
|
|
31654
|
+
return new Image(ifd.width, ifd.height, {
|
|
31655
|
+
data: ifd.data,
|
|
31656
|
+
bitDepth: ifd.bitsPerSample,
|
|
31657
|
+
colorModel: ifd.alpha ? 'GREYA' : 'GREY',
|
|
31658
|
+
meta: getMetadata(ifd)
|
|
31659
|
+
});
|
|
31660
|
+
} else {
|
|
31661
|
+
return new Image(ifd.width, ifd.height, {
|
|
31662
|
+
data: ifd.data.map(pixel => pixel * 255),
|
|
31663
|
+
bitDepth: 8,
|
|
31664
|
+
colorModel: 'GREY',
|
|
31665
|
+
meta: getMetadata(ifd)
|
|
31666
|
+
});
|
|
31667
|
+
}
|
|
31027
31668
|
} else {
|
|
31028
31669
|
return new Image(ifd.width, ifd.height, {
|
|
31029
|
-
// TODO: handle float data
|
|
31030
|
-
// @ts-expect-error float data not handled yet
|
|
31031
31670
|
data: ifd.data,
|
|
31032
31671
|
bitDepth: ifd.bitsPerSample,
|
|
31033
|
-
colorModel: ifd.
|
|
31672
|
+
colorModel: ifd.alpha ? 'RGBA' : 'RGB',
|
|
31034
31673
|
meta: getMetadata(ifd)
|
|
31035
31674
|
});
|
|
31036
31675
|
}
|
|
@@ -31045,13 +31684,15 @@ ${indent}columns: ${matrix.columns}
|
|
|
31045
31684
|
function decode(data) {
|
|
31046
31685
|
const typedArray = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
31047
31686
|
const type = imageType$1(typedArray);
|
|
31048
|
-
return
|
|
31687
|
+
return M$2(type).with({
|
|
31049
31688
|
mime: 'image/png'
|
|
31050
31689
|
}, () => decodePng(typedArray)).with({
|
|
31051
31690
|
mime: 'image/jpeg'
|
|
31052
31691
|
}, () => decodeJpeg(typedArray)).with({
|
|
31053
31692
|
mime: 'image/tiff'
|
|
31054
|
-
}, () => decodeTiff(typedArray)).
|
|
31693
|
+
}, () => decodeTiff(typedArray)).with({
|
|
31694
|
+
mime: 'image/bmp'
|
|
31695
|
+
}, () => decodeBmp(typedArray)).otherwise(() => {
|
|
31055
31696
|
throw new RangeError(`invalid data format: ${type?.mime}`);
|
|
31056
31697
|
});
|
|
31057
31698
|
}
|
|
@@ -31069,7 +31710,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
31069
31710
|
return decode(data);
|
|
31070
31711
|
}
|
|
31071
31712
|
/**
|
|
31072
|
-
* Synchronous version of
|
|
31713
|
+
* Synchronous version of {@link read}.
|
|
31073
31714
|
* This method is only implemented for Node.js.
|
|
31074
31715
|
* @param path - The path to the image.
|
|
31075
31716
|
* @returns Image instance.
|
|
@@ -31223,7 +31864,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
31223
31864
|
} = options;
|
|
31224
31865
|
const colorMap = new Uint32Array(nbNegative + nbPositive + 1);
|
|
31225
31866
|
const hueRange = 360;
|
|
31226
|
-
const step =
|
|
31867
|
+
const step = M$2(roiKind).with('bw', () => hueRange / (nbNegative + nbPositive)).with('black', () => hueRange / nbNegative).with('white', () => hueRange / nbPositive).exhaustive();
|
|
31227
31868
|
// negative values
|
|
31228
31869
|
let hue = 0;
|
|
31229
31870
|
if (roiKind === 'bw' || roiKind === 'black') {
|
|
@@ -31293,7 +31934,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
31293
31934
|
roiKind: 'bw',
|
|
31294
31935
|
...options
|
|
31295
31936
|
};
|
|
31296
|
-
return
|
|
31937
|
+
return M$2(mode).with('binary', () => getBinaryMap(options)).with('saturation', () => getSaturationMap(options)).with('rainbow', () => getRainbowMap(options)).exhaustive();
|
|
31297
31938
|
}
|
|
31298
31939
|
|
|
31299
31940
|
const RoisColorMode = {
|
|
@@ -32108,7 +32749,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
32108
32749
|
if (roiMapManager.blackRois.length === 0 && roiMapManager.whiteRois.length === 0) {
|
|
32109
32750
|
computeRois(roiMapManager);
|
|
32110
32751
|
}
|
|
32111
|
-
const rois =
|
|
32752
|
+
const rois = M$2(kind).with('black', () => roiMapManager.blackRois).with('white', () => roiMapManager.whiteRois).with('bw', () => [...roiMapManager.whiteRois, ...roiMapManager.blackRois]).exhaustive();
|
|
32112
32753
|
return rois.filter(roi => roi.surface >= minSurface && roi.surface <= maxSurface);
|
|
32113
32754
|
}
|
|
32114
32755
|
|
|
@@ -32282,7 +32923,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
32282
32923
|
|
|
32283
32924
|
var priorityQueue = {exports: {}};
|
|
32284
32925
|
|
|
32285
|
-
(function (module, exports) {
|
|
32926
|
+
(function (module, exports$1) {
|
|
32286
32927
|
(function (f) {
|
|
32287
32928
|
{
|
|
32288
32929
|
module.exports = f();
|
|
@@ -32312,7 +32953,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
32312
32953
|
for (var o = 0; o < r.length; o++) s(r[o]);
|
|
32313
32954
|
return s;
|
|
32314
32955
|
}({
|
|
32315
|
-
1: [function (_dereq_, module, exports) {
|
|
32956
|
+
1: [function (_dereq_, module, exports$1) {
|
|
32316
32957
|
var AbstractPriorityQueue,
|
|
32317
32958
|
ArrayStrategy,
|
|
32318
32959
|
BHeapStrategy,
|
|
@@ -32357,7 +32998,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
32357
32998
|
"./PriorityQueue/BHeapStrategy": 4,
|
|
32358
32999
|
"./PriorityQueue/BinaryHeapStrategy": 5
|
|
32359
33000
|
}],
|
|
32360
|
-
2: [function (_dereq_, module, exports) {
|
|
33001
|
+
2: [function (_dereq_, module, exports$1) {
|
|
32361
33002
|
module.exports = function () {
|
|
32362
33003
|
function AbstractPriorityQueue(options) {
|
|
32363
33004
|
var ref;
|
|
@@ -32395,7 +33036,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
32395
33036
|
return AbstractPriorityQueue;
|
|
32396
33037
|
}();
|
|
32397
33038
|
}, {}],
|
|
32398
|
-
3: [function (_dereq_, module, exports) {
|
|
33039
|
+
3: [function (_dereq_, module, exports$1) {
|
|
32399
33040
|
var binarySearchForIndexReversed;
|
|
32400
33041
|
binarySearchForIndexReversed = function (array, value, comparator) {
|
|
32401
33042
|
var high, low, mid;
|
|
@@ -32438,7 +33079,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
32438
33079
|
return ArrayStrategy;
|
|
32439
33080
|
}();
|
|
32440
33081
|
}, {}],
|
|
32441
|
-
4: [function (_dereq_, module, exports) {
|
|
33082
|
+
4: [function (_dereq_, module, exports$1) {
|
|
32442
33083
|
module.exports = function () {
|
|
32443
33084
|
function BHeapStrategy(options) {
|
|
32444
33085
|
var arr, j, k, len, ref, ref1, shift, value;
|
|
@@ -32576,7 +33217,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
32576
33217
|
return BHeapStrategy;
|
|
32577
33218
|
}();
|
|
32578
33219
|
}, {}],
|
|
32579
|
-
5: [function (_dereq_, module, exports) {
|
|
33220
|
+
5: [function (_dereq_, module, exports$1) {
|
|
32580
33221
|
module.exports = function () {
|
|
32581
33222
|
function BinaryHeapStrategy(options) {
|
|
32582
33223
|
var ref;
|
|
@@ -32898,6 +33539,61 @@ ${indent}columns: ${matrix.columns}
|
|
|
32898
33539
|
return result;
|
|
32899
33540
|
}
|
|
32900
33541
|
|
|
33542
|
+
/**
|
|
33543
|
+
* Decodes APNG image into a Stack
|
|
33544
|
+
* @param data - APNG data.
|
|
33545
|
+
* @returns stack of frames.
|
|
33546
|
+
*/
|
|
33547
|
+
function decodeStackFromApng(data) {
|
|
33548
|
+
const decodedApng = decodeApng(data);
|
|
33549
|
+
const images = [];
|
|
33550
|
+
let colorModel;
|
|
33551
|
+
switch (decodedApng.channels) {
|
|
33552
|
+
case 1:
|
|
33553
|
+
if (decodedApng.palette) {
|
|
33554
|
+
colorModel = decodedApng.palette[0].length === 3 ? 'RGB' : 'RGBA';
|
|
33555
|
+
} else {
|
|
33556
|
+
colorModel = 'GREY';
|
|
33557
|
+
}
|
|
33558
|
+
break;
|
|
33559
|
+
case 2:
|
|
33560
|
+
colorModel = 'GREYA';
|
|
33561
|
+
break;
|
|
33562
|
+
case 3:
|
|
33563
|
+
colorModel = 'RGB';
|
|
33564
|
+
break;
|
|
33565
|
+
default:
|
|
33566
|
+
colorModel = 'RGBA';
|
|
33567
|
+
break;
|
|
33568
|
+
}
|
|
33569
|
+
if (decodedApng.palette) {
|
|
33570
|
+
for (const image of decodedApng.frames) {
|
|
33571
|
+
images.push(new Image(decodedApng.width, decodedApng.height, {
|
|
33572
|
+
data: convertIndexedData(image.data, decodedApng.palette),
|
|
33573
|
+
colorModel
|
|
33574
|
+
}));
|
|
33575
|
+
}
|
|
33576
|
+
} else {
|
|
33577
|
+
for (const image of decodedApng.frames) {
|
|
33578
|
+
images.push(new Image(decodedApng.width, decodedApng.height, {
|
|
33579
|
+
data: image.data,
|
|
33580
|
+
colorModel
|
|
33581
|
+
}));
|
|
33582
|
+
}
|
|
33583
|
+
}
|
|
33584
|
+
const stack = new Stack(images);
|
|
33585
|
+
return stack;
|
|
33586
|
+
}
|
|
33587
|
+
function convertIndexedData(data, palette) {
|
|
33588
|
+
const result = new Uint8Array(data.length * palette[0].length);
|
|
33589
|
+
for (let i = 0; i < data.length; i++) {
|
|
33590
|
+
for (let channel = 0; channel < palette[0].length; channel++) {
|
|
33591
|
+
result[i * palette[0].length + channel] = palette[data[i]][channel];
|
|
33592
|
+
}
|
|
33593
|
+
}
|
|
33594
|
+
return result;
|
|
33595
|
+
}
|
|
33596
|
+
|
|
32901
33597
|
/**
|
|
32902
33598
|
* Decode a TIFF and create a stack of images.
|
|
32903
33599
|
* @param buffer - The data to decode.
|
|
@@ -32921,9 +33617,11 @@ ${indent}columns: ${matrix.columns}
|
|
|
32921
33617
|
function decodeStack(data) {
|
|
32922
33618
|
const typedArray = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
32923
33619
|
const type = imageType$1(typedArray);
|
|
32924
|
-
return
|
|
33620
|
+
return M$2(type).with({
|
|
32925
33621
|
mime: 'image/tiff'
|
|
32926
|
-
}, () => decodeStackFromTiff(typedArray)).
|
|
33622
|
+
}, () => decodeStackFromTiff(typedArray)).with({
|
|
33623
|
+
mime: 'image/png'
|
|
33624
|
+
}, () => decodeStackFromApng(typedArray)).otherwise(() => {
|
|
32927
33625
|
throw new RangeError(`invalid data format: ${type?.mime}`);
|
|
32928
33626
|
});
|
|
32929
33627
|
}
|
|
@@ -33181,6 +33879,105 @@ ${indent}columns: ${matrix.columns}
|
|
|
33181
33879
|
BINARY: ['Mask']
|
|
33182
33880
|
};
|
|
33183
33881
|
|
|
33882
|
+
/**
|
|
33883
|
+
* Draws text on an image.
|
|
33884
|
+
* @param image - Image to write text on.
|
|
33885
|
+
* @param text - Text to write on the image.
|
|
33886
|
+
* @param options - Out Options
|
|
33887
|
+
* @returns Image with drawn text.
|
|
33888
|
+
*/
|
|
33889
|
+
function drawText(image, text, options) {
|
|
33890
|
+
if (Array.isArray(text) && text.length === 0) {
|
|
33891
|
+
throw new Error('At least one text element must be provided');
|
|
33892
|
+
}
|
|
33893
|
+
const newImage = getOutputImage(image, options, {
|
|
33894
|
+
clone: true
|
|
33895
|
+
});
|
|
33896
|
+
const defaultFont = options?.font ?? '12px Helvetica';
|
|
33897
|
+
const defaultColor = options?.fontColor ?? [255, 255, 255, 255];
|
|
33898
|
+
const ctx = getCanvasContext(image.width, image.height);
|
|
33899
|
+
if (!Array.isArray(text)) {
|
|
33900
|
+
drawTextElement(image, ctx, text, defaultFont, defaultColor);
|
|
33901
|
+
} else {
|
|
33902
|
+
for (const label of text) {
|
|
33903
|
+
drawTextElement(image, ctx, label, defaultFont, defaultColor);
|
|
33904
|
+
}
|
|
33905
|
+
}
|
|
33906
|
+
layerCanvas(newImage.getRawImage().data, ctx.getImageData(0, 0, image.width, image.height).data, image.channels, image.bitDepth);
|
|
33907
|
+
return newImage;
|
|
33908
|
+
}
|
|
33909
|
+
function drawTextElement(image, ctx, text, defaultFont, defaultColor) {
|
|
33910
|
+
ctx.font = text.font ?? defaultFont;
|
|
33911
|
+
const fontColor = text.fontColor ?? defaultColor;
|
|
33912
|
+
validateValues(fontColor, image);
|
|
33913
|
+
const alpha = fontColor[3] ? fontColor[3] / 255 : 1;
|
|
33914
|
+
const normalizedColor = [fontColor[0] ?? 0, fontColor[1] ?? 0, fontColor[2] ?? 0, alpha];
|
|
33915
|
+
ctx.fillStyle = `rgba(${normalizedColor.join(',')})`;
|
|
33916
|
+
ctx.fillText(String(text.content), text.position.column, text.position.row);
|
|
33917
|
+
}
|
|
33918
|
+
/**
|
|
33919
|
+
* Draws labels on the image data from canvas.
|
|
33920
|
+
* @param imageData - Image data to draw text on.
|
|
33921
|
+
* @param canvasData - Canvas data to draw on the image.
|
|
33922
|
+
* @param numberOfChannels - Number of channels of the initial image.
|
|
33923
|
+
* @param bitDepth - Bit depth of the initial image.
|
|
33924
|
+
*/
|
|
33925
|
+
function layerCanvas(imageData, canvasData, numberOfChannels, bitDepth) {
|
|
33926
|
+
const config = CHANNEL_CONFIGS[numberOfChannels] || CHANNEL_CONFIGS[1];
|
|
33927
|
+
const pixelCount = canvasData.length >>> 2;
|
|
33928
|
+
const bitShift = bitDepth - 8;
|
|
33929
|
+
let imageIndex = 0;
|
|
33930
|
+
let canvasIndex = 0;
|
|
33931
|
+
for (let pixel = 0; pixel < pixelCount; pixel++) {
|
|
33932
|
+
const canvasAlpha = canvasData[canvasIndex + 3] / 255;
|
|
33933
|
+
// Skip transparent canvas pixels completely
|
|
33934
|
+
if (canvasAlpha === 0) {
|
|
33935
|
+
imageIndex += numberOfChannels;
|
|
33936
|
+
canvasIndex += 4;
|
|
33937
|
+
continue;
|
|
33938
|
+
}
|
|
33939
|
+
const invAlpha = 1 - canvasAlpha;
|
|
33940
|
+
for (const channel of config.channelOffsets) {
|
|
33941
|
+
const targetIndex = imageIndex + channel;
|
|
33942
|
+
imageData[targetIndex] = Math.round(canvasData[canvasIndex + channel] * canvasAlpha + imageData[targetIndex] * invAlpha) << bitShift;
|
|
33943
|
+
}
|
|
33944
|
+
if (config.hasAlpha) {
|
|
33945
|
+
const alphaIndex = imageIndex + config.alphaOffset;
|
|
33946
|
+
const imageAlpha = (imageData[alphaIndex] >>> bitShift) / 255;
|
|
33947
|
+
const newAlpha = canvasAlpha + imageAlpha * (1 - canvasAlpha);
|
|
33948
|
+
imageData[alphaIndex] = Math.round(newAlpha * 255) << bitShift;
|
|
33949
|
+
}
|
|
33950
|
+
imageIndex += numberOfChannels;
|
|
33951
|
+
canvasIndex += 4;
|
|
33952
|
+
}
|
|
33953
|
+
}
|
|
33954
|
+
const CHANNEL_CONFIGS = {
|
|
33955
|
+
// GREY
|
|
33956
|
+
1: {
|
|
33957
|
+
channelOffsets: [0],
|
|
33958
|
+
hasAlpha: false,
|
|
33959
|
+
alphaOffset: undefined
|
|
33960
|
+
},
|
|
33961
|
+
// GREYA
|
|
33962
|
+
2: {
|
|
33963
|
+
channelOffsets: [0],
|
|
33964
|
+
hasAlpha: true,
|
|
33965
|
+
alphaOffset: 1
|
|
33966
|
+
},
|
|
33967
|
+
3: {
|
|
33968
|
+
// RGB
|
|
33969
|
+
channelOffsets: [0, 1, 2],
|
|
33970
|
+
hasAlpha: false,
|
|
33971
|
+
alphaOffset: undefined
|
|
33972
|
+
},
|
|
33973
|
+
4: {
|
|
33974
|
+
// RGBA
|
|
33975
|
+
channelOffsets: [0, 1, 2],
|
|
33976
|
+
hasAlpha: true,
|
|
33977
|
+
alphaOffset: 3
|
|
33978
|
+
}
|
|
33979
|
+
};
|
|
33980
|
+
|
|
33184
33981
|
exports.BorderType = BorderType;
|
|
33185
33982
|
exports.DerivativeFilter = DerivativeFilter;
|
|
33186
33983
|
exports.GreyAlgorithm = GreyAlgorithm;
|
|
@@ -33251,6 +34048,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
33251
34048
|
exports.drawPolylineOnImage = drawPolylineOnImage;
|
|
33252
34049
|
exports.drawPolylineOnMask = drawPolylineOnMask;
|
|
33253
34050
|
exports.drawRectangle = drawRectangle;
|
|
34051
|
+
exports.drawText = drawText;
|
|
33254
34052
|
exports.encode = encode;
|
|
33255
34053
|
exports.encodeDataURL = encodeDataURL;
|
|
33256
34054
|
exports.encodeJpeg = encodeJpeg;
|