image-js 1.0.0 → 1.1.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 +866 -198
- 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 +866 -198
- 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 +2 -3
- package/lib/Mask.d.ts +1 -1
- package/lib/Mask.js +1 -1
- 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/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/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/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/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/package.json +27 -27
- package/src/Mask.ts +1 -1
- 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/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/maskAnalysis/utils/getMbrAngle.ts +2 -1
- package/src/maskAnalysis/utils/monotoneChainConvexHull.ts +2 -1
- package/src/save/encodeBmp.ts +22 -15
- package/src/stack/load/decodeApng.ts +71 -0
- package/src/stack/load/decodeStack.ts +2 -0
- package/src/utils/geometry/points.ts +3 -1
- package/src/utils/geometry/removeClosePoints.ts +2 -1
package/dist/image-js.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* image-js v1.
|
|
2
|
+
* image-js v1.1.0
|
|
3
3
|
* Image processing and manipulation in JavaScript
|
|
4
4
|
* https://github.com/image-js/image-js#readme
|
|
5
5
|
*
|
|
@@ -5700,11 +5700,13 @@ ${indent}columns: ${matrix.columns}
|
|
|
5700
5700
|
* @returns Sorted points.
|
|
5701
5701
|
*/
|
|
5702
5702
|
function sortByColumnRow(points) {
|
|
5703
|
-
|
|
5703
|
+
const sortedPoints = points.slice();
|
|
5704
|
+
sortedPoints.sort((point1, point2) => {
|
|
5704
5705
|
if (point1.column < point2.column) return -1;
|
|
5705
5706
|
if (point1.column > point2.column) return 1;
|
|
5706
5707
|
return point1.row - point2.row;
|
|
5707
5708
|
});
|
|
5709
|
+
return sortedPoints;
|
|
5708
5710
|
}
|
|
5709
5711
|
|
|
5710
5712
|
/**
|
|
@@ -5796,35 +5798,35 @@ ${indent}columns: ${matrix.columns}
|
|
|
5796
5798
|
if (!Array.isArray(s)) return false;
|
|
5797
5799
|
let t = [],
|
|
5798
5800
|
r = [],
|
|
5799
|
-
|
|
5801
|
+
u = [];
|
|
5800
5802
|
for (const o of n.keys()) {
|
|
5801
5803
|
const s = n[o];
|
|
5802
|
-
i$2(s) && s[e$2] ?
|
|
5804
|
+
i$2(s) && s[e$2] ? u.push(s) : u.length ? r.push(s) : t.push(s);
|
|
5803
5805
|
}
|
|
5804
|
-
if (
|
|
5805
|
-
if (
|
|
5806
|
+
if (u.length) {
|
|
5807
|
+
if (u.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
5806
5808
|
if (s.length < t.length + r.length) return false;
|
|
5807
5809
|
const e = s.slice(0, t.length),
|
|
5808
5810
|
n = 0 === r.length ? [] : s.slice(-r.length),
|
|
5809
5811
|
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 ===
|
|
5812
|
+
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
5813
|
}
|
|
5812
5814
|
return n.length === s.length && n.every((t, e) => o$2(t, s[e], c));
|
|
5813
5815
|
}
|
|
5814
5816
|
return Reflect.ownKeys(n).every(e => {
|
|
5815
5817
|
const r = n[e];
|
|
5816
|
-
return (e in s || i$2(
|
|
5817
|
-
var
|
|
5818
|
+
return (e in s || i$2(u = r) && "optional" === u[t$2]().matcherType) && o$2(r, s[e], c);
|
|
5819
|
+
var u;
|
|
5818
5820
|
});
|
|
5819
5821
|
}
|
|
5820
5822
|
return Object.is(s, n);
|
|
5821
5823
|
},
|
|
5822
5824
|
s$1 = e => {
|
|
5823
|
-
var n, o,
|
|
5824
|
-
return r$2(e) ? i$2(e) ? null != (n = null == (o = (
|
|
5825
|
+
var n, o, u;
|
|
5826
|
+
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
5827
|
},
|
|
5826
5828
|
c$1 = (t, e) => t.reduce((t, n) => t.concat(e(n)), []);
|
|
5827
|
-
function
|
|
5829
|
+
function u$2(...t) {
|
|
5828
5830
|
if (1 === t.length) {
|
|
5829
5831
|
const [e] = t;
|
|
5830
5832
|
return t => o$2(e, t, () => {});
|
|
@@ -5835,15 +5837,15 @@ ${indent}columns: ${matrix.columns}
|
|
|
5835
5837
|
}
|
|
5836
5838
|
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
|
|
5837
5839
|
}
|
|
5838
|
-
function
|
|
5840
|
+
function a$2(t) {
|
|
5839
5841
|
return Object.assign(t, {
|
|
5840
|
-
optional: () =>
|
|
5841
|
-
and: e =>
|
|
5842
|
-
or: e =>
|
|
5843
|
-
select: e => void 0 === e ?
|
|
5842
|
+
optional: () => h$2(t),
|
|
5843
|
+
and: e => d$1(t, e),
|
|
5844
|
+
or: e => y$1(t, e),
|
|
5845
|
+
select: e => void 0 === e ? v$1(t) : v$1(e, t)
|
|
5844
5846
|
});
|
|
5845
5847
|
}
|
|
5846
|
-
function
|
|
5848
|
+
function l$2(t) {
|
|
5847
5849
|
return Object.assign((t => Object.assign(t, {
|
|
5848
5850
|
[Symbol.iterator]() {
|
|
5849
5851
|
let n = 0;
|
|
@@ -5864,12 +5866,12 @@ ${indent}columns: ${matrix.columns}
|
|
|
5864
5866
|
};
|
|
5865
5867
|
}
|
|
5866
5868
|
}))(t), {
|
|
5867
|
-
optional: () =>
|
|
5868
|
-
select: e =>
|
|
5869
|
+
optional: () => l$2(h$2(t)),
|
|
5870
|
+
select: e => l$2(void 0 === e ? v$1(t) : v$1(e, t))
|
|
5869
5871
|
});
|
|
5870
5872
|
}
|
|
5871
|
-
function
|
|
5872
|
-
return
|
|
5873
|
+
function h$2(e) {
|
|
5874
|
+
return a$2({
|
|
5873
5875
|
[t$2]: () => ({
|
|
5874
5876
|
match: t => {
|
|
5875
5877
|
let n = {};
|
|
@@ -5896,9 +5898,14 @@ ${indent}columns: ${matrix.columns}
|
|
|
5896
5898
|
g$1 = (t, e) => {
|
|
5897
5899
|
for (const [n, r] of t.entries()) if (!e(r, n)) return false;
|
|
5898
5900
|
return true;
|
|
5901
|
+
},
|
|
5902
|
+
m$1 = (t, e) => {
|
|
5903
|
+
const n = Reflect.ownKeys(t);
|
|
5904
|
+
for (const r of n) if (!e(r, t[r])) return false;
|
|
5905
|
+
return true;
|
|
5899
5906
|
};
|
|
5900
|
-
function
|
|
5901
|
-
return
|
|
5907
|
+
function d$1(...e) {
|
|
5908
|
+
return a$2({
|
|
5902
5909
|
[t$2]: () => ({
|
|
5903
5910
|
match: t => {
|
|
5904
5911
|
let n = {};
|
|
@@ -5915,8 +5922,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
5915
5922
|
})
|
|
5916
5923
|
});
|
|
5917
5924
|
}
|
|
5918
|
-
function
|
|
5919
|
-
return
|
|
5925
|
+
function y$1(...e) {
|
|
5926
|
+
return a$2({
|
|
5920
5927
|
[t$2]: () => ({
|
|
5921
5928
|
match: t => {
|
|
5922
5929
|
let n = {};
|
|
@@ -5942,10 +5949,10 @@ ${indent}columns: ${matrix.columns}
|
|
|
5942
5949
|
})
|
|
5943
5950
|
};
|
|
5944
5951
|
}
|
|
5945
|
-
function
|
|
5952
|
+
function v$1(...e) {
|
|
5946
5953
|
const r = "string" == typeof e[0] ? e[0] : void 0,
|
|
5947
5954
|
i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
|
|
5948
|
-
return
|
|
5955
|
+
return a$2({
|
|
5949
5956
|
[t$2]: () => ({
|
|
5950
5957
|
match: t => {
|
|
5951
5958
|
let e = {
|
|
@@ -5962,81 +5969,83 @@ ${indent}columns: ${matrix.columns}
|
|
|
5962
5969
|
})
|
|
5963
5970
|
});
|
|
5964
5971
|
}
|
|
5965
|
-
function
|
|
5972
|
+
function b$2(t) {
|
|
5973
|
+
return true;
|
|
5974
|
+
}
|
|
5975
|
+
function w$2(t) {
|
|
5966
5976
|
return "number" == typeof t;
|
|
5967
5977
|
}
|
|
5968
|
-
function
|
|
5978
|
+
function S$1(t) {
|
|
5969
5979
|
return "string" == typeof t;
|
|
5970
5980
|
}
|
|
5971
|
-
function
|
|
5981
|
+
function j$1(t) {
|
|
5972
5982
|
return "bigint" == typeof t;
|
|
5973
5983
|
}
|
|
5974
|
-
const
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
j$1 = t => Object.assign(u$2(t), {
|
|
5984
|
+
const K = a$2(p$2(b$2)),
|
|
5985
|
+
O = a$2(p$2(b$2)),
|
|
5986
|
+
E = K,
|
|
5987
|
+
x$1 = t => Object.assign(a$2(t), {
|
|
5979
5988
|
startsWith: e => {
|
|
5980
|
-
return
|
|
5989
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.startsWith(n)))));
|
|
5981
5990
|
var n;
|
|
5982
5991
|
},
|
|
5983
5992
|
endsWith: e => {
|
|
5984
|
-
return
|
|
5993
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.endsWith(n)))));
|
|
5985
5994
|
var n;
|
|
5986
5995
|
},
|
|
5987
|
-
minLength: e =>
|
|
5988
|
-
length: e =>
|
|
5989
|
-
maxLength: e =>
|
|
5996
|
+
minLength: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length >= t))(e))),
|
|
5997
|
+
length: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length === t))(e))),
|
|
5998
|
+
maxLength: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length <= t))(e))),
|
|
5990
5999
|
includes: e => {
|
|
5991
|
-
return
|
|
6000
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.includes(n)))));
|
|
5992
6001
|
var n;
|
|
5993
6002
|
},
|
|
5994
6003
|
regex: e => {
|
|
5995
|
-
return
|
|
6004
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && Boolean(t.match(n))))));
|
|
5996
6005
|
var n;
|
|
5997
6006
|
}
|
|
5998
6007
|
}),
|
|
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: () =>
|
|
6008
|
+
A = x$1(p$2(S$1)),
|
|
6009
|
+
N$1 = t => Object.assign(a$2(t), {
|
|
6010
|
+
between: (e, n) => N$1(d$1(t, ((t, e) => p$2(n => w$2(n) && t <= n && e >= n))(e, n))),
|
|
6011
|
+
lt: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e < t))(e))),
|
|
6012
|
+
gt: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e > t))(e))),
|
|
6013
|
+
lte: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e <= t))(e))),
|
|
6014
|
+
gte: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e >= t))(e))),
|
|
6015
|
+
int: () => N$1(d$1(t, p$2(t => w$2(t) && Number.isInteger(t)))),
|
|
6016
|
+
finite: () => N$1(d$1(t, p$2(t => w$2(t) && Number.isFinite(t)))),
|
|
6017
|
+
positive: () => N$1(d$1(t, p$2(t => w$2(t) && t > 0))),
|
|
6018
|
+
negative: () => N$1(d$1(t, p$2(t => w$2(t) && t < 0)))
|
|
6010
6019
|
}),
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
between: (e, n) =>
|
|
6014
|
-
lt: e =>
|
|
6015
|
-
gt: e =>
|
|
6016
|
-
lte: e =>
|
|
6017
|
-
gte: e =>
|
|
6018
|
-
positive: () =>
|
|
6019
|
-
negative: () =>
|
|
6020
|
+
P = N$1(p$2(w$2)),
|
|
6021
|
+
k$1 = t => Object.assign(a$2(t), {
|
|
6022
|
+
between: (e, n) => k$1(d$1(t, ((t, e) => p$2(n => j$1(n) && t <= n && e >= n))(e, n))),
|
|
6023
|
+
lt: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e < t))(e))),
|
|
6024
|
+
gt: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e > t))(e))),
|
|
6025
|
+
lte: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e <= t))(e))),
|
|
6026
|
+
gte: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e >= t))(e))),
|
|
6027
|
+
positive: () => k$1(d$1(t, p$2(t => j$1(t) && t > 0))),
|
|
6028
|
+
negative: () => k$1(d$1(t, p$2(t => j$1(t) && t < 0)))
|
|
6020
6029
|
}),
|
|
6021
|
-
|
|
6022
|
-
|
|
6030
|
+
T = k$1(p$2(j$1)),
|
|
6031
|
+
B = a$2(p$2(function (t) {
|
|
6023
6032
|
return "boolean" == typeof t;
|
|
6024
6033
|
})),
|
|
6025
|
-
|
|
6034
|
+
_ = a$2(p$2(function (t) {
|
|
6026
6035
|
return "symbol" == typeof t;
|
|
6027
6036
|
})),
|
|
6028
|
-
|
|
6037
|
+
W = a$2(p$2(function (t) {
|
|
6029
6038
|
return null == t;
|
|
6030
6039
|
})),
|
|
6031
|
-
|
|
6040
|
+
$$1 = a$2(p$2(function (t) {
|
|
6032
6041
|
return null != t;
|
|
6033
6042
|
}));
|
|
6034
|
-
var
|
|
6043
|
+
var z = {
|
|
6035
6044
|
__proto__: null,
|
|
6036
6045
|
matcher: t$2,
|
|
6037
|
-
optional:
|
|
6046
|
+
optional: h$2,
|
|
6038
6047
|
array: function (...e) {
|
|
6039
|
-
return
|
|
6048
|
+
return l$2({
|
|
6040
6049
|
[t$2]: () => ({
|
|
6041
6050
|
match: t => {
|
|
6042
6051
|
if (!Array.isArray(t)) return {
|
|
@@ -6066,7 +6075,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6066
6075
|
});
|
|
6067
6076
|
},
|
|
6068
6077
|
set: function (...e) {
|
|
6069
|
-
return
|
|
6078
|
+
return a$2({
|
|
6070
6079
|
[t$2]: () => ({
|
|
6071
6080
|
match: t => {
|
|
6072
6081
|
if (!(t instanceof Set)) return {
|
|
@@ -6094,7 +6103,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6094
6103
|
});
|
|
6095
6104
|
},
|
|
6096
6105
|
map: function (...e) {
|
|
6097
|
-
return
|
|
6106
|
+
return a$2({
|
|
6098
6107
|
[t$2]: () => ({
|
|
6099
6108
|
match: t => {
|
|
6100
6109
|
if (!(t instanceof Map)) return {
|
|
@@ -6127,10 +6136,39 @@ ${indent}columns: ${matrix.columns}
|
|
|
6127
6136
|
})
|
|
6128
6137
|
});
|
|
6129
6138
|
},
|
|
6130
|
-
|
|
6131
|
-
|
|
6139
|
+
record: function (...e) {
|
|
6140
|
+
return a$2({
|
|
6141
|
+
[t$2]: () => ({
|
|
6142
|
+
match: t => {
|
|
6143
|
+
if (null === t || "object" != typeof t || Array.isArray(t)) return {
|
|
6144
|
+
matched: false
|
|
6145
|
+
};
|
|
6146
|
+
var n;
|
|
6147
|
+
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()}`);
|
|
6148
|
+
let r = {};
|
|
6149
|
+
const i = (t, e) => {
|
|
6150
|
+
r[t] = (r[t] || []).concat([e]);
|
|
6151
|
+
},
|
|
6152
|
+
[s, c] = 1 === e.length ? [A, e[0]] : e;
|
|
6153
|
+
return {
|
|
6154
|
+
matched: m$1(t, (t, e) => {
|
|
6155
|
+
const n = "string" != typeof t || Number.isNaN(Number(t)) ? null : Number(t),
|
|
6156
|
+
r = null !== n && o$2(s, n, i),
|
|
6157
|
+
u = o$2(s, t, i),
|
|
6158
|
+
a = o$2(c, e, i);
|
|
6159
|
+
return (u || r) && a;
|
|
6160
|
+
}),
|
|
6161
|
+
selections: r
|
|
6162
|
+
};
|
|
6163
|
+
},
|
|
6164
|
+
getSelectionKeys: () => 0 === e.length ? [] : [...s$1(e[0]), ...s$1(e[1])]
|
|
6165
|
+
})
|
|
6166
|
+
});
|
|
6167
|
+
},
|
|
6168
|
+
intersection: d$1,
|
|
6169
|
+
union: y$1,
|
|
6132
6170
|
not: function (e) {
|
|
6133
|
-
return
|
|
6171
|
+
return a$2({
|
|
6134
6172
|
[t$2]: () => ({
|
|
6135
6173
|
match: t => ({
|
|
6136
6174
|
matched: !o$2(e, t, () => {})
|
|
@@ -6141,26 +6179,27 @@ ${indent}columns: ${matrix.columns}
|
|
|
6141
6179
|
});
|
|
6142
6180
|
},
|
|
6143
6181
|
when: p$2,
|
|
6144
|
-
select:
|
|
6145
|
-
any:
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6182
|
+
select: v$1,
|
|
6183
|
+
any: K,
|
|
6184
|
+
unknown: O,
|
|
6185
|
+
_: E,
|
|
6186
|
+
string: A,
|
|
6187
|
+
number: P,
|
|
6188
|
+
bigint: T,
|
|
6189
|
+
boolean: B,
|
|
6190
|
+
symbol: _,
|
|
6191
|
+
nullish: W,
|
|
6192
|
+
nonNullable: $$1,
|
|
6154
6193
|
instanceOf: function (t) {
|
|
6155
|
-
return
|
|
6194
|
+
return a$2(p$2(function (t) {
|
|
6156
6195
|
return e => e instanceof t;
|
|
6157
6196
|
}(t)));
|
|
6158
6197
|
},
|
|
6159
6198
|
shape: function (t) {
|
|
6160
|
-
return
|
|
6199
|
+
return a$2(p$2(u$2(t)));
|
|
6161
6200
|
}
|
|
6162
6201
|
};
|
|
6163
|
-
class
|
|
6202
|
+
class I extends Error {
|
|
6164
6203
|
constructor(t) {
|
|
6165
6204
|
let e;
|
|
6166
6205
|
try {
|
|
@@ -6171,14 +6210,14 @@ ${indent}columns: ${matrix.columns}
|
|
|
6171
6210
|
super(`Pattern matching error: no pattern matches value ${e}`), this.input = void 0, this.input = t;
|
|
6172
6211
|
}
|
|
6173
6212
|
}
|
|
6174
|
-
const
|
|
6213
|
+
const L = {
|
|
6175
6214
|
matched: false,
|
|
6176
6215
|
value: void 0
|
|
6177
6216
|
};
|
|
6178
|
-
function
|
|
6179
|
-
return new
|
|
6217
|
+
function M$2(t) {
|
|
6218
|
+
return new R(t, L);
|
|
6180
6219
|
}
|
|
6181
|
-
class
|
|
6220
|
+
class R {
|
|
6182
6221
|
constructor(t, e) {
|
|
6183
6222
|
this.input = void 0, this.state = void 0, this.input = t, this.state = e;
|
|
6184
6223
|
}
|
|
@@ -6190,27 +6229,27 @@ ${indent}columns: ${matrix.columns}
|
|
|
6190
6229
|
3 === t.length && "function" == typeof t[1] ? i = t[1] : t.length > 2 && r.push(...t.slice(1, t.length - 1));
|
|
6191
6230
|
let s = false,
|
|
6192
6231
|
c = {};
|
|
6193
|
-
const
|
|
6232
|
+
const u = (t, e) => {
|
|
6194
6233
|
s = true, c[t] = e;
|
|
6195
6234
|
},
|
|
6196
|
-
|
|
6235
|
+
a = !r.some(t => o$2(t, this.input, u)) || i && !Boolean(i(this.input)) ? L : {
|
|
6197
6236
|
matched: true,
|
|
6198
6237
|
value: e(s ? n$2 in c ? c[n$2] : c : this.input, this.input)
|
|
6199
6238
|
};
|
|
6200
|
-
return new
|
|
6239
|
+
return new R(this.input, a);
|
|
6201
6240
|
}
|
|
6202
6241
|
when(t, e) {
|
|
6203
6242
|
if (this.state.matched) return this;
|
|
6204
6243
|
const n = Boolean(t(this.input));
|
|
6205
|
-
return new
|
|
6244
|
+
return new R(this.input, n ? {
|
|
6206
6245
|
matched: true,
|
|
6207
6246
|
value: e(this.input, this.input)
|
|
6208
|
-
} :
|
|
6247
|
+
} : L);
|
|
6209
6248
|
}
|
|
6210
6249
|
otherwise(t) {
|
|
6211
6250
|
return this.state.matched ? this.state.value : t(this.input);
|
|
6212
6251
|
}
|
|
6213
|
-
exhaustive(t =
|
|
6252
|
+
exhaustive(t = F) {
|
|
6214
6253
|
return this.state.matched ? this.state.value : t(this.input);
|
|
6215
6254
|
}
|
|
6216
6255
|
run() {
|
|
@@ -6223,34 +6262,377 @@ ${indent}columns: ${matrix.columns}
|
|
|
6223
6262
|
return this;
|
|
6224
6263
|
}
|
|
6225
6264
|
}
|
|
6226
|
-
function
|
|
6227
|
-
throw new
|
|
6265
|
+
function F(t) {
|
|
6266
|
+
throw new I(t);
|
|
6228
6267
|
}
|
|
6229
6268
|
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6269
|
+
var index_umd$1 = {exports: {}};
|
|
6270
|
+
|
|
6271
|
+
var index_umd = index_umd$1.exports;
|
|
6272
|
+
(function (module, exports) {
|
|
6273
|
+
(function (N, J) {
|
|
6274
|
+
J(exports) ;
|
|
6275
|
+
})(index_umd, function (N) {
|
|
6276
|
+
|
|
6277
|
+
function J(f, a, o, t, e) {
|
|
6278
|
+
const h = Math.abs(o - f),
|
|
6279
|
+
r = f < o ? 1 : -1,
|
|
6280
|
+
l = -Math.abs(t - a),
|
|
6281
|
+
M = a < t ? 1 : -1;
|
|
6282
|
+
let i = h + l,
|
|
6283
|
+
n;
|
|
6284
|
+
for (;;) {
|
|
6285
|
+
if (e(f, a), n = 2 * i, n >= l) {
|
|
6286
|
+
if (f === o) break;
|
|
6287
|
+
i += l, f += r;
|
|
6288
|
+
}
|
|
6289
|
+
if (n <= h) {
|
|
6290
|
+
if (a === t) break;
|
|
6291
|
+
i += h, a += M;
|
|
6292
|
+
}
|
|
6293
|
+
}
|
|
6294
|
+
}
|
|
6295
|
+
function U(f, a, o, t, e) {
|
|
6296
|
+
const h = f < o ? 1 : -1,
|
|
6297
|
+
r = a < t ? 1 : -1;
|
|
6298
|
+
let l,
|
|
6299
|
+
M = Math.abs(o - f),
|
|
6300
|
+
i = Math.abs(t - a),
|
|
6301
|
+
n = M * M + i * i,
|
|
6302
|
+
c = n === 0 ? 1 : 1 / Math.sqrt(n);
|
|
6303
|
+
for (M *= c, i *= c, n = M - i;;) {
|
|
6304
|
+
if (e(f, a, Math.abs(n - (M + i)) >> 16), c = n, l = f, 2 * c >= -M) {
|
|
6305
|
+
if (f === o) break;
|
|
6306
|
+
c + i < 16711680 && e(f, a + r, c + i >> 16), n -= i, f += h;
|
|
6307
|
+
}
|
|
6308
|
+
if (2 * c <= i) {
|
|
6309
|
+
if (a === t) break;
|
|
6310
|
+
M - c < 16711680 && e(l + h, a, M - c >> 16), n += M, a += r;
|
|
6311
|
+
}
|
|
6312
|
+
}
|
|
6313
|
+
}
|
|
6314
|
+
function w(f, a, o, t, e, h) {
|
|
6315
|
+
let r = Math.abs(o - f),
|
|
6316
|
+
l = f < o ? 1 : -1,
|
|
6317
|
+
M = Math.abs(t - a),
|
|
6318
|
+
i = a < t ? 1 : -1,
|
|
6319
|
+
n = r - M,
|
|
6320
|
+
c,
|
|
6321
|
+
q,
|
|
6322
|
+
d,
|
|
6323
|
+
b = r + M == 0 ? 1 : Math.sqrt(r * r + M * M);
|
|
6324
|
+
for (e = (e + 1) / 2;;) {
|
|
6325
|
+
if (h(f, a, Math.max(0, 255 * (Math.abs(n - r + M) / b - e + 1))), c = n, q = f, 2 * c >= -r) {
|
|
6326
|
+
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)));
|
|
6327
|
+
if (f == o) break;
|
|
6328
|
+
c = n, n -= M, f += l;
|
|
6329
|
+
}
|
|
6330
|
+
if (2 * c <= M) {
|
|
6331
|
+
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)));
|
|
6332
|
+
if (a == t) break;
|
|
6333
|
+
n += r, a += i;
|
|
6334
|
+
}
|
|
6335
|
+
}
|
|
6336
|
+
}
|
|
6337
|
+
function I(f, a = "assert error") {
|
|
6338
|
+
if (!f) throw new Error(a);
|
|
6339
|
+
}
|
|
6340
|
+
function P(f, a, o, t, e, h, r, l) {
|
|
6341
|
+
var M = f - 2 * o + e,
|
|
6342
|
+
i = a - 2 * t + h,
|
|
6343
|
+
n = f - o,
|
|
6344
|
+
c = a - t,
|
|
6345
|
+
q,
|
|
6346
|
+
d,
|
|
6347
|
+
b;
|
|
6348
|
+
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);
|
|
6349
|
+
}
|
|
6350
|
+
function H(f, a, o, t, e, h, r, l) {
|
|
6351
|
+
var M = e - o,
|
|
6352
|
+
i = h - t,
|
|
6353
|
+
n = f - e,
|
|
6354
|
+
c = a - h,
|
|
6355
|
+
q = f - o,
|
|
6356
|
+
d = a - t,
|
|
6357
|
+
b = q * i + d * M,
|
|
6358
|
+
s = q * i - d * M,
|
|
6359
|
+
u;
|
|
6360
|
+
if (I(q * M <= 0 && d * i <= 0, "sign of gradient must not change"), s != 0 && r > 0) {
|
|
6361
|
+
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)) {
|
|
6362
|
+
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);
|
|
6363
|
+
return;
|
|
6364
|
+
}
|
|
6365
|
+
u = n + c - b;
|
|
6366
|
+
do {
|
|
6367
|
+
if (l(f, a), f == e && a == h) return;
|
|
6368
|
+
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);
|
|
6369
|
+
} while (c <= b && n >= b);
|
|
6370
|
+
}
|
|
6371
|
+
J(f, a, e, h, l);
|
|
6372
|
+
}
|
|
6373
|
+
function V(f, a, o, t, e, h, r, l) {
|
|
6374
|
+
var M = e - o,
|
|
6375
|
+
i = h - t,
|
|
6376
|
+
n = f - e,
|
|
6377
|
+
c = a - h,
|
|
6378
|
+
q = f - o,
|
|
6379
|
+
d = a - t,
|
|
6380
|
+
b = q * i + d * M,
|
|
6381
|
+
s = q * i - d * M,
|
|
6382
|
+
u,
|
|
6383
|
+
z,
|
|
6384
|
+
j;
|
|
6385
|
+
if (I(q * M <= 0 && d * i <= 0), s != 0 && r > 0) {
|
|
6386
|
+
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);
|
|
6387
|
+
u = n + c - b;
|
|
6388
|
+
do {
|
|
6389
|
+
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) {
|
|
6390
|
+
if (a == h) return;
|
|
6391
|
+
n - u < z && l(f + M, a, 255 * Math.abs(n - u) / z);
|
|
6392
|
+
}
|
|
6393
|
+
if (2 * u + n > 0) {
|
|
6394
|
+
if (f == e) return;
|
|
6395
|
+
u - c < z && l(f, a + i, 255 * Math.abs(u - c) / z), f += M, n += b, u += c += d;
|
|
6396
|
+
}
|
|
6397
|
+
j && (a += i, c += b, u += n += q);
|
|
6398
|
+
} while (c < n);
|
|
6399
|
+
}
|
|
6400
|
+
U(f, a, e, h, l);
|
|
6401
|
+
}
|
|
6402
|
+
function y(f, a, o, t, e) {
|
|
6403
|
+
let h = -o,
|
|
6404
|
+
r = 0,
|
|
6405
|
+
l = t * t,
|
|
6406
|
+
M = h * (2 * l + h) + l;
|
|
6407
|
+
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);
|
|
6408
|
+
for (; r++ < t;) e(f, a + r), e(f, a - r);
|
|
6409
|
+
}
|
|
6410
|
+
function x(f, a, o, t, e, h) {
|
|
6411
|
+
let r = o * o,
|
|
6412
|
+
l = t * t;
|
|
6413
|
+
const M = Math.sin(e);
|
|
6414
|
+
let i = (r - l) * M;
|
|
6415
|
+
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);
|
|
6416
|
+
}
|
|
6417
|
+
function Y(f, a, o, t, e, h) {
|
|
6418
|
+
let r = o - f,
|
|
6419
|
+
l = t - a,
|
|
6420
|
+
M = r * l;
|
|
6421
|
+
if (e === 0) return Z(f, a, o, t, h);
|
|
6422
|
+
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);
|
|
6423
|
+
}
|
|
6424
|
+
function Z(f, a, o, t, e) {
|
|
6425
|
+
let h = Math.abs(o - f),
|
|
6426
|
+
r = Math.abs(t - a),
|
|
6427
|
+
l = r & 1,
|
|
6428
|
+
M = 4 * (1 - h) * r * r,
|
|
6429
|
+
i = 4 * (l + 1) * h * h,
|
|
6430
|
+
n = M + i + l * h * h,
|
|
6431
|
+
c;
|
|
6432
|
+
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;
|
|
6433
|
+
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);
|
|
6434
|
+
for (; a - t <= r;) e(f - 1, a), e(o + 1, a++), e(f - 1, t), e(o + 1, t--);
|
|
6435
|
+
}
|
|
6436
|
+
function aa(f, a, o, t) {
|
|
6437
|
+
var e = -o,
|
|
6438
|
+
h = 0,
|
|
6439
|
+
r = 2 - 2 * o;
|
|
6440
|
+
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);
|
|
6441
|
+
}
|
|
6442
|
+
function fa(f, a, o, t) {
|
|
6443
|
+
var e = -o,
|
|
6444
|
+
h = 0,
|
|
6445
|
+
r,
|
|
6446
|
+
l,
|
|
6447
|
+
M,
|
|
6448
|
+
i = 2 - 2 * o;
|
|
6449
|
+
o = 1 - i;
|
|
6450
|
+
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);
|
|
6451
|
+
}
|
|
6452
|
+
function ta(f, a, o, t, e, h, r) {
|
|
6453
|
+
var l = f - o,
|
|
6454
|
+
M = a - t,
|
|
6455
|
+
i = f - 2 * o + e,
|
|
6456
|
+
n;
|
|
6457
|
+
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);
|
|
6458
|
+
}
|
|
6459
|
+
function L(f, a, o, t, e, h, r) {
|
|
6460
|
+
var l = e - o,
|
|
6461
|
+
M = h - t,
|
|
6462
|
+
i = f - o,
|
|
6463
|
+
n = a - t,
|
|
6464
|
+
c,
|
|
6465
|
+
q,
|
|
6466
|
+
d,
|
|
6467
|
+
b,
|
|
6468
|
+
s = i * M - n * l;
|
|
6469
|
+
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) {
|
|
6470
|
+
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;
|
|
6471
|
+
do {
|
|
6472
|
+
if (r(f, a), f == e && a == h) return;
|
|
6473
|
+
t = +(2 * b < q), 2 * b > d && (f += l, q -= c, b += d += n), t && (a += M, d -= c, b += q += i);
|
|
6474
|
+
} while (d < 0 && q > 0);
|
|
6475
|
+
}
|
|
6476
|
+
J(f, a, e, h, r);
|
|
6477
|
+
}
|
|
6478
|
+
function ia(f, a, o, t, e, h, r) {
|
|
6479
|
+
var l = f - o,
|
|
6480
|
+
M = a - t,
|
|
6481
|
+
i = f - 2 * o + e,
|
|
6482
|
+
n;
|
|
6483
|
+
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);
|
|
6484
|
+
}
|
|
6485
|
+
function Q(f, a, o, t, e, h, r) {
|
|
6486
|
+
var l = e - o,
|
|
6487
|
+
M = h - t,
|
|
6488
|
+
i = f - o,
|
|
6489
|
+
n = a - t,
|
|
6490
|
+
c,
|
|
6491
|
+
q,
|
|
6492
|
+
d,
|
|
6493
|
+
b,
|
|
6494
|
+
s,
|
|
6495
|
+
u = i * M - n * l;
|
|
6496
|
+
if (l * l + M * M > i * i + n * n && (e = f, f = l + o, h = a, a = M + t, u = -u), u != 0) {
|
|
6497
|
+
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;
|
|
6498
|
+
do {
|
|
6499
|
+
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;
|
|
6500
|
+
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);
|
|
6501
|
+
} while (d < q);
|
|
6502
|
+
}
|
|
6503
|
+
U(f, a, e, h, r);
|
|
6504
|
+
}
|
|
6505
|
+
function _(f, a, o, t, e, h, r, l, M) {
|
|
6506
|
+
var i,
|
|
6507
|
+
n,
|
|
6508
|
+
c,
|
|
6509
|
+
q = 1;
|
|
6510
|
+
let d = f < r ? 1 : -1,
|
|
6511
|
+
b = a < l ? 1 : -1,
|
|
6512
|
+
s = -Math.abs(f + o - e - r),
|
|
6513
|
+
u = s - 4 * d * (o - e),
|
|
6514
|
+
z = d * (f - o - e + r),
|
|
6515
|
+
j = -Math.abs(a + t - h - l),
|
|
6516
|
+
B = j - 4 * b * (t - h),
|
|
6517
|
+
R = b * (a - t - h + l),
|
|
6518
|
+
p,
|
|
6519
|
+
S,
|
|
6520
|
+
W,
|
|
6521
|
+
T,
|
|
6522
|
+
G,
|
|
6523
|
+
E,
|
|
6524
|
+
O,
|
|
6525
|
+
v,
|
|
6526
|
+
g,
|
|
6527
|
+
k,
|
|
6528
|
+
F,
|
|
6529
|
+
D = .01;
|
|
6530
|
+
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);
|
|
6531
|
+
o = (o - f) * (o - f) + (t - a) * (t - a) + 1, e = (e - r) * (e - r) + (h - l) * (h - l) + 1;
|
|
6532
|
+
do {
|
|
6533
|
+
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;
|
|
6534
|
+
a: for (F = E, n = c = i; f != r && a != l;) {
|
|
6535
|
+
M(f, a);
|
|
6536
|
+
do {
|
|
6537
|
+
if (v > F || g < F) break a;
|
|
6538
|
+
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);
|
|
6539
|
+
} while (n > 0 && c > 0);
|
|
6540
|
+
2 * n <= i && (f += d, n += i), 2 * c <= i && (a += b, c += i), F == E && v < 0 && g > 0 && (F = D);
|
|
6541
|
+
}
|
|
6542
|
+
G = f, f = r, r = G, d = -d, z = -z, O = a, a = l, l = O, b = -b, R = -R, o = e;
|
|
6543
|
+
} while (q--);
|
|
6544
|
+
J(f, a, r, l, M);
|
|
6545
|
+
}
|
|
6546
|
+
function $(f, a, o, t, e, h, r, l, M) {
|
|
6547
|
+
let i,
|
|
6548
|
+
n,
|
|
6549
|
+
c,
|
|
6550
|
+
q = 1,
|
|
6551
|
+
d = f < r ? 1 : -1,
|
|
6552
|
+
b = a < l ? 1 : -1,
|
|
6553
|
+
s = -Math.abs(f + o - e - r),
|
|
6554
|
+
u = s - 4 * d * (o - e),
|
|
6555
|
+
z = d * (f - o - e + r),
|
|
6556
|
+
j = -Math.abs(a + t - h - l),
|
|
6557
|
+
B = j - 4 * b * (t - h),
|
|
6558
|
+
R = b * (a - t - h + l),
|
|
6559
|
+
p,
|
|
6560
|
+
S,
|
|
6561
|
+
W,
|
|
6562
|
+
T,
|
|
6563
|
+
G,
|
|
6564
|
+
E,
|
|
6565
|
+
O,
|
|
6566
|
+
v,
|
|
6567
|
+
g,
|
|
6568
|
+
k,
|
|
6569
|
+
F,
|
|
6570
|
+
D,
|
|
6571
|
+
C,
|
|
6572
|
+
A;
|
|
6573
|
+
const K = .01;
|
|
6574
|
+
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);
|
|
6575
|
+
o = (o - f) * (o - f) + (t - a) * (t - a) + 1, e = (e - r) * (e - r) + (h - l) * (h - l) + 1;
|
|
6576
|
+
do {
|
|
6577
|
+
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;
|
|
6578
|
+
let X = false;
|
|
6579
|
+
a: for (n = c = i; f !== r && a !== l;) {
|
|
6580
|
+
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;
|
|
6581
|
+
do {
|
|
6582
|
+
if (A >= -K && (v + G > E || g + O < E)) {
|
|
6583
|
+
X = true;
|
|
6584
|
+
break a;
|
|
6585
|
+
}
|
|
6586
|
+
if (t = 2 * k + v, 2 * k + g > 0) n--, k += v += G, g += E += S, O += W, G += p;else if (t > 0) {
|
|
6587
|
+
X = true;
|
|
6588
|
+
break a;
|
|
6589
|
+
}
|
|
6590
|
+
t <= 0 && (c--, k += g += O, v += E += W, G += S, O += T);
|
|
6591
|
+
} while (n > 0 && c > 0);
|
|
6592
|
+
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);
|
|
6593
|
+
}
|
|
6594
|
+
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);
|
|
6595
|
+
break;
|
|
6596
|
+
} while (q--);
|
|
6597
|
+
U(Math.floor(f), Math.floor(a), Math.floor(r), Math.floor(l), M);
|
|
6598
|
+
}
|
|
6599
|
+
function m(f, a, o, t, e, h, r, l, M, i) {
|
|
6600
|
+
let n = 0,
|
|
6601
|
+
c = 0,
|
|
6602
|
+
q = f + o - e - r,
|
|
6603
|
+
d = q - 4 * (o - e),
|
|
6604
|
+
b = f - o - e + r,
|
|
6605
|
+
s = b + 4 * (o + e),
|
|
6606
|
+
u = a + t - h - l,
|
|
6607
|
+
z = u - 4 * (t - h),
|
|
6608
|
+
j = a - t - h + l,
|
|
6609
|
+
B = j + 4 * (t + h);
|
|
6610
|
+
var R = f,
|
|
6611
|
+
p,
|
|
6612
|
+
S,
|
|
6613
|
+
W,
|
|
6614
|
+
T = a,
|
|
6615
|
+
G,
|
|
6616
|
+
E,
|
|
6617
|
+
O;
|
|
6618
|
+
let v = b * b - d * q,
|
|
6619
|
+
g;
|
|
6620
|
+
const k = [0, 0, 0, 0, 0];
|
|
6621
|
+
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);
|
|
6622
|
+
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;
|
|
6623
|
+
}
|
|
6624
|
+
function ra(f, a, o, t, e, h, r, l, M) {
|
|
6625
|
+
m(f, a, o, t, e, h, r, l, _, M);
|
|
6626
|
+
}
|
|
6627
|
+
function oa(f, a, o, t, e, h, r, l, M) {
|
|
6628
|
+
m(f, a, o, t, e, h, r, l, $, M);
|
|
6629
|
+
}
|
|
6630
|
+
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, {
|
|
6631
|
+
value: "Module"
|
|
6632
|
+
});
|
|
6633
|
+
});
|
|
6634
|
+
})(index_umd$1, index_umd$1.exports);
|
|
6635
|
+
var index_umdExports = index_umd$1.exports;
|
|
6254
6636
|
|
|
6255
6637
|
/**
|
|
6256
6638
|
* Remove duplicate points from array.
|
|
@@ -6277,7 +6659,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6277
6659
|
*/
|
|
6278
6660
|
function getCirclePoints(radius) {
|
|
6279
6661
|
const circlePoints = [];
|
|
6280
|
-
|
|
6662
|
+
index_umdExports.circle(radius, radius, radius, (column, row) => {
|
|
6281
6663
|
circlePoints.push({
|
|
6282
6664
|
row: row - radius,
|
|
6283
6665
|
column: column - radius
|
|
@@ -6313,7 +6695,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6313
6695
|
if (radius === 1) {
|
|
6314
6696
|
circlePoints.push(center);
|
|
6315
6697
|
}
|
|
6316
|
-
|
|
6698
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
6317
6699
|
circlePoints.push({
|
|
6318
6700
|
row,
|
|
6319
6701
|
column
|
|
@@ -6347,7 +6729,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6347
6729
|
*/
|
|
6348
6730
|
function getLinePoints(from, to) {
|
|
6349
6731
|
const linePoints = [];
|
|
6350
|
-
|
|
6732
|
+
index_umdExports.line(from.column, from.row, to.column, to.row, (column, row) => {
|
|
6351
6733
|
linePoints.push({
|
|
6352
6734
|
row,
|
|
6353
6735
|
column
|
|
@@ -6362,7 +6744,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6362
6744
|
* @returns The coordinates of the compass points.
|
|
6363
6745
|
*/
|
|
6364
6746
|
function getCompassPoints(radius) {
|
|
6365
|
-
|
|
6747
|
+
index_umdExports.circle(radius, radius, radius, (column, row) => {
|
|
6366
6748
|
});
|
|
6367
6749
|
return [{
|
|
6368
6750
|
row: 0,
|
|
@@ -6673,7 +7055,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
6673
7055
|
channels: [1],
|
|
6674
7056
|
alpha: false
|
|
6675
7057
|
});
|
|
6676
|
-
const getScore =
|
|
7058
|
+
const getScore = M$2(scoreAlgorithm).with('HARRIS', () => {
|
|
6677
7059
|
return (image, corner) => getHarrisScore(image, corner, harrisScoreOptions);
|
|
6678
7060
|
}).with('FAST', () => {
|
|
6679
7061
|
return (image, corner) => getFastScore(image, corner, threshold, circlePoints);
|
|
@@ -8055,11 +8437,13 @@ ${indent}columns: ${matrix.columns}
|
|
|
8055
8437
|
* @returns Sorted copy of the array of matches.
|
|
8056
8438
|
*/
|
|
8057
8439
|
function sortBySourceDest(matches) {
|
|
8058
|
-
|
|
8440
|
+
const sorted = matches.slice();
|
|
8441
|
+
sorted.sort((match1, match2) => {
|
|
8059
8442
|
if (match1.sourceIndex < match2.sourceIndex) return -1;
|
|
8060
8443
|
if (match1.sourceIndex > match2.sourceIndex) return 1;
|
|
8061
8444
|
return match1.destinationIndex - match2.destinationIndex;
|
|
8062
8445
|
});
|
|
8446
|
+
return sorted;
|
|
8063
8447
|
}
|
|
8064
8448
|
/**
|
|
8065
8449
|
* Sort array of matches by destination index and then source index.
|
|
@@ -8067,11 +8451,13 @@ ${indent}columns: ${matrix.columns}
|
|
|
8067
8451
|
* @returns Sorted copy of the array of matches.
|
|
8068
8452
|
*/
|
|
8069
8453
|
function sortByDestSource(matches) {
|
|
8070
|
-
|
|
8454
|
+
const sorted = matches.slice();
|
|
8455
|
+
sorted.sort((match1, match2) => {
|
|
8071
8456
|
if (match1.destinationIndex < match2.destinationIndex) return -1;
|
|
8072
8457
|
if (match1.destinationIndex > match2.destinationIndex) return 1;
|
|
8073
8458
|
return match1.sourceIndex - match2.sourceIndex;
|
|
8074
8459
|
});
|
|
8460
|
+
return sorted;
|
|
8075
8461
|
}
|
|
8076
8462
|
|
|
8077
8463
|
/**
|
|
@@ -8274,7 +8660,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8274
8660
|
* @returns Default color.
|
|
8275
8661
|
*/
|
|
8276
8662
|
function getDefaultColor(image) {
|
|
8277
|
-
return
|
|
8663
|
+
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
8664
|
}
|
|
8279
8665
|
|
|
8280
8666
|
/**
|
|
@@ -8362,7 +8748,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8362
8748
|
return newImage;
|
|
8363
8749
|
}
|
|
8364
8750
|
if (!fillColor) {
|
|
8365
|
-
|
|
8751
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
8366
8752
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8367
8753
|
});
|
|
8368
8754
|
} else {
|
|
@@ -8372,7 +8758,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8372
8758
|
//Starting points for the top and bottom row of the circle.
|
|
8373
8759
|
let prevRow = center.row + radius;
|
|
8374
8760
|
let index = 0;
|
|
8375
|
-
|
|
8761
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
8376
8762
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8377
8763
|
// Filling the first line of the circle.
|
|
8378
8764
|
if (index === 0) {
|
|
@@ -8445,7 +8831,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8445
8831
|
checkProcessable$1(newImage, {
|
|
8446
8832
|
bitDepth: [8, 16]
|
|
8447
8833
|
});
|
|
8448
|
-
|
|
8834
|
+
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
8835
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8450
8836
|
});
|
|
8451
8837
|
return newImage;
|
|
@@ -8469,7 +8855,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
8469
8855
|
const newMask = maskToOutputMask(mask, options, {
|
|
8470
8856
|
clone: true
|
|
8471
8857
|
});
|
|
8472
|
-
|
|
8858
|
+
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
8859
|
newMask.setVisiblePixel(column, row, [1]);
|
|
8474
8860
|
});
|
|
8475
8861
|
return newMask;
|
|
@@ -9575,7 +9961,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
9575
9961
|
* @returns The border interpolation function.
|
|
9576
9962
|
*/
|
|
9577
9963
|
function getBorderInterpolation(type, value) {
|
|
9578
|
-
return
|
|
9964
|
+
return M$2(type).with('constant', () => getInterpolateConstant(value)).with('replicate', () => interpolateReplicate).with('reflect', () => interpolateReflect).with('reflect101', () => interpolateReflect101).with('wrap', () => interpolateWrap).exhaustive();
|
|
9579
9965
|
}
|
|
9580
9966
|
function checkRange(point, length) {
|
|
9581
9967
|
if (point <= 0 - length || point >= length + length - 1) {
|
|
@@ -9975,7 +10361,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
9975
10361
|
const {
|
|
9976
10362
|
filter = 'sobel'
|
|
9977
10363
|
} = options;
|
|
9978
|
-
const kernels =
|
|
10364
|
+
const kernels = M$2(filter).with('sobel', () => ({
|
|
9979
10365
|
kernelX: SOBEL_X,
|
|
9980
10366
|
kernelY: SOBEL_Y
|
|
9981
10367
|
})).with('scharr', () => ({
|
|
@@ -11559,7 +11945,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
11559
11945
|
slots
|
|
11560
11946
|
});
|
|
11561
11947
|
const scale = slots ? 2 ** image.bitDepth / slots : 1;
|
|
11562
|
-
return
|
|
11948
|
+
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
11949
|
}
|
|
11564
11950
|
// See: https://docs.opencv.org/4.0.1/d7/d1b/group__imgproc__misc.html#gaa9e58d2860d4afa658ef70a9b1115576
|
|
11565
11951
|
/**
|
|
@@ -12070,7 +12456,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
12070
12456
|
* @returns The interpolation function.
|
|
12071
12457
|
*/
|
|
12072
12458
|
function getInterpolationFunction(interpolationType) {
|
|
12073
|
-
return
|
|
12459
|
+
return M$2(interpolationType).with('nearest', () => interpolateNearest).with('bilinear', () => interpolateBilinear).with('bicubic', () => interpolateBicubic).exhaustive();
|
|
12074
12460
|
}
|
|
12075
12461
|
/**
|
|
12076
12462
|
* Interpolate using nearest neighbor.
|
|
@@ -13573,7 +13959,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
13573
13959
|
sorted = false
|
|
13574
13960
|
} = options;
|
|
13575
13961
|
if (!sorted) {
|
|
13576
|
-
points = points.slice()
|
|
13962
|
+
points = points.slice();
|
|
13963
|
+
points.sort(byXThenY);
|
|
13577
13964
|
}
|
|
13578
13965
|
const n = points.length;
|
|
13579
13966
|
const result = new Array(n * 2);
|
|
@@ -13836,7 +14223,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
13836
14223
|
* @returns The angle in degrees.
|
|
13837
14224
|
*/
|
|
13838
14225
|
function getMbrAngle(mbr) {
|
|
13839
|
-
const sorted = mbr.slice()
|
|
14226
|
+
const sorted = mbr.slice();
|
|
14227
|
+
sorted.sort(leftFirst);
|
|
13840
14228
|
const left = sorted.slice(0, 2);
|
|
13841
14229
|
const right = sorted.slice(2, 4);
|
|
13842
14230
|
left.sort(topFirst);
|
|
@@ -15021,7 +15409,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
15021
15409
|
}
|
|
15022
15410
|
/**
|
|
15023
15411
|
* Get the number of pixels that do not have the value 0.
|
|
15024
|
-
* @returns
|
|
15412
|
+
* @returns The number of non-zero pixels.
|
|
15025
15413
|
*/
|
|
15026
15414
|
getNbNonZeroPixels() {
|
|
15027
15415
|
let count = 0;
|
|
@@ -16794,7 +17182,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
16794
17182
|
* @returns Coordinates of the point in the format [column, row].
|
|
16795
17183
|
*/
|
|
16796
17184
|
getCoordinates(coordinates, round = false) {
|
|
16797
|
-
return
|
|
17185
|
+
return M$2(coordinates).with('center', () => {
|
|
16798
17186
|
const centerX = (this.width - 1) / 2;
|
|
16799
17187
|
const centerY = (this.height - 1) / 2;
|
|
16800
17188
|
if (round) {
|
|
@@ -17213,7 +17601,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
17213
17601
|
*/
|
|
17214
17602
|
function createPixelArray(size, channels, alpha, bitDepth, maxValue) {
|
|
17215
17603
|
const length = channels * size;
|
|
17216
|
-
const arr =
|
|
17604
|
+
const arr = M$2(bitDepth).with(8, () => new Uint8Array(length)).with(16, () => new Uint16Array(length)).otherwise(() => {
|
|
17217
17605
|
throw new RangeError(`invalid bitDepth: ${bitDepth}`);
|
|
17218
17606
|
});
|
|
17219
17607
|
// Alpha channel is 100% by default.
|
|
@@ -17542,9 +17930,11 @@ ${indent}columns: ${matrix.columns}
|
|
|
17542
17930
|
* @returns Sorted copy of the array of matches.
|
|
17543
17931
|
*/
|
|
17544
17932
|
function sortByDistance(matches) {
|
|
17545
|
-
|
|
17933
|
+
const sorted = matches.slice();
|
|
17934
|
+
sorted.sort((match1, match2) => {
|
|
17546
17935
|
return match1.distance - match2.distance;
|
|
17547
17936
|
});
|
|
17937
|
+
return sorted;
|
|
17548
17938
|
}
|
|
17549
17939
|
|
|
17550
17940
|
/**
|
|
@@ -17803,7 +18193,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
17803
18193
|
row: 0
|
|
17804
18194
|
}
|
|
17805
18195
|
} = options;
|
|
17806
|
-
const sorted = matches.
|
|
18196
|
+
const sorted = matches.slice();
|
|
18197
|
+
sorted.sort((a, b) => a.destinationIndex - b.destinationIndex);
|
|
17807
18198
|
const result = [];
|
|
17808
18199
|
let sameDestMatches = [];
|
|
17809
18200
|
let currentIndex = sorted[0].destinationIndex;
|
|
@@ -17811,12 +18202,14 @@ ${indent}columns: ${matrix.columns}
|
|
|
17811
18202
|
if (match.destinationIndex === currentIndex) {
|
|
17812
18203
|
sameDestMatches.push(match);
|
|
17813
18204
|
} else {
|
|
17814
|
-
|
|
18205
|
+
sameDestMatches.sort((a, b) => distanceSquared(a) - distanceSquared(b));
|
|
18206
|
+
result.push(...sameDestMatches.slice(0, 1));
|
|
17815
18207
|
currentIndex = match.destinationIndex;
|
|
17816
18208
|
sameDestMatches = [match];
|
|
17817
18209
|
}
|
|
17818
18210
|
}
|
|
17819
|
-
|
|
18211
|
+
sameDestMatches.sort((a, b) => distanceSquared(a) - distanceSquared(b));
|
|
18212
|
+
result.push(...sameDestMatches.slice(0, 1));
|
|
17820
18213
|
return result;
|
|
17821
18214
|
function distanceSquared(match) {
|
|
17822
18215
|
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 +18222,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
17829
18222
|
* @param encoding - Text encoding
|
|
17830
18223
|
* @returns The decoded text
|
|
17831
18224
|
*/
|
|
17832
|
-
function decode$
|
|
18225
|
+
function decode$4(bytes, encoding = 'utf8') {
|
|
17833
18226
|
const decoder = new TextDecoder(encoding);
|
|
17834
18227
|
return decoder.decode(bytes);
|
|
17835
18228
|
}
|
|
@@ -18225,7 +18618,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
18225
18618
|
* @returns The decoded string.
|
|
18226
18619
|
*/
|
|
18227
18620
|
readUtf8(n = 1) {
|
|
18228
|
-
return decode$
|
|
18621
|
+
return decode$4(this.readBytes(n));
|
|
18229
18622
|
}
|
|
18230
18623
|
/**
|
|
18231
18624
|
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer
|
|
@@ -18236,7 +18629,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
18236
18629
|
* @returns The decoded string.
|
|
18237
18630
|
*/
|
|
18238
18631
|
decodeText(n = 1, encoding = 'utf8') {
|
|
18239
|
-
return decode$
|
|
18632
|
+
return decode$4(this.readBytes(n), encoding);
|
|
18240
18633
|
}
|
|
18241
18634
|
/**
|
|
18242
18635
|
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
|
|
@@ -18457,6 +18850,117 @@ ${indent}columns: ${matrix.columns}
|
|
|
18457
18850
|
}
|
|
18458
18851
|
}
|
|
18459
18852
|
|
|
18853
|
+
class BMPDecoder {
|
|
18854
|
+
bufferData;
|
|
18855
|
+
pixelDataOffset;
|
|
18856
|
+
width;
|
|
18857
|
+
height;
|
|
18858
|
+
bitsPerPixel;
|
|
18859
|
+
xPixelsPerMeter;
|
|
18860
|
+
yPixelsPerMeter;
|
|
18861
|
+
compression;
|
|
18862
|
+
colorMasks;
|
|
18863
|
+
constructor(bufferData) {
|
|
18864
|
+
this.bufferData = new IOBuffer(bufferData);
|
|
18865
|
+
const formatCheck = this.bufferData.readBytes(2);
|
|
18866
|
+
if (formatCheck[0] !== 0x42 && formatCheck[1] !== 0x4d) {
|
|
18867
|
+
throw new Error('This is not a BMP image or the encoding is not correct.');
|
|
18868
|
+
}
|
|
18869
|
+
this.pixelDataOffset = this.bufferData.skip(8).readUint32();
|
|
18870
|
+
this.width = this.bufferData.skip(4).readUint32();
|
|
18871
|
+
this.height = this.bufferData.readUint32();
|
|
18872
|
+
this.bitsPerPixel = this.bufferData.seek(28).readUint16();
|
|
18873
|
+
if (this.bitsPerPixel !== 1 && this.bitsPerPixel !== 8 && this.bitsPerPixel !== 24 && this.bitsPerPixel !== 32) {
|
|
18874
|
+
throw new Error(`Invalid number of bits per pixel. Supported number of bits per pixel: 1, 8, 24, 32. Received: ${this.bitsPerPixel}`);
|
|
18875
|
+
}
|
|
18876
|
+
this.compression = this.bufferData.readUint32();
|
|
18877
|
+
if (this.compression !== 0 && this.compression !== 3) {
|
|
18878
|
+
throw new Error(`Only BI_RGB and BI_BITFIELDS compression methods are allowed. `);
|
|
18879
|
+
}
|
|
18880
|
+
this.colorMasks = [this.bufferData.seek(54).readUint32(), this.bufferData.readUint32(), this.bufferData.readUint32()];
|
|
18881
|
+
if (this.bitsPerPixel === 32 && (this.colorMasks[0] !== 0x00ff0000 || this.colorMasks[1] !== 0x0000ff00 || this.colorMasks[2] !== 0x000000ff)) {
|
|
18882
|
+
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)}.`);
|
|
18883
|
+
}
|
|
18884
|
+
this.bufferData.skip(1); // skipping image size.
|
|
18885
|
+
this.xPixelsPerMeter = this.bufferData.seek(38).readInt32();
|
|
18886
|
+
this.yPixelsPerMeter = this.bufferData.readInt32();
|
|
18887
|
+
this.bufferData.skip(1);
|
|
18888
|
+
}
|
|
18889
|
+
decode() {
|
|
18890
|
+
this.bufferData.seek(this.pixelDataOffset);
|
|
18891
|
+
this.bufferData.setBigEndian();
|
|
18892
|
+
const channels = Math.ceil(this.bitsPerPixel / 8);
|
|
18893
|
+
const components = channels % 2 === 0 ? channels - 1 : channels;
|
|
18894
|
+
const data = this.decodePixelData(channels, components);
|
|
18895
|
+
return {
|
|
18896
|
+
width: this.width,
|
|
18897
|
+
height: this.height,
|
|
18898
|
+
bitsPerPixel: this.bitsPerPixel,
|
|
18899
|
+
compression: this.compression,
|
|
18900
|
+
colorMasks: this.colorMasks,
|
|
18901
|
+
channels,
|
|
18902
|
+
components,
|
|
18903
|
+
data,
|
|
18904
|
+
yPixelsPerMeter: this.yPixelsPerMeter,
|
|
18905
|
+
xPixelsPerMeter: this.xPixelsPerMeter
|
|
18906
|
+
};
|
|
18907
|
+
}
|
|
18908
|
+
decodePixelData(channels, components) {
|
|
18909
|
+
const data = new Uint8Array(this.height * this.width * channels);
|
|
18910
|
+
if (this.bitsPerPixel === 1) {
|
|
18911
|
+
this.decodeBitDepth1Pixels(data);
|
|
18912
|
+
} else if (channels === components) {
|
|
18913
|
+
this.decodeStandardPixels(data, channels);
|
|
18914
|
+
} else {
|
|
18915
|
+
this.decodePixelsWithAlpha(data, channels, components);
|
|
18916
|
+
}
|
|
18917
|
+
return data;
|
|
18918
|
+
}
|
|
18919
|
+
decodeBitDepth1Pixels(data) {
|
|
18920
|
+
let currentNumber = 0;
|
|
18921
|
+
for (let row = 0; row < this.height; row++) {
|
|
18922
|
+
for (let col = 0; col < this.width; col++) {
|
|
18923
|
+
const bitIndex = col % 32;
|
|
18924
|
+
if (bitIndex === 0) {
|
|
18925
|
+
currentNumber = this.bufferData.readUint32();
|
|
18926
|
+
}
|
|
18927
|
+
if (currentNumber & 1 << 31 - bitIndex) {
|
|
18928
|
+
data[(this.height - row - 1) * this.width + col] = 1;
|
|
18929
|
+
}
|
|
18930
|
+
}
|
|
18931
|
+
}
|
|
18932
|
+
}
|
|
18933
|
+
decodeStandardPixels(data, channels) {
|
|
18934
|
+
const padding = this.calculatePadding(channels);
|
|
18935
|
+
for (let row = 0; row < this.height; row++) {
|
|
18936
|
+
const rowOffset = (this.height - row - 1) * this.width;
|
|
18937
|
+
for (let col = 0; col < this.width; col++) {
|
|
18938
|
+
for (let channel = channels - 1; channel >= 0; channel--) {
|
|
18939
|
+
data[(rowOffset + col) * channels + channel] = this.bufferData.readByte();
|
|
18940
|
+
}
|
|
18941
|
+
}
|
|
18942
|
+
this.bufferData.skip(padding);
|
|
18943
|
+
}
|
|
18944
|
+
}
|
|
18945
|
+
decodePixelsWithAlpha(data, channels, components) {
|
|
18946
|
+
for (let row = 0; row < this.height; row++) {
|
|
18947
|
+
const rowOffset = (this.height - row - 1) * this.width;
|
|
18948
|
+
for (let col = 0; col < this.width; col++) {
|
|
18949
|
+
const pixelBaseIndex = (rowOffset + col) * channels;
|
|
18950
|
+
// Decode color components
|
|
18951
|
+
for (let component = components - 1; component >= 0; component--) {
|
|
18952
|
+
data[pixelBaseIndex + component] = this.bufferData.readByte();
|
|
18953
|
+
}
|
|
18954
|
+
// Decode alpha channel
|
|
18955
|
+
data[pixelBaseIndex + components] = this.bufferData.readByte();
|
|
18956
|
+
}
|
|
18957
|
+
}
|
|
18958
|
+
}
|
|
18959
|
+
calculatePadding(channels) {
|
|
18960
|
+
return this.width * channels % 4 === 0 ? 0 : 4 - this.width * channels % 4;
|
|
18961
|
+
}
|
|
18962
|
+
}
|
|
18963
|
+
|
|
18460
18964
|
const BITMAPV5HEADER = {
|
|
18461
18965
|
LogicalColorSpace: {
|
|
18462
18966
|
LCS_sRGB: 0x73524742},
|
|
@@ -18618,25 +19122,41 @@ ${indent}columns: ${matrix.columns}
|
|
|
18618
19122
|
const encoder = new BMPEncoder(data);
|
|
18619
19123
|
return encoder.encode();
|
|
18620
19124
|
}
|
|
19125
|
+
/**
|
|
19126
|
+
* Decodes BMP format image into data.
|
|
19127
|
+
* @param data - Buffer with image data.
|
|
19128
|
+
* @returns - Decoded data.
|
|
19129
|
+
*/
|
|
19130
|
+
function decode$3(data) {
|
|
19131
|
+
const decoder = new BMPDecoder(data);
|
|
19132
|
+
return decoder.decode();
|
|
19133
|
+
}
|
|
18621
19134
|
|
|
18622
19135
|
/**
|
|
18623
19136
|
* Creates a BMP buffer from a mask.
|
|
18624
|
-
* @param
|
|
19137
|
+
* @param image - The mask instance.
|
|
18625
19138
|
* @returns The buffer.
|
|
18626
19139
|
*/
|
|
18627
|
-
function encodeBmp(
|
|
18628
|
-
if (
|
|
18629
|
-
|
|
19140
|
+
function encodeBmp(image) {
|
|
19141
|
+
if (image instanceof Image) {
|
|
19142
|
+
return encode$2({
|
|
19143
|
+
width: image.width,
|
|
19144
|
+
height: image.height,
|
|
19145
|
+
components: image.components,
|
|
19146
|
+
bitsPerPixel: image.channels * image.bitDepth,
|
|
19147
|
+
channels: image.channels,
|
|
19148
|
+
data: image.getRawImage().data
|
|
19149
|
+
});
|
|
19150
|
+
} else {
|
|
19151
|
+
return encode$2({
|
|
19152
|
+
width: image.width,
|
|
19153
|
+
height: image.height,
|
|
19154
|
+
components: 1,
|
|
19155
|
+
bitsPerPixel: 1,
|
|
19156
|
+
channels: 1,
|
|
19157
|
+
data: image.getRawImage().data
|
|
19158
|
+
});
|
|
18630
19159
|
}
|
|
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
19160
|
}
|
|
18641
19161
|
|
|
18642
19162
|
var encoder = {exports: {}};
|
|
@@ -28103,6 +28623,10 @@ ${indent}columns: ${matrix.columns}
|
|
|
28103
28623
|
const encoder = new PngEncoder(png, options);
|
|
28104
28624
|
return encoder.encode();
|
|
28105
28625
|
}
|
|
28626
|
+
function decodeApng(data, options) {
|
|
28627
|
+
const decoder = new PngDecoder(data, options);
|
|
28628
|
+
return decoder.decodeApng();
|
|
28629
|
+
}
|
|
28106
28630
|
|
|
28107
28631
|
/**
|
|
28108
28632
|
* Creates a PNG buffer from an image.
|
|
@@ -28140,10 +28664,10 @@ ${indent}columns: ${matrix.columns}
|
|
|
28140
28664
|
* @returns The encoded image.
|
|
28141
28665
|
*/
|
|
28142
28666
|
function encode(image, options = defaultPng) {
|
|
28143
|
-
return
|
|
28667
|
+
return M$2(options).with({
|
|
28144
28668
|
format: 'png'
|
|
28145
28669
|
}, options => encodePng(image, options.encoderOptions)).with({
|
|
28146
|
-
format:
|
|
28670
|
+
format: z.union('jpg', 'jpeg')
|
|
28147
28671
|
}, options => encodeJpeg(image, options.encoderOptions)).with({
|
|
28148
28672
|
format: 'bmp'
|
|
28149
28673
|
}, () => encodeBmp(image)).exhaustive();
|
|
@@ -28661,7 +29185,8 @@ ${indent}columns: ${matrix.columns}
|
|
|
28661
29185
|
}
|
|
28662
29186
|
const channel = options?.channel || 0;
|
|
28663
29187
|
const isMax = kind === 'maximum';
|
|
28664
|
-
const sortedPoints = points.slice()
|
|
29188
|
+
const sortedPoints = points.slice();
|
|
29189
|
+
sortedPoints.sort(getSort(image, channel, isMax));
|
|
28665
29190
|
if (distance > 0) {
|
|
28666
29191
|
for (let i = 0; i < sortedPoints.length; i++) {
|
|
28667
29192
|
for (let j = i + 1; j < sortedPoints.length; j++) {
|
|
@@ -29662,6 +30187,38 @@ ${indent}columns: ${matrix.columns}
|
|
|
29662
30187
|
var imageTypeExports = imageType$2.exports;
|
|
29663
30188
|
var imageType$1 = /*@__PURE__*/getDefaultExportFromCjs(imageTypeExports);
|
|
29664
30189
|
|
|
30190
|
+
/**
|
|
30191
|
+
* Decode a BMP. See the fast-bmp npm module.
|
|
30192
|
+
* @param data - The data to decode.
|
|
30193
|
+
* @returns The decoded image or mask.
|
|
30194
|
+
*/
|
|
30195
|
+
function decodeBmp(data) {
|
|
30196
|
+
const decodedData = decode$3(data);
|
|
30197
|
+
if (decodedData.bitsPerPixel === 1) {
|
|
30198
|
+
const mask = new Mask(decodedData.width, decodedData.height, {
|
|
30199
|
+
data: decodedData.data
|
|
30200
|
+
});
|
|
30201
|
+
return mask.convertColor('GREY');
|
|
30202
|
+
} else {
|
|
30203
|
+
let colorModel;
|
|
30204
|
+
switch (decodedData.channels) {
|
|
30205
|
+
case 1:
|
|
30206
|
+
colorModel = 'GREY';
|
|
30207
|
+
break;
|
|
30208
|
+
case 3:
|
|
30209
|
+
colorModel = 'RGB';
|
|
30210
|
+
break;
|
|
30211
|
+
default:
|
|
30212
|
+
colorModel = 'RGBA';
|
|
30213
|
+
break;
|
|
30214
|
+
}
|
|
30215
|
+
return new Image(decodedData.width, decodedData.height, {
|
|
30216
|
+
colorModel,
|
|
30217
|
+
data: decodedData.data
|
|
30218
|
+
});
|
|
30219
|
+
}
|
|
30220
|
+
}
|
|
30221
|
+
|
|
29665
30222
|
const tagsById$2 = {
|
|
29666
30223
|
0x829a: 'ExposureTime',
|
|
29667
30224
|
0x829d: 'FNumber',
|
|
@@ -30380,7 +30937,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
30380
30937
|
return this.get('SamplesPerPixel') || 1;
|
|
30381
30938
|
}
|
|
30382
30939
|
get rowsPerStrip() {
|
|
30383
|
-
return this.get('RowsPerStrip');
|
|
30940
|
+
return this.get('RowsPerStrip') || 2 ** 32 - 1;
|
|
30384
30941
|
}
|
|
30385
30942
|
get stripByteCounts() {
|
|
30386
30943
|
return alwaysArray(this.get('StripByteCounts'));
|
|
@@ -30934,10 +31491,16 @@ ${indent}columns: ${matrix.columns}
|
|
|
30934
31491
|
function decodePng(buffer) {
|
|
30935
31492
|
const png = decodePng$1(buffer);
|
|
30936
31493
|
let colorModel;
|
|
30937
|
-
const bitDepth = png.depth
|
|
31494
|
+
const bitDepth = png.depth;
|
|
30938
31495
|
if (png.palette) {
|
|
30939
31496
|
return loadPalettePng(png);
|
|
30940
31497
|
}
|
|
31498
|
+
if (bitDepth === 1) {
|
|
31499
|
+
return new Image(png.width, png.height, {
|
|
31500
|
+
data: decodeBinary(png),
|
|
31501
|
+
colorModel: 'GREY'
|
|
31502
|
+
});
|
|
31503
|
+
}
|
|
30941
31504
|
switch (png.channels) {
|
|
30942
31505
|
case 1:
|
|
30943
31506
|
colorModel = 'GREY';
|
|
@@ -30968,7 +31531,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
30968
31531
|
function loadPalettePng(png) {
|
|
30969
31532
|
assert(png.palette);
|
|
30970
31533
|
const pixels = png.width * png.height;
|
|
30971
|
-
const data = new Uint8Array(pixels *
|
|
31534
|
+
const data = new Uint8Array(pixels * png.palette[0].length);
|
|
30972
31535
|
const pixelsPerByte = 8 / png.depth;
|
|
30973
31536
|
const factor = png.depth < 8 ? pixelsPerByte : 1;
|
|
30974
31537
|
const mask = Number.parseInt('1'.repeat(png.depth), 2);
|
|
@@ -30980,14 +31543,32 @@ ${indent}columns: ${matrix.columns}
|
|
|
30980
31543
|
value = value >>> png.depth * (pixelsPerByte - 1 - i % pixelsPerByte) & mask;
|
|
30981
31544
|
}
|
|
30982
31545
|
const paletteValue = png.palette[value];
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
|
|
31546
|
+
for (const paletteChannel of paletteValue) {
|
|
31547
|
+
data[dataIndex++] = paletteChannel;
|
|
31548
|
+
}
|
|
30986
31549
|
}
|
|
30987
31550
|
return new Image(png.width, png.height, {
|
|
30988
|
-
data
|
|
31551
|
+
data,
|
|
31552
|
+
colorModel: png.palette[0].length === 4 ? 'RGBA' : 'RGB'
|
|
30989
31553
|
});
|
|
30990
31554
|
}
|
|
31555
|
+
function decodeBinary(png) {
|
|
31556
|
+
const totalPixels = png.width * png.height;
|
|
31557
|
+
const result = new Uint8Array(totalPixels);
|
|
31558
|
+
const pngData = png.data;
|
|
31559
|
+
const padding = png.width % 8;
|
|
31560
|
+
const bytesPerLine = Math.ceil(png.width / 8);
|
|
31561
|
+
let pixelIndex = 0;
|
|
31562
|
+
for (let byteIndex = 0; byteIndex < pngData.length && pixelIndex < totalPixels; byteIndex++) {
|
|
31563
|
+
const byte = pngData[byteIndex];
|
|
31564
|
+
const limit = byteIndex % bytesPerLine === 0 ? 8 - padding : 0;
|
|
31565
|
+
for (let bitIndex = 7; bitIndex >= limit && pixelIndex < totalPixels; bitIndex--) {
|
|
31566
|
+
const bit = byte >> bitIndex & 1;
|
|
31567
|
+
result[pixelIndex++] = bit * 255;
|
|
31568
|
+
}
|
|
31569
|
+
}
|
|
31570
|
+
return result;
|
|
31571
|
+
}
|
|
30991
31572
|
|
|
30992
31573
|
/**
|
|
30993
31574
|
* Decode a TIFF. See the tiff module.
|
|
@@ -30995,9 +31576,10 @@ ${indent}columns: ${matrix.columns}
|
|
|
30995
31576
|
* @returns The decoded image.
|
|
30996
31577
|
*/
|
|
30997
31578
|
function decodeTiff(buffer) {
|
|
30998
|
-
const result = decodeTIFF(buffer
|
|
31579
|
+
const result = decodeTIFF(buffer, {
|
|
31580
|
+
pages: [0]
|
|
31581
|
+
});
|
|
30999
31582
|
return getImageFromIFD(result[0]);
|
|
31000
|
-
// TODO: optimize not to decode whole file
|
|
31001
31583
|
}
|
|
31002
31584
|
/**
|
|
31003
31585
|
* Create image from a single IFD.
|
|
@@ -31005,32 +31587,59 @@ ${indent}columns: ${matrix.columns}
|
|
|
31005
31587
|
* @returns The decoded image.
|
|
31006
31588
|
*/
|
|
31007
31589
|
function getImageFromIFD(ifd) {
|
|
31590
|
+
if (ifd.data instanceof Float32Array || ifd.data instanceof Float64Array) {
|
|
31591
|
+
throw new Error('Float TIFF data is not supported.');
|
|
31592
|
+
}
|
|
31008
31593
|
if (ifd.type === 3) {
|
|
31009
|
-
|
|
31010
|
-
const
|
|
31594
|
+
const hasAlpha = ifd.samplesPerPixel === 2;
|
|
31595
|
+
const pixelLength = hasAlpha ? 4 : 3;
|
|
31596
|
+
const data = new Uint16Array(pixelLength * ifd.width * ifd.height);
|
|
31011
31597
|
const palette = ifd.palette;
|
|
31012
31598
|
let ptr = 0;
|
|
31013
|
-
|
|
31014
|
-
|
|
31015
|
-
|
|
31016
|
-
|
|
31017
|
-
|
|
31599
|
+
if (hasAlpha) {
|
|
31600
|
+
for (let index = 0; index < ifd.data.length; index += ifd.samplesPerPixel) {
|
|
31601
|
+
const color = palette[ifd.data[index]];
|
|
31602
|
+
data[ptr++] = color[0];
|
|
31603
|
+
data[ptr++] = color[1];
|
|
31604
|
+
data[ptr++] = color[2];
|
|
31605
|
+
// To ensure that the value is 16 bits.
|
|
31606
|
+
data[ptr++] = Math.round(ifd.data[index + 1] / 2 ** ifd.bitsPerSample * 65535);
|
|
31607
|
+
}
|
|
31608
|
+
} else {
|
|
31609
|
+
for (let index = 0; index < ifd.data.length; index += ifd.samplesPerPixel) {
|
|
31610
|
+
const color = palette[ifd.data[index]];
|
|
31611
|
+
data[ptr++] = color[0];
|
|
31612
|
+
data[ptr++] = color[1];
|
|
31613
|
+
data[ptr++] = color[2];
|
|
31614
|
+
}
|
|
31018
31615
|
}
|
|
31019
31616
|
return new Image(ifd.width, ifd.height, {
|
|
31020
31617
|
data,
|
|
31021
|
-
|
|
31022
|
-
colorModel: ifd.alpha ? 'RGBA' : 'RGB',
|
|
31023
|
-
// TODO: handle other bit depths
|
|
31618
|
+
colorModel: hasAlpha ? 'RGBA' : 'RGB',
|
|
31024
31619
|
bitDepth: 16,
|
|
31025
31620
|
meta: getMetadata(ifd)
|
|
31026
31621
|
});
|
|
31622
|
+
} else if (ifd.type === 1 || ifd.type === 0) {
|
|
31623
|
+
if (ifd.bitsPerSample !== 1) {
|
|
31624
|
+
return new Image(ifd.width, ifd.height, {
|
|
31625
|
+
data: ifd.data,
|
|
31626
|
+
bitDepth: ifd.bitsPerSample,
|
|
31627
|
+
colorModel: ifd.alpha ? 'GREYA' : 'GREY',
|
|
31628
|
+
meta: getMetadata(ifd)
|
|
31629
|
+
});
|
|
31630
|
+
} else {
|
|
31631
|
+
return new Image(ifd.width, ifd.height, {
|
|
31632
|
+
data: ifd.data.map(pixel => pixel * 255),
|
|
31633
|
+
bitDepth: 8,
|
|
31634
|
+
colorModel: 'GREY',
|
|
31635
|
+
meta: getMetadata(ifd)
|
|
31636
|
+
});
|
|
31637
|
+
}
|
|
31027
31638
|
} else {
|
|
31028
31639
|
return new Image(ifd.width, ifd.height, {
|
|
31029
|
-
// TODO: handle float data
|
|
31030
|
-
// @ts-expect-error float data not handled yet
|
|
31031
31640
|
data: ifd.data,
|
|
31032
31641
|
bitDepth: ifd.bitsPerSample,
|
|
31033
|
-
colorModel: ifd.
|
|
31642
|
+
colorModel: ifd.alpha ? 'RGBA' : 'RGB',
|
|
31034
31643
|
meta: getMetadata(ifd)
|
|
31035
31644
|
});
|
|
31036
31645
|
}
|
|
@@ -31045,13 +31654,15 @@ ${indent}columns: ${matrix.columns}
|
|
|
31045
31654
|
function decode(data) {
|
|
31046
31655
|
const typedArray = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
31047
31656
|
const type = imageType$1(typedArray);
|
|
31048
|
-
return
|
|
31657
|
+
return M$2(type).with({
|
|
31049
31658
|
mime: 'image/png'
|
|
31050
31659
|
}, () => decodePng(typedArray)).with({
|
|
31051
31660
|
mime: 'image/jpeg'
|
|
31052
31661
|
}, () => decodeJpeg(typedArray)).with({
|
|
31053
31662
|
mime: 'image/tiff'
|
|
31054
|
-
}, () => decodeTiff(typedArray)).
|
|
31663
|
+
}, () => decodeTiff(typedArray)).with({
|
|
31664
|
+
mime: 'image/bmp'
|
|
31665
|
+
}, () => decodeBmp(typedArray)).otherwise(() => {
|
|
31055
31666
|
throw new RangeError(`invalid data format: ${type?.mime}`);
|
|
31056
31667
|
});
|
|
31057
31668
|
}
|
|
@@ -31223,7 +31834,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
31223
31834
|
} = options;
|
|
31224
31835
|
const colorMap = new Uint32Array(nbNegative + nbPositive + 1);
|
|
31225
31836
|
const hueRange = 360;
|
|
31226
|
-
const step =
|
|
31837
|
+
const step = M$2(roiKind).with('bw', () => hueRange / (nbNegative + nbPositive)).with('black', () => hueRange / nbNegative).with('white', () => hueRange / nbPositive).exhaustive();
|
|
31227
31838
|
// negative values
|
|
31228
31839
|
let hue = 0;
|
|
31229
31840
|
if (roiKind === 'bw' || roiKind === 'black') {
|
|
@@ -31293,7 +31904,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
31293
31904
|
roiKind: 'bw',
|
|
31294
31905
|
...options
|
|
31295
31906
|
};
|
|
31296
|
-
return
|
|
31907
|
+
return M$2(mode).with('binary', () => getBinaryMap(options)).with('saturation', () => getSaturationMap(options)).with('rainbow', () => getRainbowMap(options)).exhaustive();
|
|
31297
31908
|
}
|
|
31298
31909
|
|
|
31299
31910
|
const RoisColorMode = {
|
|
@@ -32108,7 +32719,7 @@ ${indent}columns: ${matrix.columns}
|
|
|
32108
32719
|
if (roiMapManager.blackRois.length === 0 && roiMapManager.whiteRois.length === 0) {
|
|
32109
32720
|
computeRois(roiMapManager);
|
|
32110
32721
|
}
|
|
32111
|
-
const rois =
|
|
32722
|
+
const rois = M$2(kind).with('black', () => roiMapManager.blackRois).with('white', () => roiMapManager.whiteRois).with('bw', () => [...roiMapManager.whiteRois, ...roiMapManager.blackRois]).exhaustive();
|
|
32112
32723
|
return rois.filter(roi => roi.surface >= minSurface && roi.surface <= maxSurface);
|
|
32113
32724
|
}
|
|
32114
32725
|
|
|
@@ -32898,6 +33509,61 @@ ${indent}columns: ${matrix.columns}
|
|
|
32898
33509
|
return result;
|
|
32899
33510
|
}
|
|
32900
33511
|
|
|
33512
|
+
/**
|
|
33513
|
+
* Decodes APNG image into a Stack
|
|
33514
|
+
* @param data - APNG data.
|
|
33515
|
+
* @returns stack of frames.
|
|
33516
|
+
*/
|
|
33517
|
+
function decodeStackFromApng(data) {
|
|
33518
|
+
const decodedApng = decodeApng(data);
|
|
33519
|
+
const images = [];
|
|
33520
|
+
let colorModel;
|
|
33521
|
+
switch (decodedApng.channels) {
|
|
33522
|
+
case 1:
|
|
33523
|
+
if (decodedApng.palette) {
|
|
33524
|
+
colorModel = decodedApng.palette[0].length === 3 ? 'RGB' : 'RGBA';
|
|
33525
|
+
} else {
|
|
33526
|
+
colorModel = 'GREY';
|
|
33527
|
+
}
|
|
33528
|
+
break;
|
|
33529
|
+
case 2:
|
|
33530
|
+
colorModel = 'GREYA';
|
|
33531
|
+
break;
|
|
33532
|
+
case 3:
|
|
33533
|
+
colorModel = 'RGB';
|
|
33534
|
+
break;
|
|
33535
|
+
default:
|
|
33536
|
+
colorModel = 'RGBA';
|
|
33537
|
+
break;
|
|
33538
|
+
}
|
|
33539
|
+
if (decodedApng.palette) {
|
|
33540
|
+
for (const image of decodedApng.frames) {
|
|
33541
|
+
images.push(new Image(decodedApng.width, decodedApng.height, {
|
|
33542
|
+
data: convertIndexedData(image.data, decodedApng.palette),
|
|
33543
|
+
colorModel
|
|
33544
|
+
}));
|
|
33545
|
+
}
|
|
33546
|
+
} else {
|
|
33547
|
+
for (const image of decodedApng.frames) {
|
|
33548
|
+
images.push(new Image(decodedApng.width, decodedApng.height, {
|
|
33549
|
+
data: image.data,
|
|
33550
|
+
colorModel
|
|
33551
|
+
}));
|
|
33552
|
+
}
|
|
33553
|
+
}
|
|
33554
|
+
const stack = new Stack(images);
|
|
33555
|
+
return stack;
|
|
33556
|
+
}
|
|
33557
|
+
function convertIndexedData(data, palette) {
|
|
33558
|
+
const result = new Uint8Array(data.length * palette[0].length);
|
|
33559
|
+
for (let i = 0; i < data.length; i++) {
|
|
33560
|
+
for (let channel = 0; channel < palette[0].length; channel++) {
|
|
33561
|
+
result[i * palette[0].length + channel] = palette[data[i]][channel];
|
|
33562
|
+
}
|
|
33563
|
+
}
|
|
33564
|
+
return result;
|
|
33565
|
+
}
|
|
33566
|
+
|
|
32901
33567
|
/**
|
|
32902
33568
|
* Decode a TIFF and create a stack of images.
|
|
32903
33569
|
* @param buffer - The data to decode.
|
|
@@ -32921,9 +33587,11 @@ ${indent}columns: ${matrix.columns}
|
|
|
32921
33587
|
function decodeStack(data) {
|
|
32922
33588
|
const typedArray = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
32923
33589
|
const type = imageType$1(typedArray);
|
|
32924
|
-
return
|
|
33590
|
+
return M$2(type).with({
|
|
32925
33591
|
mime: 'image/tiff'
|
|
32926
|
-
}, () => decodeStackFromTiff(typedArray)).
|
|
33592
|
+
}, () => decodeStackFromTiff(typedArray)).with({
|
|
33593
|
+
mime: 'image/png'
|
|
33594
|
+
}, () => decodeStackFromApng(typedArray)).otherwise(() => {
|
|
32927
33595
|
throw new RangeError(`invalid data format: ${type?.mime}`);
|
|
32928
33596
|
});
|
|
32929
33597
|
}
|