image-js 1.3.0 → 1.5.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 +1050 -6561
- 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 +1051 -6560
- 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 +53 -13
- package/lib/Image.d.ts +1 -1
- package/lib/Image.d.ts.map +1 -1
- package/lib/Image.js.map +1 -1
- package/lib/featureMatching/index.d.ts +2 -0
- package/lib/featureMatching/index.d.ts.map +1 -1
- package/lib/featureMatching/index.js +2 -0
- package/lib/featureMatching/index.js.map +1 -1
- package/lib/featureMatching/keypoints/getEigenvaluesForScore.d.ts +11 -0
- package/lib/featureMatching/keypoints/getEigenvaluesForScore.d.ts.map +1 -0
- package/lib/featureMatching/keypoints/getEigenvaluesForScore.js +43 -0
- package/lib/featureMatching/keypoints/getEigenvaluesForScore.js.map +1 -0
- package/lib/featureMatching/keypoints/getFastKeypoints.d.ts +3 -2
- package/lib/featureMatching/keypoints/getFastKeypoints.d.ts.map +1 -1
- package/lib/featureMatching/keypoints/getFastKeypoints.js +14 -7
- package/lib/featureMatching/keypoints/getFastKeypoints.js.map +1 -1
- package/lib/featureMatching/keypoints/getHarrisScore.d.ts +2 -2
- package/lib/featureMatching/keypoints/getHarrisScore.d.ts.map +1 -1
- package/lib/featureMatching/keypoints/getHarrisScore.js +5 -37
- package/lib/featureMatching/keypoints/getHarrisScore.js.map +1 -1
- package/lib/featureMatching/keypoints/getOrientedFastKeypoints.d.ts +1 -1
- package/lib/featureMatching/keypoints/getOrientedFastKeypoints.d.ts.map +1 -1
- package/lib/featureMatching/keypoints/getOrientedFastKeypoints.js.map +1 -1
- package/lib/featureMatching/keypoints/getShiTomasiScore.d.ts +24 -0
- package/lib/featureMatching/keypoints/getShiTomasiScore.d.ts.map +1 -0
- package/lib/featureMatching/keypoints/getShiTomasiScore.js +18 -0
- package/lib/featureMatching/keypoints/getShiTomasiScore.js.map +1 -0
- package/lib/featureMatching/visualize/Montage.d.ts.map +1 -1
- package/lib/featureMatching/visualize/Montage.js.map +1 -1
- package/lib/filters/convolution.d.ts +1 -1
- package/lib/filters/convolution.d.ts.map +1 -1
- package/lib/filters/convolution.js +6 -1
- package/lib/filters/convolution.js.map +1 -1
- package/lib/filters/derivativeFilter.d.ts.map +1 -1
- package/lib/filters/derivativeFilter.js.map +1 -1
- package/lib/filters/medianFilter.d.ts +5 -5
- package/lib/filters/medianFilter.d.ts.map +1 -1
- package/lib/filters/medianFilter.js +3 -2
- package/lib/filters/medianFilter.js.map +1 -1
- package/lib/geometry/resize.d.ts +1 -1
- package/lib/geometry/resize.d.ts.map +1 -1
- package/lib/geometry/transform.d.ts +1 -1
- package/lib/geometry/transform.d.ts.map +1 -1
- package/lib/geometry/transform.js +6 -1
- package/lib/geometry/transform.js.map +1 -1
- package/lib/operations/extendBorders.d.ts +1 -1
- package/lib/operations/extendBorders.d.ts.map +1 -1
- package/lib/operations/extendBorders.js +6 -1
- package/lib/operations/extendBorders.js.map +1 -1
- package/lib/operations/grey.d.ts.map +1 -1
- package/lib/operations/grey.js.map +1 -1
- package/lib/operations/threshold.d.ts.map +1 -1
- package/lib/operations/threshold.js.map +1 -1
- package/lib/roi/colorRois.d.ts.map +1 -1
- package/lib/roi/colorRois.js.map +1 -1
- package/lib/roi/getRois.d.ts.map +1 -1
- package/lib/roi/getRois.js.map +1 -1
- package/lib/save/encode.d.ts.map +1 -1
- package/lib/save/encode.js.map +1 -1
- package/lib/utils/constants/colorModels.d.ts.map +1 -1
- package/lib/utils/constants/colorModels.js.map +1 -1
- package/lib/utils/cross_platform.d.ts +2 -1
- package/lib/utils/cross_platform.d.ts.map +1 -1
- package/lib/utils/cross_platform.js +9 -1
- package/lib/utils/cross_platform.js.map +1 -1
- package/lib/utils/interpolateBorder.d.ts +1 -1
- package/lib/utils/interpolateBorder.d.ts.map +1 -1
- package/lib/utils/interpolateBorder.js +4 -1
- package/lib/utils/interpolateBorder.js.map +1 -1
- package/lib/utils/interpolatePixel.d.ts +1 -1
- package/lib/utils/interpolatePixel.d.ts.map +1 -1
- package/lib/utils/interpolatePixel.js.map +1 -1
- package/package.json +33 -30
- package/src/Image.ts +2 -2
- package/src/featureMatching/index.ts +2 -0
- package/src/featureMatching/keypoints/getEigenvaluesForScore.ts +56 -0
- package/src/featureMatching/keypoints/getFastKeypoints.ts +22 -15
- package/src/featureMatching/keypoints/getHarrisScore.ts +6 -45
- package/src/featureMatching/keypoints/getOrientedFastKeypoints.ts +2 -3
- package/src/featureMatching/keypoints/getShiTomasiScore.ts +36 -0
- package/src/featureMatching/visualize/Montage.ts +0 -1
- package/src/filters/convolution.ts +8 -2
- package/src/filters/derivativeFilter.ts +0 -1
- package/src/filters/medianFilter.ts +12 -10
- package/src/geometry/resize.ts +1 -1
- package/src/geometry/transform.ts +8 -2
- package/src/operations/extendBorders.ts +7 -2
- package/src/operations/grey.ts +0 -1
- package/src/operations/threshold.ts +0 -1
- package/src/roi/colorRois.ts +0 -1
- package/src/roi/getRois.ts +0 -1
- package/src/save/encode.ts +0 -1
- package/src/utils/constants/colorModels.ts +0 -1
- package/src/utils/cross_platform.ts +11 -1
- package/src/utils/interpolateBorder.ts +6 -4
- package/src/utils/interpolatePixel.ts +1 -2
package/src/roi/getRois.ts
CHANGED
package/src/save/encode.ts
CHANGED
|
@@ -24,6 +24,7 @@ let CanvasCtorNode: typeof SkiaCanvas;
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Returns a 2D canvas context for rendering on the browser or Node.js.
|
|
27
|
+
* On Node.js this requires the optional `skia-canvas` package to be installed.
|
|
27
28
|
* @param width - Width of the canvas.
|
|
28
29
|
* @param height - Height of the canvas.
|
|
29
30
|
* @returns The initialised canvas context.
|
|
@@ -33,7 +34,16 @@ export function getCanvasContext(
|
|
|
33
34
|
height: number,
|
|
34
35
|
): OffscreenCanvasRenderingContext2D | SkiaCanvasRenderingContext2D {
|
|
35
36
|
if (isNode()) {
|
|
36
|
-
|
|
37
|
+
if (!CanvasCtorNode) {
|
|
38
|
+
try {
|
|
39
|
+
CanvasCtorNode = getRequireFn()('skia-canvas').Canvas;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
'drawText on Node.js requires the optional "skia-canvas" package. Install it with: npm install skia-canvas',
|
|
43
|
+
{ cause: error },
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
37
47
|
return new CanvasCtorNode(width, height).getContext('2d');
|
|
38
48
|
} else {
|
|
39
49
|
CanvasCtorBrowser ??= globalThis.OffscreenCanvas;
|
|
@@ -11,7 +11,6 @@ export const BorderType = {
|
|
|
11
11
|
WRAP: 'wrap',
|
|
12
12
|
REFLECT_101: 'reflect101',
|
|
13
13
|
} as const;
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
15
14
|
export type BorderType = (typeof BorderType)[keyof typeof BorderType];
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -24,8 +23,11 @@ export type BorderType = (typeof BorderType)[keyof typeof BorderType];
|
|
|
24
23
|
*/
|
|
25
24
|
export function getBorderInterpolation(
|
|
26
25
|
type: BorderType,
|
|
27
|
-
value: number,
|
|
26
|
+
value: number | number[],
|
|
28
27
|
): BorderInterpolationFunction {
|
|
28
|
+
if (typeof value === 'number') {
|
|
29
|
+
value = new Array(4).fill(value);
|
|
30
|
+
}
|
|
29
31
|
return match(type)
|
|
30
32
|
.with('constant', () => getInterpolateConstant(value))
|
|
31
33
|
.with('replicate', () => interpolateReplicate)
|
|
@@ -41,7 +43,7 @@ function checkRange(point: number, length: number): void {
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
function getInterpolateConstant(value: number): BorderInterpolationFunction {
|
|
46
|
+
function getInterpolateConstant(value: number[]): BorderInterpolationFunction {
|
|
45
47
|
return function interpolateConstant(
|
|
46
48
|
column: number,
|
|
47
49
|
row: number,
|
|
@@ -51,7 +53,7 @@ function getInterpolateConstant(value: number): BorderInterpolationFunction {
|
|
|
51
53
|
const newColumn = interpolateConstantPoint(column, image.width);
|
|
52
54
|
const newRow = interpolateConstantPoint(row, image.height);
|
|
53
55
|
if (newColumn === -1 || newRow === -1) {
|
|
54
|
-
return value;
|
|
56
|
+
return value[channel];
|
|
55
57
|
}
|
|
56
58
|
return image.getValue(newColumn, newRow, channel);
|
|
57
59
|
};
|
|
@@ -13,7 +13,6 @@ export const InterpolationType = {
|
|
|
13
13
|
BILINEAR: 'bilinear',
|
|
14
14
|
BICUBIC: 'bicubic',
|
|
15
15
|
} as const;
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
17
16
|
export type InterpolationType =
|
|
18
17
|
(typeof InterpolationType)[keyof typeof InterpolationType];
|
|
19
18
|
|
|
@@ -22,7 +21,7 @@ type InterpolationFunction = (
|
|
|
22
21
|
column: number,
|
|
23
22
|
row: number,
|
|
24
23
|
channel: number,
|
|
25
|
-
|
|
24
|
+
interpolateBorder: BorderInterpolationFunction,
|
|
26
25
|
clamp: ClampFunction,
|
|
27
26
|
) => number;
|
|
28
27
|
|