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.esm.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
|
*
|
|
@@ -5694,11 +5694,13 @@ function rotate$1(radians, points) {
|
|
|
5694
5694
|
* @returns Sorted points.
|
|
5695
5695
|
*/
|
|
5696
5696
|
function sortByColumnRow(points) {
|
|
5697
|
-
|
|
5697
|
+
const sortedPoints = points.slice();
|
|
5698
|
+
sortedPoints.sort((point1, point2) => {
|
|
5698
5699
|
if (point1.column < point2.column) return -1;
|
|
5699
5700
|
if (point1.column > point2.column) return 1;
|
|
5700
5701
|
return point1.row - point2.row;
|
|
5701
5702
|
});
|
|
5703
|
+
return sortedPoints;
|
|
5702
5704
|
}
|
|
5703
5705
|
|
|
5704
5706
|
/**
|
|
@@ -5790,35 +5792,35 @@ const t$2 = Symbol.for("@ts-pattern/matcher"),
|
|
|
5790
5792
|
if (!Array.isArray(s)) return false;
|
|
5791
5793
|
let t = [],
|
|
5792
5794
|
r = [],
|
|
5793
|
-
|
|
5795
|
+
u = [];
|
|
5794
5796
|
for (const o of n.keys()) {
|
|
5795
5797
|
const s = n[o];
|
|
5796
|
-
i$2(s) && s[e$2] ?
|
|
5798
|
+
i$2(s) && s[e$2] ? u.push(s) : u.length ? r.push(s) : t.push(s);
|
|
5797
5799
|
}
|
|
5798
|
-
if (
|
|
5799
|
-
if (
|
|
5800
|
+
if (u.length) {
|
|
5801
|
+
if (u.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
5800
5802
|
if (s.length < t.length + r.length) return false;
|
|
5801
5803
|
const e = s.slice(0, t.length),
|
|
5802
5804
|
n = 0 === r.length ? [] : s.slice(-r.length),
|
|
5803
5805
|
i = s.slice(t.length, 0 === r.length ? Infinity : -r.length);
|
|
5804
|
-
return t.every((t, n) => o$2(t, e[n], c)) && r.every((t, e) => o$2(t, n[e], c)) && (0 ===
|
|
5806
|
+
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));
|
|
5805
5807
|
}
|
|
5806
5808
|
return n.length === s.length && n.every((t, e) => o$2(t, s[e], c));
|
|
5807
5809
|
}
|
|
5808
5810
|
return Reflect.ownKeys(n).every(e => {
|
|
5809
5811
|
const r = n[e];
|
|
5810
|
-
return (e in s || i$2(
|
|
5811
|
-
var
|
|
5812
|
+
return (e in s || i$2(u = r) && "optional" === u[t$2]().matcherType) && o$2(r, s[e], c);
|
|
5813
|
+
var u;
|
|
5812
5814
|
});
|
|
5813
5815
|
}
|
|
5814
5816
|
return Object.is(s, n);
|
|
5815
5817
|
},
|
|
5816
5818
|
s$1 = e => {
|
|
5817
|
-
var n, o,
|
|
5818
|
-
return r$2(e) ? i$2(e) ? null != (n = null == (o = (
|
|
5819
|
+
var n, o, u;
|
|
5820
|
+
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) : [];
|
|
5819
5821
|
},
|
|
5820
5822
|
c$1 = (t, e) => t.reduce((t, n) => t.concat(e(n)), []);
|
|
5821
|
-
function
|
|
5823
|
+
function u$2(...t) {
|
|
5822
5824
|
if (1 === t.length) {
|
|
5823
5825
|
const [e] = t;
|
|
5824
5826
|
return t => o$2(e, t, () => {});
|
|
@@ -5829,15 +5831,15 @@ function a$2(...t) {
|
|
|
5829
5831
|
}
|
|
5830
5832
|
throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`);
|
|
5831
5833
|
}
|
|
5832
|
-
function
|
|
5834
|
+
function a$2(t) {
|
|
5833
5835
|
return Object.assign(t, {
|
|
5834
|
-
optional: () =>
|
|
5835
|
-
and: e =>
|
|
5836
|
-
or: e =>
|
|
5837
|
-
select: e => void 0 === e ?
|
|
5836
|
+
optional: () => h$2(t),
|
|
5837
|
+
and: e => d$1(t, e),
|
|
5838
|
+
or: e => y$1(t, e),
|
|
5839
|
+
select: e => void 0 === e ? v$1(t) : v$1(e, t)
|
|
5838
5840
|
});
|
|
5839
5841
|
}
|
|
5840
|
-
function
|
|
5842
|
+
function l$2(t) {
|
|
5841
5843
|
return Object.assign((t => Object.assign(t, {
|
|
5842
5844
|
[Symbol.iterator]() {
|
|
5843
5845
|
let n = 0;
|
|
@@ -5858,12 +5860,12 @@ function h$2(t) {
|
|
|
5858
5860
|
};
|
|
5859
5861
|
}
|
|
5860
5862
|
}))(t), {
|
|
5861
|
-
optional: () =>
|
|
5862
|
-
select: e =>
|
|
5863
|
+
optional: () => l$2(h$2(t)),
|
|
5864
|
+
select: e => l$2(void 0 === e ? v$1(t) : v$1(e, t))
|
|
5863
5865
|
});
|
|
5864
5866
|
}
|
|
5865
|
-
function
|
|
5866
|
-
return
|
|
5867
|
+
function h$2(e) {
|
|
5868
|
+
return a$2({
|
|
5867
5869
|
[t$2]: () => ({
|
|
5868
5870
|
match: t => {
|
|
5869
5871
|
let n = {};
|
|
@@ -5890,9 +5892,14 @@ const f$1 = (t, e) => {
|
|
|
5890
5892
|
g$1 = (t, e) => {
|
|
5891
5893
|
for (const [n, r] of t.entries()) if (!e(r, n)) return false;
|
|
5892
5894
|
return true;
|
|
5895
|
+
},
|
|
5896
|
+
m$1 = (t, e) => {
|
|
5897
|
+
const n = Reflect.ownKeys(t);
|
|
5898
|
+
for (const r of n) if (!e(r, t[r])) return false;
|
|
5899
|
+
return true;
|
|
5893
5900
|
};
|
|
5894
|
-
function
|
|
5895
|
-
return
|
|
5901
|
+
function d$1(...e) {
|
|
5902
|
+
return a$2({
|
|
5896
5903
|
[t$2]: () => ({
|
|
5897
5904
|
match: t => {
|
|
5898
5905
|
let n = {};
|
|
@@ -5909,8 +5916,8 @@ function m$1(...e) {
|
|
|
5909
5916
|
})
|
|
5910
5917
|
});
|
|
5911
5918
|
}
|
|
5912
|
-
function
|
|
5913
|
-
return
|
|
5919
|
+
function y$1(...e) {
|
|
5920
|
+
return a$2({
|
|
5914
5921
|
[t$2]: () => ({
|
|
5915
5922
|
match: t => {
|
|
5916
5923
|
let n = {};
|
|
@@ -5936,10 +5943,10 @@ function p$2(e) {
|
|
|
5936
5943
|
})
|
|
5937
5944
|
};
|
|
5938
5945
|
}
|
|
5939
|
-
function
|
|
5946
|
+
function v$1(...e) {
|
|
5940
5947
|
const r = "string" == typeof e[0] ? e[0] : void 0,
|
|
5941
5948
|
i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
|
|
5942
|
-
return
|
|
5949
|
+
return a$2({
|
|
5943
5950
|
[t$2]: () => ({
|
|
5944
5951
|
match: t => {
|
|
5945
5952
|
let e = {
|
|
@@ -5956,81 +5963,83 @@ function y$1(...e) {
|
|
|
5956
5963
|
})
|
|
5957
5964
|
});
|
|
5958
5965
|
}
|
|
5959
|
-
function
|
|
5966
|
+
function b$2(t) {
|
|
5967
|
+
return true;
|
|
5968
|
+
}
|
|
5969
|
+
function w$2(t) {
|
|
5960
5970
|
return "number" == typeof t;
|
|
5961
5971
|
}
|
|
5962
|
-
function
|
|
5972
|
+
function S$1(t) {
|
|
5963
5973
|
return "string" == typeof t;
|
|
5964
5974
|
}
|
|
5965
|
-
function
|
|
5975
|
+
function j$1(t) {
|
|
5966
5976
|
return "bigint" == typeof t;
|
|
5967
5977
|
}
|
|
5968
|
-
const
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
j$1 = t => Object.assign(u$2(t), {
|
|
5978
|
+
const K = a$2(p$2(b$2)),
|
|
5979
|
+
O = a$2(p$2(b$2)),
|
|
5980
|
+
E = K,
|
|
5981
|
+
x$1 = t => Object.assign(a$2(t), {
|
|
5973
5982
|
startsWith: e => {
|
|
5974
|
-
return
|
|
5983
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.startsWith(n)))));
|
|
5975
5984
|
var n;
|
|
5976
5985
|
},
|
|
5977
5986
|
endsWith: e => {
|
|
5978
|
-
return
|
|
5987
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.endsWith(n)))));
|
|
5979
5988
|
var n;
|
|
5980
5989
|
},
|
|
5981
|
-
minLength: e =>
|
|
5982
|
-
length: e =>
|
|
5983
|
-
maxLength: e =>
|
|
5990
|
+
minLength: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length >= t))(e))),
|
|
5991
|
+
length: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length === t))(e))),
|
|
5992
|
+
maxLength: e => x$1(d$1(t, (t => p$2(e => S$1(e) && e.length <= t))(e))),
|
|
5984
5993
|
includes: e => {
|
|
5985
|
-
return
|
|
5994
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && t.includes(n)))));
|
|
5986
5995
|
var n;
|
|
5987
5996
|
},
|
|
5988
5997
|
regex: e => {
|
|
5989
|
-
return
|
|
5998
|
+
return x$1(d$1(t, (n = e, p$2(t => S$1(t) && Boolean(t.match(n))))));
|
|
5990
5999
|
var n;
|
|
5991
6000
|
}
|
|
5992
6001
|
}),
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
between: (e, n) =>
|
|
5996
|
-
lt: e =>
|
|
5997
|
-
gt: e =>
|
|
5998
|
-
lte: e =>
|
|
5999
|
-
gte: e =>
|
|
6000
|
-
int: () =>
|
|
6001
|
-
finite: () =>
|
|
6002
|
-
positive: () =>
|
|
6003
|
-
negative: () =>
|
|
6002
|
+
A = x$1(p$2(S$1)),
|
|
6003
|
+
N$1 = t => Object.assign(a$2(t), {
|
|
6004
|
+
between: (e, n) => N$1(d$1(t, ((t, e) => p$2(n => w$2(n) && t <= n && e >= n))(e, n))),
|
|
6005
|
+
lt: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e < t))(e))),
|
|
6006
|
+
gt: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e > t))(e))),
|
|
6007
|
+
lte: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e <= t))(e))),
|
|
6008
|
+
gte: e => N$1(d$1(t, (t => p$2(e => w$2(e) && e >= t))(e))),
|
|
6009
|
+
int: () => N$1(d$1(t, p$2(t => w$2(t) && Number.isInteger(t)))),
|
|
6010
|
+
finite: () => N$1(d$1(t, p$2(t => w$2(t) && Number.isFinite(t)))),
|
|
6011
|
+
positive: () => N$1(d$1(t, p$2(t => w$2(t) && t > 0))),
|
|
6012
|
+
negative: () => N$1(d$1(t, p$2(t => w$2(t) && t < 0)))
|
|
6004
6013
|
}),
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
between: (e, n) =>
|
|
6008
|
-
lt: e =>
|
|
6009
|
-
gt: e =>
|
|
6010
|
-
lte: e =>
|
|
6011
|
-
gte: e =>
|
|
6012
|
-
positive: () =>
|
|
6013
|
-
negative: () =>
|
|
6014
|
+
P = N$1(p$2(w$2)),
|
|
6015
|
+
k$1 = t => Object.assign(a$2(t), {
|
|
6016
|
+
between: (e, n) => k$1(d$1(t, ((t, e) => p$2(n => j$1(n) && t <= n && e >= n))(e, n))),
|
|
6017
|
+
lt: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e < t))(e))),
|
|
6018
|
+
gt: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e > t))(e))),
|
|
6019
|
+
lte: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e <= t))(e))),
|
|
6020
|
+
gte: e => k$1(d$1(t, (t => p$2(e => j$1(e) && e >= t))(e))),
|
|
6021
|
+
positive: () => k$1(d$1(t, p$2(t => j$1(t) && t > 0))),
|
|
6022
|
+
negative: () => k$1(d$1(t, p$2(t => j$1(t) && t < 0)))
|
|
6014
6023
|
}),
|
|
6015
|
-
|
|
6016
|
-
|
|
6024
|
+
T = k$1(p$2(j$1)),
|
|
6025
|
+
B = a$2(p$2(function (t) {
|
|
6017
6026
|
return "boolean" == typeof t;
|
|
6018
6027
|
})),
|
|
6019
|
-
|
|
6028
|
+
_ = a$2(p$2(function (t) {
|
|
6020
6029
|
return "symbol" == typeof t;
|
|
6021
6030
|
})),
|
|
6022
|
-
|
|
6031
|
+
W = a$2(p$2(function (t) {
|
|
6023
6032
|
return null == t;
|
|
6024
6033
|
})),
|
|
6025
|
-
|
|
6034
|
+
$$1 = a$2(p$2(function (t) {
|
|
6026
6035
|
return null != t;
|
|
6027
6036
|
}));
|
|
6028
|
-
var
|
|
6037
|
+
var z = {
|
|
6029
6038
|
__proto__: null,
|
|
6030
6039
|
matcher: t$2,
|
|
6031
|
-
optional:
|
|
6040
|
+
optional: h$2,
|
|
6032
6041
|
array: function (...e) {
|
|
6033
|
-
return
|
|
6042
|
+
return l$2({
|
|
6034
6043
|
[t$2]: () => ({
|
|
6035
6044
|
match: t => {
|
|
6036
6045
|
if (!Array.isArray(t)) return {
|
|
@@ -6060,7 +6069,7 @@ var N$1 = {
|
|
|
6060
6069
|
});
|
|
6061
6070
|
},
|
|
6062
6071
|
set: function (...e) {
|
|
6063
|
-
return
|
|
6072
|
+
return a$2({
|
|
6064
6073
|
[t$2]: () => ({
|
|
6065
6074
|
match: t => {
|
|
6066
6075
|
if (!(t instanceof Set)) return {
|
|
@@ -6088,7 +6097,7 @@ var N$1 = {
|
|
|
6088
6097
|
});
|
|
6089
6098
|
},
|
|
6090
6099
|
map: function (...e) {
|
|
6091
|
-
return
|
|
6100
|
+
return a$2({
|
|
6092
6101
|
[t$2]: () => ({
|
|
6093
6102
|
match: t => {
|
|
6094
6103
|
if (!(t instanceof Map)) return {
|
|
@@ -6121,10 +6130,39 @@ var N$1 = {
|
|
|
6121
6130
|
})
|
|
6122
6131
|
});
|
|
6123
6132
|
},
|
|
6124
|
-
|
|
6125
|
-
|
|
6133
|
+
record: function (...e) {
|
|
6134
|
+
return a$2({
|
|
6135
|
+
[t$2]: () => ({
|
|
6136
|
+
match: t => {
|
|
6137
|
+
if (null === t || "object" != typeof t || Array.isArray(t)) return {
|
|
6138
|
+
matched: false
|
|
6139
|
+
};
|
|
6140
|
+
var n;
|
|
6141
|
+
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()}`);
|
|
6142
|
+
let r = {};
|
|
6143
|
+
const i = (t, e) => {
|
|
6144
|
+
r[t] = (r[t] || []).concat([e]);
|
|
6145
|
+
},
|
|
6146
|
+
[s, c] = 1 === e.length ? [A, e[0]] : e;
|
|
6147
|
+
return {
|
|
6148
|
+
matched: m$1(t, (t, e) => {
|
|
6149
|
+
const n = "string" != typeof t || Number.isNaN(Number(t)) ? null : Number(t),
|
|
6150
|
+
r = null !== n && o$2(s, n, i),
|
|
6151
|
+
u = o$2(s, t, i),
|
|
6152
|
+
a = o$2(c, e, i);
|
|
6153
|
+
return (u || r) && a;
|
|
6154
|
+
}),
|
|
6155
|
+
selections: r
|
|
6156
|
+
};
|
|
6157
|
+
},
|
|
6158
|
+
getSelectionKeys: () => 0 === e.length ? [] : [...s$1(e[0]), ...s$1(e[1])]
|
|
6159
|
+
})
|
|
6160
|
+
});
|
|
6161
|
+
},
|
|
6162
|
+
intersection: d$1,
|
|
6163
|
+
union: y$1,
|
|
6126
6164
|
not: function (e) {
|
|
6127
|
-
return
|
|
6165
|
+
return a$2({
|
|
6128
6166
|
[t$2]: () => ({
|
|
6129
6167
|
match: t => ({
|
|
6130
6168
|
matched: !o$2(e, t, () => {})
|
|
@@ -6135,26 +6173,27 @@ var N$1 = {
|
|
|
6135
6173
|
});
|
|
6136
6174
|
},
|
|
6137
6175
|
when: p$2,
|
|
6138
|
-
select:
|
|
6139
|
-
any:
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6176
|
+
select: v$1,
|
|
6177
|
+
any: K,
|
|
6178
|
+
unknown: O,
|
|
6179
|
+
_: E,
|
|
6180
|
+
string: A,
|
|
6181
|
+
number: P,
|
|
6182
|
+
bigint: T,
|
|
6183
|
+
boolean: B,
|
|
6184
|
+
symbol: _,
|
|
6185
|
+
nullish: W,
|
|
6186
|
+
nonNullable: $$1,
|
|
6148
6187
|
instanceOf: function (t) {
|
|
6149
|
-
return
|
|
6188
|
+
return a$2(p$2(function (t) {
|
|
6150
6189
|
return e => e instanceof t;
|
|
6151
6190
|
}(t)));
|
|
6152
6191
|
},
|
|
6153
6192
|
shape: function (t) {
|
|
6154
|
-
return
|
|
6193
|
+
return a$2(p$2(u$2(t)));
|
|
6155
6194
|
}
|
|
6156
6195
|
};
|
|
6157
|
-
class
|
|
6196
|
+
class I extends Error {
|
|
6158
6197
|
constructor(t) {
|
|
6159
6198
|
let e;
|
|
6160
6199
|
try {
|
|
@@ -6165,14 +6204,14 @@ class W extends Error {
|
|
|
6165
6204
|
super(`Pattern matching error: no pattern matches value ${e}`), this.input = void 0, this.input = t;
|
|
6166
6205
|
}
|
|
6167
6206
|
}
|
|
6168
|
-
const
|
|
6207
|
+
const L = {
|
|
6169
6208
|
matched: false,
|
|
6170
6209
|
value: void 0
|
|
6171
6210
|
};
|
|
6172
|
-
function
|
|
6173
|
-
return new
|
|
6211
|
+
function M$2(t) {
|
|
6212
|
+
return new R(t, L);
|
|
6174
6213
|
}
|
|
6175
|
-
class
|
|
6214
|
+
class R {
|
|
6176
6215
|
constructor(t, e) {
|
|
6177
6216
|
this.input = void 0, this.state = void 0, this.input = t, this.state = e;
|
|
6178
6217
|
}
|
|
@@ -6184,27 +6223,27 @@ class I {
|
|
|
6184
6223
|
3 === t.length && "function" == typeof t[1] ? i = t[1] : t.length > 2 && r.push(...t.slice(1, t.length - 1));
|
|
6185
6224
|
let s = false,
|
|
6186
6225
|
c = {};
|
|
6187
|
-
const
|
|
6226
|
+
const u = (t, e) => {
|
|
6188
6227
|
s = true, c[t] = e;
|
|
6189
6228
|
},
|
|
6190
|
-
|
|
6229
|
+
a = !r.some(t => o$2(t, this.input, u)) || i && !Boolean(i(this.input)) ? L : {
|
|
6191
6230
|
matched: true,
|
|
6192
6231
|
value: e(s ? n$2 in c ? c[n$2] : c : this.input, this.input)
|
|
6193
6232
|
};
|
|
6194
|
-
return new
|
|
6233
|
+
return new R(this.input, a);
|
|
6195
6234
|
}
|
|
6196
6235
|
when(t, e) {
|
|
6197
6236
|
if (this.state.matched) return this;
|
|
6198
6237
|
const n = Boolean(t(this.input));
|
|
6199
|
-
return new
|
|
6238
|
+
return new R(this.input, n ? {
|
|
6200
6239
|
matched: true,
|
|
6201
6240
|
value: e(this.input, this.input)
|
|
6202
|
-
} :
|
|
6241
|
+
} : L);
|
|
6203
6242
|
}
|
|
6204
6243
|
otherwise(t) {
|
|
6205
6244
|
return this.state.matched ? this.state.value : t(this.input);
|
|
6206
6245
|
}
|
|
6207
|
-
exhaustive(t =
|
|
6246
|
+
exhaustive(t = F) {
|
|
6208
6247
|
return this.state.matched ? this.state.value : t(this.input);
|
|
6209
6248
|
}
|
|
6210
6249
|
run() {
|
|
@@ -6217,34 +6256,377 @@ class I {
|
|
|
6217
6256
|
return this;
|
|
6218
6257
|
}
|
|
6219
6258
|
}
|
|
6220
|
-
function
|
|
6221
|
-
throw new
|
|
6259
|
+
function F(t) {
|
|
6260
|
+
throw new I(t);
|
|
6222
6261
|
}
|
|
6223
6262
|
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
}
|
|
6263
|
+
var index_umd$1 = {exports: {}};
|
|
6264
|
+
|
|
6265
|
+
var index_umd = index_umd$1.exports;
|
|
6266
|
+
(function (module, exports) {
|
|
6267
|
+
(function (N, J) {
|
|
6268
|
+
J(exports) ;
|
|
6269
|
+
})(index_umd, function (N) {
|
|
6270
|
+
|
|
6271
|
+
function J(f, a, o, t, e) {
|
|
6272
|
+
const h = Math.abs(o - f),
|
|
6273
|
+
r = f < o ? 1 : -1,
|
|
6274
|
+
l = -Math.abs(t - a),
|
|
6275
|
+
M = a < t ? 1 : -1;
|
|
6276
|
+
let i = h + l,
|
|
6277
|
+
n;
|
|
6278
|
+
for (;;) {
|
|
6279
|
+
if (e(f, a), n = 2 * i, n >= l) {
|
|
6280
|
+
if (f === o) break;
|
|
6281
|
+
i += l, f += r;
|
|
6282
|
+
}
|
|
6283
|
+
if (n <= h) {
|
|
6284
|
+
if (a === t) break;
|
|
6285
|
+
i += h, a += M;
|
|
6286
|
+
}
|
|
6287
|
+
}
|
|
6288
|
+
}
|
|
6289
|
+
function U(f, a, o, t, e) {
|
|
6290
|
+
const h = f < o ? 1 : -1,
|
|
6291
|
+
r = a < t ? 1 : -1;
|
|
6292
|
+
let l,
|
|
6293
|
+
M = Math.abs(o - f),
|
|
6294
|
+
i = Math.abs(t - a),
|
|
6295
|
+
n = M * M + i * i,
|
|
6296
|
+
c = n === 0 ? 1 : 1 / Math.sqrt(n);
|
|
6297
|
+
for (M *= c, i *= c, n = M - i;;) {
|
|
6298
|
+
if (e(f, a, Math.abs(n - (M + i)) >> 16), c = n, l = f, 2 * c >= -M) {
|
|
6299
|
+
if (f === o) break;
|
|
6300
|
+
c + i < 16711680 && e(f, a + r, c + i >> 16), n -= i, f += h;
|
|
6301
|
+
}
|
|
6302
|
+
if (2 * c <= i) {
|
|
6303
|
+
if (a === t) break;
|
|
6304
|
+
M - c < 16711680 && e(l + h, a, M - c >> 16), n += M, a += r;
|
|
6305
|
+
}
|
|
6306
|
+
}
|
|
6307
|
+
}
|
|
6308
|
+
function w(f, a, o, t, e, h) {
|
|
6309
|
+
let r = Math.abs(o - f),
|
|
6310
|
+
l = f < o ? 1 : -1,
|
|
6311
|
+
M = Math.abs(t - a),
|
|
6312
|
+
i = a < t ? 1 : -1,
|
|
6313
|
+
n = r - M,
|
|
6314
|
+
c,
|
|
6315
|
+
q,
|
|
6316
|
+
d,
|
|
6317
|
+
b = r + M == 0 ? 1 : Math.sqrt(r * r + M * M);
|
|
6318
|
+
for (e = (e + 1) / 2;;) {
|
|
6319
|
+
if (h(f, a, Math.max(0, 255 * (Math.abs(n - r + M) / b - e + 1))), c = n, q = f, 2 * c >= -r) {
|
|
6320
|
+
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)));
|
|
6321
|
+
if (f == o) break;
|
|
6322
|
+
c = n, n -= M, f += l;
|
|
6323
|
+
}
|
|
6324
|
+
if (2 * c <= M) {
|
|
6325
|
+
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)));
|
|
6326
|
+
if (a == t) break;
|
|
6327
|
+
n += r, a += i;
|
|
6328
|
+
}
|
|
6329
|
+
}
|
|
6330
|
+
}
|
|
6331
|
+
function I(f, a = "assert error") {
|
|
6332
|
+
if (!f) throw new Error(a);
|
|
6333
|
+
}
|
|
6334
|
+
function P(f, a, o, t, e, h, r, l) {
|
|
6335
|
+
var M = f - 2 * o + e,
|
|
6336
|
+
i = a - 2 * t + h,
|
|
6337
|
+
n = f - o,
|
|
6338
|
+
c = a - t,
|
|
6339
|
+
q,
|
|
6340
|
+
d,
|
|
6341
|
+
b;
|
|
6342
|
+
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);
|
|
6343
|
+
}
|
|
6344
|
+
function H(f, a, o, t, e, h, r, l) {
|
|
6345
|
+
var M = e - o,
|
|
6346
|
+
i = h - t,
|
|
6347
|
+
n = f - e,
|
|
6348
|
+
c = a - h,
|
|
6349
|
+
q = f - o,
|
|
6350
|
+
d = a - t,
|
|
6351
|
+
b = q * i + d * M,
|
|
6352
|
+
s = q * i - d * M,
|
|
6353
|
+
u;
|
|
6354
|
+
if (I(q * M <= 0 && d * i <= 0, "sign of gradient must not change"), s != 0 && r > 0) {
|
|
6355
|
+
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)) {
|
|
6356
|
+
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);
|
|
6357
|
+
return;
|
|
6358
|
+
}
|
|
6359
|
+
u = n + c - b;
|
|
6360
|
+
do {
|
|
6361
|
+
if (l(f, a), f == e && a == h) return;
|
|
6362
|
+
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);
|
|
6363
|
+
} while (c <= b && n >= b);
|
|
6364
|
+
}
|
|
6365
|
+
J(f, a, e, h, l);
|
|
6366
|
+
}
|
|
6367
|
+
function V(f, a, o, t, e, h, r, l) {
|
|
6368
|
+
var M = e - o,
|
|
6369
|
+
i = h - t,
|
|
6370
|
+
n = f - e,
|
|
6371
|
+
c = a - h,
|
|
6372
|
+
q = f - o,
|
|
6373
|
+
d = a - t,
|
|
6374
|
+
b = q * i + d * M,
|
|
6375
|
+
s = q * i - d * M,
|
|
6376
|
+
u,
|
|
6377
|
+
z,
|
|
6378
|
+
j;
|
|
6379
|
+
if (I(q * M <= 0 && d * i <= 0), s != 0 && r > 0) {
|
|
6380
|
+
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);
|
|
6381
|
+
u = n + c - b;
|
|
6382
|
+
do {
|
|
6383
|
+
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) {
|
|
6384
|
+
if (a == h) return;
|
|
6385
|
+
n - u < z && l(f + M, a, 255 * Math.abs(n - u) / z);
|
|
6386
|
+
}
|
|
6387
|
+
if (2 * u + n > 0) {
|
|
6388
|
+
if (f == e) return;
|
|
6389
|
+
u - c < z && l(f, a + i, 255 * Math.abs(u - c) / z), f += M, n += b, u += c += d;
|
|
6390
|
+
}
|
|
6391
|
+
j && (a += i, c += b, u += n += q);
|
|
6392
|
+
} while (c < n);
|
|
6393
|
+
}
|
|
6394
|
+
U(f, a, e, h, l);
|
|
6395
|
+
}
|
|
6396
|
+
function y(f, a, o, t, e) {
|
|
6397
|
+
let h = -o,
|
|
6398
|
+
r = 0,
|
|
6399
|
+
l = t * t,
|
|
6400
|
+
M = h * (2 * l + h) + l;
|
|
6401
|
+
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);
|
|
6402
|
+
for (; r++ < t;) e(f, a + r), e(f, a - r);
|
|
6403
|
+
}
|
|
6404
|
+
function x(f, a, o, t, e, h) {
|
|
6405
|
+
let r = o * o,
|
|
6406
|
+
l = t * t;
|
|
6407
|
+
const M = Math.sin(e);
|
|
6408
|
+
let i = (r - l) * M;
|
|
6409
|
+
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);
|
|
6410
|
+
}
|
|
6411
|
+
function Y(f, a, o, t, e, h) {
|
|
6412
|
+
let r = o - f,
|
|
6413
|
+
l = t - a,
|
|
6414
|
+
M = r * l;
|
|
6415
|
+
if (e === 0) return Z(f, a, o, t, h);
|
|
6416
|
+
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);
|
|
6417
|
+
}
|
|
6418
|
+
function Z(f, a, o, t, e) {
|
|
6419
|
+
let h = Math.abs(o - f),
|
|
6420
|
+
r = Math.abs(t - a),
|
|
6421
|
+
l = r & 1,
|
|
6422
|
+
M = 4 * (1 - h) * r * r,
|
|
6423
|
+
i = 4 * (l + 1) * h * h,
|
|
6424
|
+
n = M + i + l * h * h,
|
|
6425
|
+
c;
|
|
6426
|
+
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;
|
|
6427
|
+
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);
|
|
6428
|
+
for (; a - t <= r;) e(f - 1, a), e(o + 1, a++), e(f - 1, t), e(o + 1, t--);
|
|
6429
|
+
}
|
|
6430
|
+
function aa(f, a, o, t) {
|
|
6431
|
+
var e = -o,
|
|
6432
|
+
h = 0,
|
|
6433
|
+
r = 2 - 2 * o;
|
|
6434
|
+
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);
|
|
6435
|
+
}
|
|
6436
|
+
function fa(f, a, o, t) {
|
|
6437
|
+
var e = -o,
|
|
6438
|
+
h = 0,
|
|
6439
|
+
r,
|
|
6440
|
+
l,
|
|
6441
|
+
M,
|
|
6442
|
+
i = 2 - 2 * o;
|
|
6443
|
+
o = 1 - i;
|
|
6444
|
+
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);
|
|
6445
|
+
}
|
|
6446
|
+
function ta(f, a, o, t, e, h, r) {
|
|
6447
|
+
var l = f - o,
|
|
6448
|
+
M = a - t,
|
|
6449
|
+
i = f - 2 * o + e,
|
|
6450
|
+
n;
|
|
6451
|
+
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);
|
|
6452
|
+
}
|
|
6453
|
+
function L(f, a, o, t, e, h, r) {
|
|
6454
|
+
var l = e - o,
|
|
6455
|
+
M = h - t,
|
|
6456
|
+
i = f - o,
|
|
6457
|
+
n = a - t,
|
|
6458
|
+
c,
|
|
6459
|
+
q,
|
|
6460
|
+
d,
|
|
6461
|
+
b,
|
|
6462
|
+
s = i * M - n * l;
|
|
6463
|
+
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) {
|
|
6464
|
+
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;
|
|
6465
|
+
do {
|
|
6466
|
+
if (r(f, a), f == e && a == h) return;
|
|
6467
|
+
t = +(2 * b < q), 2 * b > d && (f += l, q -= c, b += d += n), t && (a += M, d -= c, b += q += i);
|
|
6468
|
+
} while (d < 0 && q > 0);
|
|
6469
|
+
}
|
|
6470
|
+
J(f, a, e, h, r);
|
|
6471
|
+
}
|
|
6472
|
+
function ia(f, a, o, t, e, h, r) {
|
|
6473
|
+
var l = f - o,
|
|
6474
|
+
M = a - t,
|
|
6475
|
+
i = f - 2 * o + e,
|
|
6476
|
+
n;
|
|
6477
|
+
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);
|
|
6478
|
+
}
|
|
6479
|
+
function Q(f, a, o, t, e, h, r) {
|
|
6480
|
+
var l = e - o,
|
|
6481
|
+
M = h - t,
|
|
6482
|
+
i = f - o,
|
|
6483
|
+
n = a - t,
|
|
6484
|
+
c,
|
|
6485
|
+
q,
|
|
6486
|
+
d,
|
|
6487
|
+
b,
|
|
6488
|
+
s,
|
|
6489
|
+
u = i * M - n * l;
|
|
6490
|
+
if (l * l + M * M > i * i + n * n && (e = f, f = l + o, h = a, a = M + t, u = -u), u != 0) {
|
|
6491
|
+
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;
|
|
6492
|
+
do {
|
|
6493
|
+
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;
|
|
6494
|
+
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);
|
|
6495
|
+
} while (d < q);
|
|
6496
|
+
}
|
|
6497
|
+
U(f, a, e, h, r);
|
|
6498
|
+
}
|
|
6499
|
+
function _(f, a, o, t, e, h, r, l, M) {
|
|
6500
|
+
var i,
|
|
6501
|
+
n,
|
|
6502
|
+
c,
|
|
6503
|
+
q = 1;
|
|
6504
|
+
let d = f < r ? 1 : -1,
|
|
6505
|
+
b = a < l ? 1 : -1,
|
|
6506
|
+
s = -Math.abs(f + o - e - r),
|
|
6507
|
+
u = s - 4 * d * (o - e),
|
|
6508
|
+
z = d * (f - o - e + r),
|
|
6509
|
+
j = -Math.abs(a + t - h - l),
|
|
6510
|
+
B = j - 4 * b * (t - h),
|
|
6511
|
+
R = b * (a - t - h + l),
|
|
6512
|
+
p,
|
|
6513
|
+
S,
|
|
6514
|
+
W,
|
|
6515
|
+
T,
|
|
6516
|
+
G,
|
|
6517
|
+
E,
|
|
6518
|
+
O,
|
|
6519
|
+
v,
|
|
6520
|
+
g,
|
|
6521
|
+
k,
|
|
6522
|
+
F,
|
|
6523
|
+
D = .01;
|
|
6524
|
+
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);
|
|
6525
|
+
o = (o - f) * (o - f) + (t - a) * (t - a) + 1, e = (e - r) * (e - r) + (h - l) * (h - l) + 1;
|
|
6526
|
+
do {
|
|
6527
|
+
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;
|
|
6528
|
+
a: for (F = E, n = c = i; f != r && a != l;) {
|
|
6529
|
+
M(f, a);
|
|
6530
|
+
do {
|
|
6531
|
+
if (v > F || g < F) break a;
|
|
6532
|
+
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);
|
|
6533
|
+
} while (n > 0 && c > 0);
|
|
6534
|
+
2 * n <= i && (f += d, n += i), 2 * c <= i && (a += b, c += i), F == E && v < 0 && g > 0 && (F = D);
|
|
6535
|
+
}
|
|
6536
|
+
G = f, f = r, r = G, d = -d, z = -z, O = a, a = l, l = O, b = -b, R = -R, o = e;
|
|
6537
|
+
} while (q--);
|
|
6538
|
+
J(f, a, r, l, M);
|
|
6539
|
+
}
|
|
6540
|
+
function $(f, a, o, t, e, h, r, l, M) {
|
|
6541
|
+
let i,
|
|
6542
|
+
n,
|
|
6543
|
+
c,
|
|
6544
|
+
q = 1,
|
|
6545
|
+
d = f < r ? 1 : -1,
|
|
6546
|
+
b = a < l ? 1 : -1,
|
|
6547
|
+
s = -Math.abs(f + o - e - r),
|
|
6548
|
+
u = s - 4 * d * (o - e),
|
|
6549
|
+
z = d * (f - o - e + r),
|
|
6550
|
+
j = -Math.abs(a + t - h - l),
|
|
6551
|
+
B = j - 4 * b * (t - h),
|
|
6552
|
+
R = b * (a - t - h + l),
|
|
6553
|
+
p,
|
|
6554
|
+
S,
|
|
6555
|
+
W,
|
|
6556
|
+
T,
|
|
6557
|
+
G,
|
|
6558
|
+
E,
|
|
6559
|
+
O,
|
|
6560
|
+
v,
|
|
6561
|
+
g,
|
|
6562
|
+
k,
|
|
6563
|
+
F,
|
|
6564
|
+
D,
|
|
6565
|
+
C,
|
|
6566
|
+
A;
|
|
6567
|
+
const K = .01;
|
|
6568
|
+
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);
|
|
6569
|
+
o = (o - f) * (o - f) + (t - a) * (t - a) + 1, e = (e - r) * (e - r) + (h - l) * (h - l) + 1;
|
|
6570
|
+
do {
|
|
6571
|
+
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;
|
|
6572
|
+
let X = false;
|
|
6573
|
+
a: for (n = c = i; f !== r && a !== l;) {
|
|
6574
|
+
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;
|
|
6575
|
+
do {
|
|
6576
|
+
if (A >= -K && (v + G > E || g + O < E)) {
|
|
6577
|
+
X = true;
|
|
6578
|
+
break a;
|
|
6579
|
+
}
|
|
6580
|
+
if (t = 2 * k + v, 2 * k + g > 0) n--, k += v += G, g += E += S, O += W, G += p;else if (t > 0) {
|
|
6581
|
+
X = true;
|
|
6582
|
+
break a;
|
|
6583
|
+
}
|
|
6584
|
+
t <= 0 && (c--, k += g += O, v += E += W, G += S, O += T);
|
|
6585
|
+
} while (n > 0 && c > 0);
|
|
6586
|
+
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);
|
|
6587
|
+
}
|
|
6588
|
+
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);
|
|
6589
|
+
break;
|
|
6590
|
+
} while (q--);
|
|
6591
|
+
U(Math.floor(f), Math.floor(a), Math.floor(r), Math.floor(l), M);
|
|
6592
|
+
}
|
|
6593
|
+
function m(f, a, o, t, e, h, r, l, M, i) {
|
|
6594
|
+
let n = 0,
|
|
6595
|
+
c = 0,
|
|
6596
|
+
q = f + o - e - r,
|
|
6597
|
+
d = q - 4 * (o - e),
|
|
6598
|
+
b = f - o - e + r,
|
|
6599
|
+
s = b + 4 * (o + e),
|
|
6600
|
+
u = a + t - h - l,
|
|
6601
|
+
z = u - 4 * (t - h),
|
|
6602
|
+
j = a - t - h + l,
|
|
6603
|
+
B = j + 4 * (t + h);
|
|
6604
|
+
var R = f,
|
|
6605
|
+
p,
|
|
6606
|
+
S,
|
|
6607
|
+
W,
|
|
6608
|
+
T = a,
|
|
6609
|
+
G,
|
|
6610
|
+
E,
|
|
6611
|
+
O;
|
|
6612
|
+
let v = b * b - d * q,
|
|
6613
|
+
g;
|
|
6614
|
+
const k = [0, 0, 0, 0, 0];
|
|
6615
|
+
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);
|
|
6616
|
+
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;
|
|
6617
|
+
}
|
|
6618
|
+
function ra(f, a, o, t, e, h, r, l, M) {
|
|
6619
|
+
m(f, a, o, t, e, h, r, l, _, M);
|
|
6620
|
+
}
|
|
6621
|
+
function oa(f, a, o, t, e, h, r, l, M) {
|
|
6622
|
+
m(f, a, o, t, e, h, r, l, $, M);
|
|
6623
|
+
}
|
|
6624
|
+
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, {
|
|
6625
|
+
value: "Module"
|
|
6626
|
+
});
|
|
6627
|
+
});
|
|
6628
|
+
})(index_umd$1, index_umd$1.exports);
|
|
6629
|
+
var index_umdExports = index_umd$1.exports;
|
|
6248
6630
|
|
|
6249
6631
|
/**
|
|
6250
6632
|
* Remove duplicate points from array.
|
|
@@ -6271,7 +6653,7 @@ function deleteDuplicates(points) {
|
|
|
6271
6653
|
*/
|
|
6272
6654
|
function getCirclePoints(radius) {
|
|
6273
6655
|
const circlePoints = [];
|
|
6274
|
-
|
|
6656
|
+
index_umdExports.circle(radius, radius, radius, (column, row) => {
|
|
6275
6657
|
circlePoints.push({
|
|
6276
6658
|
row: row - radius,
|
|
6277
6659
|
column: column - radius
|
|
@@ -6307,7 +6689,7 @@ function getFilledCirclePoints(radius, center = zeroPoint) {
|
|
|
6307
6689
|
if (radius === 1) {
|
|
6308
6690
|
circlePoints.push(center);
|
|
6309
6691
|
}
|
|
6310
|
-
|
|
6692
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
6311
6693
|
circlePoints.push({
|
|
6312
6694
|
row,
|
|
6313
6695
|
column
|
|
@@ -6341,7 +6723,7 @@ function getFilledCirclePoints(radius, center = zeroPoint) {
|
|
|
6341
6723
|
*/
|
|
6342
6724
|
function getLinePoints(from, to) {
|
|
6343
6725
|
const linePoints = [];
|
|
6344
|
-
|
|
6726
|
+
index_umdExports.line(from.column, from.row, to.column, to.row, (column, row) => {
|
|
6345
6727
|
linePoints.push({
|
|
6346
6728
|
row,
|
|
6347
6729
|
column
|
|
@@ -6356,7 +6738,7 @@ function getLinePoints(from, to) {
|
|
|
6356
6738
|
* @returns The coordinates of the compass points.
|
|
6357
6739
|
*/
|
|
6358
6740
|
function getCompassPoints(radius) {
|
|
6359
|
-
|
|
6741
|
+
index_umdExports.circle(radius, radius, radius, (column, row) => {
|
|
6360
6742
|
});
|
|
6361
6743
|
return [{
|
|
6362
6744
|
row: 0,
|
|
@@ -6667,7 +7049,7 @@ function getFastKeypoints(image, options = {}) {
|
|
|
6667
7049
|
channels: [1],
|
|
6668
7050
|
alpha: false
|
|
6669
7051
|
});
|
|
6670
|
-
const getScore =
|
|
7052
|
+
const getScore = M$2(scoreAlgorithm).with('HARRIS', () => {
|
|
6671
7053
|
return (image, corner) => getHarrisScore(image, corner, harrisScoreOptions);
|
|
6672
7054
|
}).with('FAST', () => {
|
|
6673
7055
|
return (image, corner) => getFastScore(image, corner, threshold, circlePoints);
|
|
@@ -8049,11 +8431,13 @@ function bruteForceOneMatch(source, destination, options = {}) {
|
|
|
8049
8431
|
* @returns Sorted copy of the array of matches.
|
|
8050
8432
|
*/
|
|
8051
8433
|
function sortBySourceDest(matches) {
|
|
8052
|
-
|
|
8434
|
+
const sorted = matches.slice();
|
|
8435
|
+
sorted.sort((match1, match2) => {
|
|
8053
8436
|
if (match1.sourceIndex < match2.sourceIndex) return -1;
|
|
8054
8437
|
if (match1.sourceIndex > match2.sourceIndex) return 1;
|
|
8055
8438
|
return match1.destinationIndex - match2.destinationIndex;
|
|
8056
8439
|
});
|
|
8440
|
+
return sorted;
|
|
8057
8441
|
}
|
|
8058
8442
|
/**
|
|
8059
8443
|
* Sort array of matches by destination index and then source index.
|
|
@@ -8061,11 +8445,13 @@ function sortBySourceDest(matches) {
|
|
|
8061
8445
|
* @returns Sorted copy of the array of matches.
|
|
8062
8446
|
*/
|
|
8063
8447
|
function sortByDestSource(matches) {
|
|
8064
|
-
|
|
8448
|
+
const sorted = matches.slice();
|
|
8449
|
+
sorted.sort((match1, match2) => {
|
|
8065
8450
|
if (match1.destinationIndex < match2.destinationIndex) return -1;
|
|
8066
8451
|
if (match1.destinationIndex > match2.destinationIndex) return 1;
|
|
8067
8452
|
return match1.sourceIndex - match2.sourceIndex;
|
|
8068
8453
|
});
|
|
8454
|
+
return sorted;
|
|
8069
8455
|
}
|
|
8070
8456
|
|
|
8071
8457
|
/**
|
|
@@ -8268,7 +8654,7 @@ function computePsnr(image, otherImage) {
|
|
|
8268
8654
|
* @returns Default color.
|
|
8269
8655
|
*/
|
|
8270
8656
|
function getDefaultColor(image) {
|
|
8271
|
-
return
|
|
8657
|
+
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();
|
|
8272
8658
|
}
|
|
8273
8659
|
|
|
8274
8660
|
/**
|
|
@@ -8356,7 +8742,7 @@ function drawCircleOnImage(image, center, radius, options = {}) {
|
|
|
8356
8742
|
return newImage;
|
|
8357
8743
|
}
|
|
8358
8744
|
if (!fillColor) {
|
|
8359
|
-
|
|
8745
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
8360
8746
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8361
8747
|
});
|
|
8362
8748
|
} else {
|
|
@@ -8366,7 +8752,7 @@ function drawCircleOnImage(image, center, radius, options = {}) {
|
|
|
8366
8752
|
//Starting points for the top and bottom row of the circle.
|
|
8367
8753
|
let prevRow = center.row + radius;
|
|
8368
8754
|
let index = 0;
|
|
8369
|
-
|
|
8755
|
+
index_umdExports.circle(center.column, center.row, radius, (column, row) => {
|
|
8370
8756
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8371
8757
|
// Filling the first line of the circle.
|
|
8372
8758
|
if (index === 0) {
|
|
@@ -8439,7 +8825,7 @@ function drawLineOnImage(image, from, to, options = {}) {
|
|
|
8439
8825
|
checkProcessable$1(newImage, {
|
|
8440
8826
|
bitDepth: [8, 16]
|
|
8441
8827
|
});
|
|
8442
|
-
|
|
8828
|
+
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) => {
|
|
8443
8829
|
setBlendedVisiblePixel(newImage, column, row, strokeColor);
|
|
8444
8830
|
});
|
|
8445
8831
|
return newImage;
|
|
@@ -8463,7 +8849,7 @@ function drawLineOnMask(mask, from, to, options = {}) {
|
|
|
8463
8849
|
const newMask = maskToOutputMask(mask, options, {
|
|
8464
8850
|
clone: true
|
|
8465
8851
|
});
|
|
8466
|
-
|
|
8852
|
+
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) => {
|
|
8467
8853
|
newMask.setVisiblePixel(column, row, [1]);
|
|
8468
8854
|
});
|
|
8469
8855
|
return newMask;
|
|
@@ -9569,7 +9955,7 @@ const BorderType = {
|
|
|
9569
9955
|
* @returns The border interpolation function.
|
|
9570
9956
|
*/
|
|
9571
9957
|
function getBorderInterpolation(type, value) {
|
|
9572
|
-
return
|
|
9958
|
+
return M$2(type).with('constant', () => getInterpolateConstant(value)).with('replicate', () => interpolateReplicate).with('reflect', () => interpolateReflect).with('reflect101', () => interpolateReflect101).with('wrap', () => interpolateWrap).exhaustive();
|
|
9573
9959
|
}
|
|
9574
9960
|
function checkRange(point, length) {
|
|
9575
9961
|
if (point <= 0 - length || point >= length + length - 1) {
|
|
@@ -9969,7 +10355,7 @@ function derivativeFilter(image, options = {}) {
|
|
|
9969
10355
|
const {
|
|
9970
10356
|
filter = 'sobel'
|
|
9971
10357
|
} = options;
|
|
9972
|
-
const kernels =
|
|
10358
|
+
const kernels = M$2(filter).with('sobel', () => ({
|
|
9973
10359
|
kernelX: SOBEL_X,
|
|
9974
10360
|
kernelY: SOBEL_Y
|
|
9975
10361
|
})).with('scharr', () => ({
|
|
@@ -11553,7 +11939,7 @@ function computeThreshold(image, options = {}) {
|
|
|
11553
11939
|
slots
|
|
11554
11940
|
});
|
|
11555
11941
|
const scale = slots ? 2 ** image.bitDepth / slots : 1;
|
|
11556
|
-
return
|
|
11942
|
+
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();
|
|
11557
11943
|
}
|
|
11558
11944
|
// See: https://docs.opencv.org/4.0.1/d7/d1b/group__imgproc__misc.html#gaa9e58d2860d4afa658ef70a9b1115576
|
|
11559
11945
|
/**
|
|
@@ -12064,7 +12450,7 @@ const InterpolationType = {
|
|
|
12064
12450
|
* @returns The interpolation function.
|
|
12065
12451
|
*/
|
|
12066
12452
|
function getInterpolationFunction(interpolationType) {
|
|
12067
|
-
return
|
|
12453
|
+
return M$2(interpolationType).with('nearest', () => interpolateNearest).with('bilinear', () => interpolateBilinear).with('bicubic', () => interpolateBicubic).exhaustive();
|
|
12068
12454
|
}
|
|
12069
12455
|
/**
|
|
12070
12456
|
* Interpolate using nearest neighbor.
|
|
@@ -13567,7 +13953,8 @@ function monotoneChainConvexHull(points, options = {}) {
|
|
|
13567
13953
|
sorted = false
|
|
13568
13954
|
} = options;
|
|
13569
13955
|
if (!sorted) {
|
|
13570
|
-
points = points.slice()
|
|
13956
|
+
points = points.slice();
|
|
13957
|
+
points.sort(byXThenY);
|
|
13571
13958
|
}
|
|
13572
13959
|
const n = points.length;
|
|
13573
13960
|
const result = new Array(n * 2);
|
|
@@ -13830,7 +14217,8 @@ const topFirst = (mbrPoint1, mbrPoint2) => mbrPoint1.row >= mbrPoint2.row ? -1 :
|
|
|
13830
14217
|
* @returns The angle in degrees.
|
|
13831
14218
|
*/
|
|
13832
14219
|
function getMbrAngle(mbr) {
|
|
13833
|
-
const sorted = mbr.slice()
|
|
14220
|
+
const sorted = mbr.slice();
|
|
14221
|
+
sorted.sort(leftFirst);
|
|
13834
14222
|
const left = sorted.slice(0, 2);
|
|
13835
14223
|
const right = sorted.slice(2, 4);
|
|
13836
14224
|
left.sort(topFirst);
|
|
@@ -15015,7 +15403,7 @@ class Mask {
|
|
|
15015
15403
|
}
|
|
15016
15404
|
/**
|
|
15017
15405
|
* Get the number of pixels that do not have the value 0.
|
|
15018
|
-
* @returns
|
|
15406
|
+
* @returns The number of non-zero pixels.
|
|
15019
15407
|
*/
|
|
15020
15408
|
getNbNonZeroPixels() {
|
|
15021
15409
|
let count = 0;
|
|
@@ -16788,7 +17176,7 @@ class Image {
|
|
|
16788
17176
|
* @returns Coordinates of the point in the format [column, row].
|
|
16789
17177
|
*/
|
|
16790
17178
|
getCoordinates(coordinates, round = false) {
|
|
16791
|
-
return
|
|
17179
|
+
return M$2(coordinates).with('center', () => {
|
|
16792
17180
|
const centerX = (this.width - 1) / 2;
|
|
16793
17181
|
const centerY = (this.height - 1) / 2;
|
|
16794
17182
|
if (round) {
|
|
@@ -17207,7 +17595,7 @@ class Image {
|
|
|
17207
17595
|
*/
|
|
17208
17596
|
function createPixelArray(size, channels, alpha, bitDepth, maxValue) {
|
|
17209
17597
|
const length = channels * size;
|
|
17210
|
-
const arr =
|
|
17598
|
+
const arr = M$2(bitDepth).with(8, () => new Uint8Array(length)).with(16, () => new Uint16Array(length)).otherwise(() => {
|
|
17211
17599
|
throw new RangeError(`invalid bitDepth: ${bitDepth}`);
|
|
17212
17600
|
});
|
|
17213
17601
|
// Alpha channel is 100% by default.
|
|
@@ -17536,9 +17924,11 @@ function getMatchColor(matches, index, colors) {
|
|
|
17536
17924
|
* @returns Sorted copy of the array of matches.
|
|
17537
17925
|
*/
|
|
17538
17926
|
function sortByDistance(matches) {
|
|
17539
|
-
|
|
17927
|
+
const sorted = matches.slice();
|
|
17928
|
+
sorted.sort((match1, match2) => {
|
|
17540
17929
|
return match1.distance - match2.distance;
|
|
17541
17930
|
});
|
|
17931
|
+
return sorted;
|
|
17542
17932
|
}
|
|
17543
17933
|
|
|
17544
17934
|
/**
|
|
@@ -17797,7 +18187,8 @@ function filterEuclideanDistance(matches, sourceKeypoints, destinationKeypoints,
|
|
|
17797
18187
|
row: 0
|
|
17798
18188
|
}
|
|
17799
18189
|
} = options;
|
|
17800
|
-
const sorted = matches.
|
|
18190
|
+
const sorted = matches.slice();
|
|
18191
|
+
sorted.sort((a, b) => a.destinationIndex - b.destinationIndex);
|
|
17801
18192
|
const result = [];
|
|
17802
18193
|
let sameDestMatches = [];
|
|
17803
18194
|
let currentIndex = sorted[0].destinationIndex;
|
|
@@ -17805,12 +18196,14 @@ function filterEuclideanDistance(matches, sourceKeypoints, destinationKeypoints,
|
|
|
17805
18196
|
if (match.destinationIndex === currentIndex) {
|
|
17806
18197
|
sameDestMatches.push(match);
|
|
17807
18198
|
} else {
|
|
17808
|
-
|
|
18199
|
+
sameDestMatches.sort((a, b) => distanceSquared(a) - distanceSquared(b));
|
|
18200
|
+
result.push(...sameDestMatches.slice(0, 1));
|
|
17809
18201
|
currentIndex = match.destinationIndex;
|
|
17810
18202
|
sameDestMatches = [match];
|
|
17811
18203
|
}
|
|
17812
18204
|
}
|
|
17813
|
-
|
|
18205
|
+
sameDestMatches.sort((a, b) => distanceSquared(a) - distanceSquared(b));
|
|
18206
|
+
result.push(...sameDestMatches.slice(0, 1));
|
|
17814
18207
|
return result;
|
|
17815
18208
|
function distanceSquared(match) {
|
|
17816
18209
|
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;
|
|
@@ -17823,7 +18216,7 @@ function filterEuclideanDistance(matches, sourceKeypoints, destinationKeypoints,
|
|
|
17823
18216
|
* @param encoding - Text encoding
|
|
17824
18217
|
* @returns The decoded text
|
|
17825
18218
|
*/
|
|
17826
|
-
function decode$
|
|
18219
|
+
function decode$4(bytes, encoding = 'utf8') {
|
|
17827
18220
|
const decoder = new TextDecoder(encoding);
|
|
17828
18221
|
return decoder.decode(bytes);
|
|
17829
18222
|
}
|
|
@@ -18219,7 +18612,7 @@ class IOBuffer {
|
|
|
18219
18612
|
* @returns The decoded string.
|
|
18220
18613
|
*/
|
|
18221
18614
|
readUtf8(n = 1) {
|
|
18222
|
-
return decode$
|
|
18615
|
+
return decode$4(this.readBytes(n));
|
|
18223
18616
|
}
|
|
18224
18617
|
/**
|
|
18225
18618
|
* Read the next `n` bytes, return a string decoded with `encoding` and move pointer
|
|
@@ -18230,7 +18623,7 @@ class IOBuffer {
|
|
|
18230
18623
|
* @returns The decoded string.
|
|
18231
18624
|
*/
|
|
18232
18625
|
decodeText(n = 1, encoding = 'utf8') {
|
|
18233
|
-
return decode$
|
|
18626
|
+
return decode$4(this.readBytes(n), encoding);
|
|
18234
18627
|
}
|
|
18235
18628
|
/**
|
|
18236
18629
|
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
|
|
@@ -18451,6 +18844,117 @@ class IOBuffer {
|
|
|
18451
18844
|
}
|
|
18452
18845
|
}
|
|
18453
18846
|
|
|
18847
|
+
class BMPDecoder {
|
|
18848
|
+
bufferData;
|
|
18849
|
+
pixelDataOffset;
|
|
18850
|
+
width;
|
|
18851
|
+
height;
|
|
18852
|
+
bitsPerPixel;
|
|
18853
|
+
xPixelsPerMeter;
|
|
18854
|
+
yPixelsPerMeter;
|
|
18855
|
+
compression;
|
|
18856
|
+
colorMasks;
|
|
18857
|
+
constructor(bufferData) {
|
|
18858
|
+
this.bufferData = new IOBuffer(bufferData);
|
|
18859
|
+
const formatCheck = this.bufferData.readBytes(2);
|
|
18860
|
+
if (formatCheck[0] !== 0x42 && formatCheck[1] !== 0x4d) {
|
|
18861
|
+
throw new Error('This is not a BMP image or the encoding is not correct.');
|
|
18862
|
+
}
|
|
18863
|
+
this.pixelDataOffset = this.bufferData.skip(8).readUint32();
|
|
18864
|
+
this.width = this.bufferData.skip(4).readUint32();
|
|
18865
|
+
this.height = this.bufferData.readUint32();
|
|
18866
|
+
this.bitsPerPixel = this.bufferData.seek(28).readUint16();
|
|
18867
|
+
if (this.bitsPerPixel !== 1 && this.bitsPerPixel !== 8 && this.bitsPerPixel !== 24 && this.bitsPerPixel !== 32) {
|
|
18868
|
+
throw new Error(`Invalid number of bits per pixel. Supported number of bits per pixel: 1, 8, 24, 32. Received: ${this.bitsPerPixel}`);
|
|
18869
|
+
}
|
|
18870
|
+
this.compression = this.bufferData.readUint32();
|
|
18871
|
+
if (this.compression !== 0 && this.compression !== 3) {
|
|
18872
|
+
throw new Error(`Only BI_RGB and BI_BITFIELDS compression methods are allowed. `);
|
|
18873
|
+
}
|
|
18874
|
+
this.colorMasks = [this.bufferData.seek(54).readUint32(), this.bufferData.readUint32(), this.bufferData.readUint32()];
|
|
18875
|
+
if (this.bitsPerPixel === 32 && (this.colorMasks[0] !== 0x00ff0000 || this.colorMasks[1] !== 0x0000ff00 || this.colorMasks[2] !== 0x000000ff)) {
|
|
18876
|
+
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)}.`);
|
|
18877
|
+
}
|
|
18878
|
+
this.bufferData.skip(1); // skipping image size.
|
|
18879
|
+
this.xPixelsPerMeter = this.bufferData.seek(38).readInt32();
|
|
18880
|
+
this.yPixelsPerMeter = this.bufferData.readInt32();
|
|
18881
|
+
this.bufferData.skip(1);
|
|
18882
|
+
}
|
|
18883
|
+
decode() {
|
|
18884
|
+
this.bufferData.seek(this.pixelDataOffset);
|
|
18885
|
+
this.bufferData.setBigEndian();
|
|
18886
|
+
const channels = Math.ceil(this.bitsPerPixel / 8);
|
|
18887
|
+
const components = channels % 2 === 0 ? channels - 1 : channels;
|
|
18888
|
+
const data = this.decodePixelData(channels, components);
|
|
18889
|
+
return {
|
|
18890
|
+
width: this.width,
|
|
18891
|
+
height: this.height,
|
|
18892
|
+
bitsPerPixel: this.bitsPerPixel,
|
|
18893
|
+
compression: this.compression,
|
|
18894
|
+
colorMasks: this.colorMasks,
|
|
18895
|
+
channels,
|
|
18896
|
+
components,
|
|
18897
|
+
data,
|
|
18898
|
+
yPixelsPerMeter: this.yPixelsPerMeter,
|
|
18899
|
+
xPixelsPerMeter: this.xPixelsPerMeter
|
|
18900
|
+
};
|
|
18901
|
+
}
|
|
18902
|
+
decodePixelData(channels, components) {
|
|
18903
|
+
const data = new Uint8Array(this.height * this.width * channels);
|
|
18904
|
+
if (this.bitsPerPixel === 1) {
|
|
18905
|
+
this.decodeBitDepth1Pixels(data);
|
|
18906
|
+
} else if (channels === components) {
|
|
18907
|
+
this.decodeStandardPixels(data, channels);
|
|
18908
|
+
} else {
|
|
18909
|
+
this.decodePixelsWithAlpha(data, channels, components);
|
|
18910
|
+
}
|
|
18911
|
+
return data;
|
|
18912
|
+
}
|
|
18913
|
+
decodeBitDepth1Pixels(data) {
|
|
18914
|
+
let currentNumber = 0;
|
|
18915
|
+
for (let row = 0; row < this.height; row++) {
|
|
18916
|
+
for (let col = 0; col < this.width; col++) {
|
|
18917
|
+
const bitIndex = col % 32;
|
|
18918
|
+
if (bitIndex === 0) {
|
|
18919
|
+
currentNumber = this.bufferData.readUint32();
|
|
18920
|
+
}
|
|
18921
|
+
if (currentNumber & 1 << 31 - bitIndex) {
|
|
18922
|
+
data[(this.height - row - 1) * this.width + col] = 1;
|
|
18923
|
+
}
|
|
18924
|
+
}
|
|
18925
|
+
}
|
|
18926
|
+
}
|
|
18927
|
+
decodeStandardPixels(data, channels) {
|
|
18928
|
+
const padding = this.calculatePadding(channels);
|
|
18929
|
+
for (let row = 0; row < this.height; row++) {
|
|
18930
|
+
const rowOffset = (this.height - row - 1) * this.width;
|
|
18931
|
+
for (let col = 0; col < this.width; col++) {
|
|
18932
|
+
for (let channel = channels - 1; channel >= 0; channel--) {
|
|
18933
|
+
data[(rowOffset + col) * channels + channel] = this.bufferData.readByte();
|
|
18934
|
+
}
|
|
18935
|
+
}
|
|
18936
|
+
this.bufferData.skip(padding);
|
|
18937
|
+
}
|
|
18938
|
+
}
|
|
18939
|
+
decodePixelsWithAlpha(data, channels, components) {
|
|
18940
|
+
for (let row = 0; row < this.height; row++) {
|
|
18941
|
+
const rowOffset = (this.height - row - 1) * this.width;
|
|
18942
|
+
for (let col = 0; col < this.width; col++) {
|
|
18943
|
+
const pixelBaseIndex = (rowOffset + col) * channels;
|
|
18944
|
+
// Decode color components
|
|
18945
|
+
for (let component = components - 1; component >= 0; component--) {
|
|
18946
|
+
data[pixelBaseIndex + component] = this.bufferData.readByte();
|
|
18947
|
+
}
|
|
18948
|
+
// Decode alpha channel
|
|
18949
|
+
data[pixelBaseIndex + components] = this.bufferData.readByte();
|
|
18950
|
+
}
|
|
18951
|
+
}
|
|
18952
|
+
}
|
|
18953
|
+
calculatePadding(channels) {
|
|
18954
|
+
return this.width * channels % 4 === 0 ? 0 : 4 - this.width * channels % 4;
|
|
18955
|
+
}
|
|
18956
|
+
}
|
|
18957
|
+
|
|
18454
18958
|
const BITMAPV5HEADER = {
|
|
18455
18959
|
LogicalColorSpace: {
|
|
18456
18960
|
LCS_sRGB: 0x73524742},
|
|
@@ -18612,25 +19116,41 @@ function encode$2(data) {
|
|
|
18612
19116
|
const encoder = new BMPEncoder(data);
|
|
18613
19117
|
return encoder.encode();
|
|
18614
19118
|
}
|
|
19119
|
+
/**
|
|
19120
|
+
* Decodes BMP format image into data.
|
|
19121
|
+
* @param data - Buffer with image data.
|
|
19122
|
+
* @returns - Decoded data.
|
|
19123
|
+
*/
|
|
19124
|
+
function decode$3(data) {
|
|
19125
|
+
const decoder = new BMPDecoder(data);
|
|
19126
|
+
return decoder.decode();
|
|
19127
|
+
}
|
|
18615
19128
|
|
|
18616
19129
|
/**
|
|
18617
19130
|
* Creates a BMP buffer from a mask.
|
|
18618
|
-
* @param
|
|
19131
|
+
* @param image - The mask instance.
|
|
18619
19132
|
* @returns The buffer.
|
|
18620
19133
|
*/
|
|
18621
|
-
function encodeBmp(
|
|
18622
|
-
if (
|
|
18623
|
-
|
|
19134
|
+
function encodeBmp(image) {
|
|
19135
|
+
if (image instanceof Image) {
|
|
19136
|
+
return encode$2({
|
|
19137
|
+
width: image.width,
|
|
19138
|
+
height: image.height,
|
|
19139
|
+
components: image.components,
|
|
19140
|
+
bitsPerPixel: image.channels * image.bitDepth,
|
|
19141
|
+
channels: image.channels,
|
|
19142
|
+
data: image.getRawImage().data
|
|
19143
|
+
});
|
|
19144
|
+
} else {
|
|
19145
|
+
return encode$2({
|
|
19146
|
+
width: image.width,
|
|
19147
|
+
height: image.height,
|
|
19148
|
+
components: 1,
|
|
19149
|
+
bitsPerPixel: 1,
|
|
19150
|
+
channels: 1,
|
|
19151
|
+
data: image.getRawImage().data
|
|
19152
|
+
});
|
|
18624
19153
|
}
|
|
18625
|
-
const imageData = mask.getRawImage();
|
|
18626
|
-
return encode$2({
|
|
18627
|
-
width: imageData.width,
|
|
18628
|
-
height: imageData.height,
|
|
18629
|
-
components: 1,
|
|
18630
|
-
bitsPerPixel: 1,
|
|
18631
|
-
channels: 1,
|
|
18632
|
-
data: imageData.data
|
|
18633
|
-
});
|
|
18634
19154
|
}
|
|
18635
19155
|
|
|
18636
19156
|
var encoder = {exports: {}};
|
|
@@ -28097,6 +28617,10 @@ function encodePng$1(png, options) {
|
|
|
28097
28617
|
const encoder = new PngEncoder(png, options);
|
|
28098
28618
|
return encoder.encode();
|
|
28099
28619
|
}
|
|
28620
|
+
function decodeApng(data, options) {
|
|
28621
|
+
const decoder = new PngDecoder(data, options);
|
|
28622
|
+
return decoder.decodeApng();
|
|
28623
|
+
}
|
|
28100
28624
|
|
|
28101
28625
|
/**
|
|
28102
28626
|
* Creates a PNG buffer from an image.
|
|
@@ -28134,10 +28658,10 @@ const defaultPng = {
|
|
|
28134
28658
|
* @returns The encoded image.
|
|
28135
28659
|
*/
|
|
28136
28660
|
function encode(image, options = defaultPng) {
|
|
28137
|
-
return
|
|
28661
|
+
return M$2(options).with({
|
|
28138
28662
|
format: 'png'
|
|
28139
28663
|
}, options => encodePng(image, options.encoderOptions)).with({
|
|
28140
|
-
format:
|
|
28664
|
+
format: z.union('jpg', 'jpeg')
|
|
28141
28665
|
}, options => encodeJpeg(image, options.encoderOptions)).with({
|
|
28142
28666
|
format: 'bmp'
|
|
28143
28667
|
}, () => encodeBmp(image)).exhaustive();
|
|
@@ -28655,7 +29179,8 @@ function removeClosePoints(points, image, options) {
|
|
|
28655
29179
|
}
|
|
28656
29180
|
const channel = options?.channel || 0;
|
|
28657
29181
|
const isMax = kind === 'maximum';
|
|
28658
|
-
const sortedPoints = points.slice()
|
|
29182
|
+
const sortedPoints = points.slice();
|
|
29183
|
+
sortedPoints.sort(getSort(image, channel, isMax));
|
|
28659
29184
|
if (distance > 0) {
|
|
28660
29185
|
for (let i = 0; i < sortedPoints.length; i++) {
|
|
28661
29186
|
for (let j = i + 1; j < sortedPoints.length; j++) {
|
|
@@ -29656,6 +30181,38 @@ Object.defineProperty(imageType, 'minimumBytes', {
|
|
|
29656
30181
|
var imageTypeExports = imageType$2.exports;
|
|
29657
30182
|
var imageType$1 = /*@__PURE__*/getDefaultExportFromCjs(imageTypeExports);
|
|
29658
30183
|
|
|
30184
|
+
/**
|
|
30185
|
+
* Decode a BMP. See the fast-bmp npm module.
|
|
30186
|
+
* @param data - The data to decode.
|
|
30187
|
+
* @returns The decoded image or mask.
|
|
30188
|
+
*/
|
|
30189
|
+
function decodeBmp(data) {
|
|
30190
|
+
const decodedData = decode$3(data);
|
|
30191
|
+
if (decodedData.bitsPerPixel === 1) {
|
|
30192
|
+
const mask = new Mask(decodedData.width, decodedData.height, {
|
|
30193
|
+
data: decodedData.data
|
|
30194
|
+
});
|
|
30195
|
+
return mask.convertColor('GREY');
|
|
30196
|
+
} else {
|
|
30197
|
+
let colorModel;
|
|
30198
|
+
switch (decodedData.channels) {
|
|
30199
|
+
case 1:
|
|
30200
|
+
colorModel = 'GREY';
|
|
30201
|
+
break;
|
|
30202
|
+
case 3:
|
|
30203
|
+
colorModel = 'RGB';
|
|
30204
|
+
break;
|
|
30205
|
+
default:
|
|
30206
|
+
colorModel = 'RGBA';
|
|
30207
|
+
break;
|
|
30208
|
+
}
|
|
30209
|
+
return new Image(decodedData.width, decodedData.height, {
|
|
30210
|
+
colorModel,
|
|
30211
|
+
data: decodedData.data
|
|
30212
|
+
});
|
|
30213
|
+
}
|
|
30214
|
+
}
|
|
30215
|
+
|
|
29659
30216
|
const tagsById$2 = {
|
|
29660
30217
|
0x829a: 'ExposureTime',
|
|
29661
30218
|
0x829d: 'FNumber',
|
|
@@ -30374,7 +30931,7 @@ class TiffIfd extends IFD {
|
|
|
30374
30931
|
return this.get('SamplesPerPixel') || 1;
|
|
30375
30932
|
}
|
|
30376
30933
|
get rowsPerStrip() {
|
|
30377
|
-
return this.get('RowsPerStrip');
|
|
30934
|
+
return this.get('RowsPerStrip') || 2 ** 32 - 1;
|
|
30378
30935
|
}
|
|
30379
30936
|
get stripByteCounts() {
|
|
30380
30937
|
return alwaysArray(this.get('StripByteCounts'));
|
|
@@ -30928,10 +31485,16 @@ function decodeJpeg(buffer) {
|
|
|
30928
31485
|
function decodePng(buffer) {
|
|
30929
31486
|
const png = decodePng$1(buffer);
|
|
30930
31487
|
let colorModel;
|
|
30931
|
-
const bitDepth = png.depth
|
|
31488
|
+
const bitDepth = png.depth;
|
|
30932
31489
|
if (png.palette) {
|
|
30933
31490
|
return loadPalettePng(png);
|
|
30934
31491
|
}
|
|
31492
|
+
if (bitDepth === 1) {
|
|
31493
|
+
return new Image(png.width, png.height, {
|
|
31494
|
+
data: decodeBinary(png),
|
|
31495
|
+
colorModel: 'GREY'
|
|
31496
|
+
});
|
|
31497
|
+
}
|
|
30935
31498
|
switch (png.channels) {
|
|
30936
31499
|
case 1:
|
|
30937
31500
|
colorModel = 'GREY';
|
|
@@ -30962,7 +31525,7 @@ function decodePng(buffer) {
|
|
|
30962
31525
|
function loadPalettePng(png) {
|
|
30963
31526
|
assert(png.palette);
|
|
30964
31527
|
const pixels = png.width * png.height;
|
|
30965
|
-
const data = new Uint8Array(pixels *
|
|
31528
|
+
const data = new Uint8Array(pixels * png.palette[0].length);
|
|
30966
31529
|
const pixelsPerByte = 8 / png.depth;
|
|
30967
31530
|
const factor = png.depth < 8 ? pixelsPerByte : 1;
|
|
30968
31531
|
const mask = Number.parseInt('1'.repeat(png.depth), 2);
|
|
@@ -30974,14 +31537,32 @@ function loadPalettePng(png) {
|
|
|
30974
31537
|
value = value >>> png.depth * (pixelsPerByte - 1 - i % pixelsPerByte) & mask;
|
|
30975
31538
|
}
|
|
30976
31539
|
const paletteValue = png.palette[value];
|
|
30977
|
-
|
|
30978
|
-
|
|
30979
|
-
|
|
31540
|
+
for (const paletteChannel of paletteValue) {
|
|
31541
|
+
data[dataIndex++] = paletteChannel;
|
|
31542
|
+
}
|
|
30980
31543
|
}
|
|
30981
31544
|
return new Image(png.width, png.height, {
|
|
30982
|
-
data
|
|
31545
|
+
data,
|
|
31546
|
+
colorModel: png.palette[0].length === 4 ? 'RGBA' : 'RGB'
|
|
30983
31547
|
});
|
|
30984
31548
|
}
|
|
31549
|
+
function decodeBinary(png) {
|
|
31550
|
+
const totalPixels = png.width * png.height;
|
|
31551
|
+
const result = new Uint8Array(totalPixels);
|
|
31552
|
+
const pngData = png.data;
|
|
31553
|
+
const padding = png.width % 8;
|
|
31554
|
+
const bytesPerLine = Math.ceil(png.width / 8);
|
|
31555
|
+
let pixelIndex = 0;
|
|
31556
|
+
for (let byteIndex = 0; byteIndex < pngData.length && pixelIndex < totalPixels; byteIndex++) {
|
|
31557
|
+
const byte = pngData[byteIndex];
|
|
31558
|
+
const limit = byteIndex % bytesPerLine === 0 ? 8 - padding : 0;
|
|
31559
|
+
for (let bitIndex = 7; bitIndex >= limit && pixelIndex < totalPixels; bitIndex--) {
|
|
31560
|
+
const bit = byte >> bitIndex & 1;
|
|
31561
|
+
result[pixelIndex++] = bit * 255;
|
|
31562
|
+
}
|
|
31563
|
+
}
|
|
31564
|
+
return result;
|
|
31565
|
+
}
|
|
30985
31566
|
|
|
30986
31567
|
/**
|
|
30987
31568
|
* Decode a TIFF. See the tiff module.
|
|
@@ -30989,9 +31570,10 @@ function loadPalettePng(png) {
|
|
|
30989
31570
|
* @returns The decoded image.
|
|
30990
31571
|
*/
|
|
30991
31572
|
function decodeTiff(buffer) {
|
|
30992
|
-
const result = decodeTIFF(buffer
|
|
31573
|
+
const result = decodeTIFF(buffer, {
|
|
31574
|
+
pages: [0]
|
|
31575
|
+
});
|
|
30993
31576
|
return getImageFromIFD(result[0]);
|
|
30994
|
-
// TODO: optimize not to decode whole file
|
|
30995
31577
|
}
|
|
30996
31578
|
/**
|
|
30997
31579
|
* Create image from a single IFD.
|
|
@@ -30999,32 +31581,59 @@ function decodeTiff(buffer) {
|
|
|
30999
31581
|
* @returns The decoded image.
|
|
31000
31582
|
*/
|
|
31001
31583
|
function getImageFromIFD(ifd) {
|
|
31584
|
+
if (ifd.data instanceof Float32Array || ifd.data instanceof Float64Array) {
|
|
31585
|
+
throw new Error('Float TIFF data is not supported.');
|
|
31586
|
+
}
|
|
31002
31587
|
if (ifd.type === 3) {
|
|
31003
|
-
|
|
31004
|
-
const
|
|
31588
|
+
const hasAlpha = ifd.samplesPerPixel === 2;
|
|
31589
|
+
const pixelLength = hasAlpha ? 4 : 3;
|
|
31590
|
+
const data = new Uint16Array(pixelLength * ifd.width * ifd.height);
|
|
31005
31591
|
const palette = ifd.palette;
|
|
31006
31592
|
let ptr = 0;
|
|
31007
|
-
|
|
31008
|
-
|
|
31009
|
-
|
|
31010
|
-
|
|
31011
|
-
|
|
31593
|
+
if (hasAlpha) {
|
|
31594
|
+
for (let index = 0; index < ifd.data.length; index += ifd.samplesPerPixel) {
|
|
31595
|
+
const color = palette[ifd.data[index]];
|
|
31596
|
+
data[ptr++] = color[0];
|
|
31597
|
+
data[ptr++] = color[1];
|
|
31598
|
+
data[ptr++] = color[2];
|
|
31599
|
+
// To ensure that the value is 16 bits.
|
|
31600
|
+
data[ptr++] = Math.round(ifd.data[index + 1] / 2 ** ifd.bitsPerSample * 65535);
|
|
31601
|
+
}
|
|
31602
|
+
} else {
|
|
31603
|
+
for (let index = 0; index < ifd.data.length; index += ifd.samplesPerPixel) {
|
|
31604
|
+
const color = palette[ifd.data[index]];
|
|
31605
|
+
data[ptr++] = color[0];
|
|
31606
|
+
data[ptr++] = color[1];
|
|
31607
|
+
data[ptr++] = color[2];
|
|
31608
|
+
}
|
|
31012
31609
|
}
|
|
31013
31610
|
return new Image(ifd.width, ifd.height, {
|
|
31014
31611
|
data,
|
|
31015
|
-
|
|
31016
|
-
colorModel: ifd.alpha ? 'RGBA' : 'RGB',
|
|
31017
|
-
// TODO: handle other bit depths
|
|
31612
|
+
colorModel: hasAlpha ? 'RGBA' : 'RGB',
|
|
31018
31613
|
bitDepth: 16,
|
|
31019
31614
|
meta: getMetadata(ifd)
|
|
31020
31615
|
});
|
|
31616
|
+
} else if (ifd.type === 1 || ifd.type === 0) {
|
|
31617
|
+
if (ifd.bitsPerSample !== 1) {
|
|
31618
|
+
return new Image(ifd.width, ifd.height, {
|
|
31619
|
+
data: ifd.data,
|
|
31620
|
+
bitDepth: ifd.bitsPerSample,
|
|
31621
|
+
colorModel: ifd.alpha ? 'GREYA' : 'GREY',
|
|
31622
|
+
meta: getMetadata(ifd)
|
|
31623
|
+
});
|
|
31624
|
+
} else {
|
|
31625
|
+
return new Image(ifd.width, ifd.height, {
|
|
31626
|
+
data: ifd.data.map(pixel => pixel * 255),
|
|
31627
|
+
bitDepth: 8,
|
|
31628
|
+
colorModel: 'GREY',
|
|
31629
|
+
meta: getMetadata(ifd)
|
|
31630
|
+
});
|
|
31631
|
+
}
|
|
31021
31632
|
} else {
|
|
31022
31633
|
return new Image(ifd.width, ifd.height, {
|
|
31023
|
-
// TODO: handle float data
|
|
31024
|
-
// @ts-expect-error float data not handled yet
|
|
31025
31634
|
data: ifd.data,
|
|
31026
31635
|
bitDepth: ifd.bitsPerSample,
|
|
31027
|
-
colorModel: ifd.
|
|
31636
|
+
colorModel: ifd.alpha ? 'RGBA' : 'RGB',
|
|
31028
31637
|
meta: getMetadata(ifd)
|
|
31029
31638
|
});
|
|
31030
31639
|
}
|
|
@@ -31039,13 +31648,15 @@ function getImageFromIFD(ifd) {
|
|
|
31039
31648
|
function decode(data) {
|
|
31040
31649
|
const typedArray = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
31041
31650
|
const type = imageType$1(typedArray);
|
|
31042
|
-
return
|
|
31651
|
+
return M$2(type).with({
|
|
31043
31652
|
mime: 'image/png'
|
|
31044
31653
|
}, () => decodePng(typedArray)).with({
|
|
31045
31654
|
mime: 'image/jpeg'
|
|
31046
31655
|
}, () => decodeJpeg(typedArray)).with({
|
|
31047
31656
|
mime: 'image/tiff'
|
|
31048
|
-
}, () => decodeTiff(typedArray)).
|
|
31657
|
+
}, () => decodeTiff(typedArray)).with({
|
|
31658
|
+
mime: 'image/bmp'
|
|
31659
|
+
}, () => decodeBmp(typedArray)).otherwise(() => {
|
|
31049
31660
|
throw new RangeError(`invalid data format: ${type?.mime}`);
|
|
31050
31661
|
});
|
|
31051
31662
|
}
|
|
@@ -31217,7 +31828,7 @@ function getRainbowMap(options) {
|
|
|
31217
31828
|
} = options;
|
|
31218
31829
|
const colorMap = new Uint32Array(nbNegative + nbPositive + 1);
|
|
31219
31830
|
const hueRange = 360;
|
|
31220
|
-
const step =
|
|
31831
|
+
const step = M$2(roiKind).with('bw', () => hueRange / (nbNegative + nbPositive)).with('black', () => hueRange / nbNegative).with('white', () => hueRange / nbPositive).exhaustive();
|
|
31221
31832
|
// negative values
|
|
31222
31833
|
let hue = 0;
|
|
31223
31834
|
if (roiKind === 'bw' || roiKind === 'black') {
|
|
@@ -31287,7 +31898,7 @@ function getColorMap(options) {
|
|
|
31287
31898
|
roiKind: 'bw',
|
|
31288
31899
|
...options
|
|
31289
31900
|
};
|
|
31290
|
-
return
|
|
31901
|
+
return M$2(mode).with('binary', () => getBinaryMap(options)).with('saturation', () => getSaturationMap(options)).with('rainbow', () => getRainbowMap(options)).exhaustive();
|
|
31291
31902
|
}
|
|
31292
31903
|
|
|
31293
31904
|
const RoisColorMode = {
|
|
@@ -32102,7 +32713,7 @@ function getRois(roiMapManager, options = {}) {
|
|
|
32102
32713
|
if (roiMapManager.blackRois.length === 0 && roiMapManager.whiteRois.length === 0) {
|
|
32103
32714
|
computeRois(roiMapManager);
|
|
32104
32715
|
}
|
|
32105
|
-
const rois =
|
|
32716
|
+
const rois = M$2(kind).with('black', () => roiMapManager.blackRois).with('white', () => roiMapManager.whiteRois).with('bw', () => [...roiMapManager.whiteRois, ...roiMapManager.blackRois]).exhaustive();
|
|
32106
32717
|
return rois.filter(roi => roi.surface >= minSurface && roi.surface <= maxSurface);
|
|
32107
32718
|
}
|
|
32108
32719
|
|
|
@@ -32892,6 +33503,61 @@ function medianImage(stack) {
|
|
|
32892
33503
|
return result;
|
|
32893
33504
|
}
|
|
32894
33505
|
|
|
33506
|
+
/**
|
|
33507
|
+
* Decodes APNG image into a Stack
|
|
33508
|
+
* @param data - APNG data.
|
|
33509
|
+
* @returns stack of frames.
|
|
33510
|
+
*/
|
|
33511
|
+
function decodeStackFromApng(data) {
|
|
33512
|
+
const decodedApng = decodeApng(data);
|
|
33513
|
+
const images = [];
|
|
33514
|
+
let colorModel;
|
|
33515
|
+
switch (decodedApng.channels) {
|
|
33516
|
+
case 1:
|
|
33517
|
+
if (decodedApng.palette) {
|
|
33518
|
+
colorModel = decodedApng.palette[0].length === 3 ? 'RGB' : 'RGBA';
|
|
33519
|
+
} else {
|
|
33520
|
+
colorModel = 'GREY';
|
|
33521
|
+
}
|
|
33522
|
+
break;
|
|
33523
|
+
case 2:
|
|
33524
|
+
colorModel = 'GREYA';
|
|
33525
|
+
break;
|
|
33526
|
+
case 3:
|
|
33527
|
+
colorModel = 'RGB';
|
|
33528
|
+
break;
|
|
33529
|
+
default:
|
|
33530
|
+
colorModel = 'RGBA';
|
|
33531
|
+
break;
|
|
33532
|
+
}
|
|
33533
|
+
if (decodedApng.palette) {
|
|
33534
|
+
for (const image of decodedApng.frames) {
|
|
33535
|
+
images.push(new Image(decodedApng.width, decodedApng.height, {
|
|
33536
|
+
data: convertIndexedData(image.data, decodedApng.palette),
|
|
33537
|
+
colorModel
|
|
33538
|
+
}));
|
|
33539
|
+
}
|
|
33540
|
+
} else {
|
|
33541
|
+
for (const image of decodedApng.frames) {
|
|
33542
|
+
images.push(new Image(decodedApng.width, decodedApng.height, {
|
|
33543
|
+
data: image.data,
|
|
33544
|
+
colorModel
|
|
33545
|
+
}));
|
|
33546
|
+
}
|
|
33547
|
+
}
|
|
33548
|
+
const stack = new Stack(images);
|
|
33549
|
+
return stack;
|
|
33550
|
+
}
|
|
33551
|
+
function convertIndexedData(data, palette) {
|
|
33552
|
+
const result = new Uint8Array(data.length * palette[0].length);
|
|
33553
|
+
for (let i = 0; i < data.length; i++) {
|
|
33554
|
+
for (let channel = 0; channel < palette[0].length; channel++) {
|
|
33555
|
+
result[i * palette[0].length + channel] = palette[data[i]][channel];
|
|
33556
|
+
}
|
|
33557
|
+
}
|
|
33558
|
+
return result;
|
|
33559
|
+
}
|
|
33560
|
+
|
|
32895
33561
|
/**
|
|
32896
33562
|
* Decode a TIFF and create a stack of images.
|
|
32897
33563
|
* @param buffer - The data to decode.
|
|
@@ -32915,9 +33581,11 @@ function decodeStackFromTiff(buffer) {
|
|
|
32915
33581
|
function decodeStack(data) {
|
|
32916
33582
|
const typedArray = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
32917
33583
|
const type = imageType$1(typedArray);
|
|
32918
|
-
return
|
|
33584
|
+
return M$2(type).with({
|
|
32919
33585
|
mime: 'image/tiff'
|
|
32920
|
-
}, () => decodeStackFromTiff(typedArray)).
|
|
33586
|
+
}, () => decodeStackFromTiff(typedArray)).with({
|
|
33587
|
+
mime: 'image/png'
|
|
33588
|
+
}, () => decodeStackFromApng(typedArray)).otherwise(() => {
|
|
32921
33589
|
throw new RangeError(`invalid data format: ${type?.mime}`);
|
|
32922
33590
|
});
|
|
32923
33591
|
}
|