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
|
@@ -6,7 +6,7 @@ export declare const InterpolationType: {
|
|
|
6
6
|
readonly BICUBIC: "bicubic";
|
|
7
7
|
};
|
|
8
8
|
export type InterpolationType = (typeof InterpolationType)[keyof typeof InterpolationType];
|
|
9
|
-
type InterpolationFunction = (image: Image, column: number, row: number, channel: number,
|
|
9
|
+
type InterpolationFunction = (image: Image, column: number, row: number, channel: number, interpolateBorder: BorderInterpolationFunction, clamp: ClampFunction) => number;
|
|
10
10
|
/**
|
|
11
11
|
* Get the interpolation function based on its name.
|
|
12
12
|
* @param interpolationType - Specified interpolation type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolatePixel.d.ts","sourceRoot":"","sources":["../../src/utils/interpolatePixel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,KAAK,EACV,2BAA2B,EAC3B,aAAa,EACd,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;
|
|
1
|
+
{"version":3,"file":"interpolatePixel.d.ts","sourceRoot":"","sources":["../../src/utils/interpolatePixel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,KAAK,EACV,2BAA2B,EAC3B,aAAa,EACd,MAAM,kBAAkB,CAAC;AAE1B,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC;AACX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D,KAAK,qBAAqB,GAAG,CAC3B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,2BAA2B,EAC9C,KAAK,EAAE,aAAa,KACjB,MAAM,CAAC;AAEZ;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,EAAE,iBAAiB,GACnC,qBAAqB,CAMvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interpolatePixel.js","sourceRoot":"","sources":["../../src/utils/interpolatePixel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAMnC,MAAM,CAAC,MAAM,iBAAiB,GAAG;I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AC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACxE,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Image processing and manipulation in JavaScript",
|
|
6
6
|
"author": "Michaël Zasso",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"./ssim": "./lib/extra/ssim/index.js"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
+
"allow-scripts": "allow-scripts run",
|
|
23
24
|
"api-extractor": "rimraf dist-types && api-extractor run --local",
|
|
24
25
|
"build": "npm run tsc && npm run cheminfo-build",
|
|
25
26
|
"check-types": "tsc --noEmit",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"colord": "^2.9.3",
|
|
42
43
|
"fast-bmp": "^4.0.1",
|
|
43
44
|
"fast-jpeg": "^3.0.1",
|
|
44
|
-
"fast-png": "^
|
|
45
|
+
"fast-png": "^8.0.0",
|
|
45
46
|
"image-type": "^4.1.0",
|
|
46
47
|
"jpeg-js": "^0.4.4",
|
|
47
48
|
"js-priority-queue": "^0.1.5",
|
|
@@ -52,14 +53,16 @@
|
|
|
52
53
|
"ml-ransac": "^1.0.0",
|
|
53
54
|
"ml-regression-multivariate-linear": "^2.0.4",
|
|
54
55
|
"ml-regression-polynomial-2d": "^1.0.0",
|
|
55
|
-
"ml-spectra-processing": "^14.18.
|
|
56
|
+
"ml-spectra-processing": "^14.18.2",
|
|
56
57
|
"robust-point-in-polygon": "^1.0.3",
|
|
57
|
-
"skia-canvas": "^3.0.8",
|
|
58
58
|
"ssim.js": "^3.5.0",
|
|
59
|
-
"tiff": "^7.1.
|
|
59
|
+
"tiff": "^7.1.3",
|
|
60
60
|
"ts-pattern": "^5.9.0",
|
|
61
61
|
"uint8-base64": "^1.0.0"
|
|
62
62
|
},
|
|
63
|
+
"optionalDependencies": {
|
|
64
|
+
"skia-canvas": "^3.0.8"
|
|
65
|
+
},
|
|
63
66
|
"lavamoat": {
|
|
64
67
|
"allowScripts": {
|
|
65
68
|
"@lavamoat/preinstall-always-fail": false,
|
|
@@ -68,42 +71,42 @@
|
|
|
68
71
|
}
|
|
69
72
|
},
|
|
70
73
|
"devDependencies": {
|
|
71
|
-
"@lavamoat/allow-scripts": "^3.4.
|
|
74
|
+
"@lavamoat/allow-scripts": "^3.4.1",
|
|
72
75
|
"@lavamoat/preinstall-always-fail": "^2.1.1",
|
|
73
|
-
"@microsoft/api-extractor": "^7.
|
|
74
|
-
"@tailwindcss/forms": "^0.5.
|
|
75
|
-
"@tailwindcss/vite": "^4.1.
|
|
76
|
+
"@microsoft/api-extractor": "^7.55.2",
|
|
77
|
+
"@tailwindcss/forms": "^0.5.11",
|
|
78
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
76
79
|
"@types/jest-image-snapshot": "^6.4.0",
|
|
77
80
|
"@types/js-priority-queue": "^0.0.9",
|
|
78
|
-
"@types/node": "^
|
|
79
|
-
"@types/react": "^19.2.
|
|
80
|
-
"@types/react-dom": "^19.2.
|
|
81
|
+
"@types/node": "^25.0.3",
|
|
82
|
+
"@types/react": "^19.2.7",
|
|
83
|
+
"@types/react-dom": "^19.2.3",
|
|
81
84
|
"@types/robust-point-in-polygon": "^1.0.4",
|
|
82
|
-
"@types/skia-canvas": "^0.9.
|
|
83
|
-
"@vitejs/plugin-react": "^5.1.
|
|
84
|
-
"@vitest/coverage-v8": "^4.0.
|
|
85
|
-
"@vitest/expect": "^4.0.
|
|
85
|
+
"@types/skia-canvas": "^0.9.28",
|
|
86
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
87
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
88
|
+
"@vitest/expect": "^4.0.16",
|
|
86
89
|
"@zakodium/tsconfig": "^1.0.2",
|
|
87
|
-
"autoprefixer": "^10.4.
|
|
88
|
-
"cheminfo-build": "^1.3.
|
|
90
|
+
"autoprefixer": "^10.4.23",
|
|
91
|
+
"cheminfo-build": "^1.3.2",
|
|
89
92
|
"clsx": "^2.1.1",
|
|
90
93
|
"cross-env": "^10.1.0",
|
|
91
|
-
"eslint": "^9.
|
|
92
|
-
"eslint-config-cheminfo-react": "^
|
|
93
|
-
"eslint-config-cheminfo-typescript": "^
|
|
94
|
-
"immer": "^
|
|
94
|
+
"eslint": "^9.39.2",
|
|
95
|
+
"eslint-config-cheminfo-react": "^19.0.0",
|
|
96
|
+
"eslint-config-cheminfo-typescript": "^21.0.1",
|
|
97
|
+
"immer": "^11.0.1",
|
|
95
98
|
"jest-image-snapshot": "^6.5.1",
|
|
96
99
|
"jest-matcher-deep-close-to": "^3.0.2",
|
|
97
100
|
"postcss": "^8.5.6",
|
|
98
|
-
"prettier": "^3.
|
|
99
|
-
"react": "^19.2.
|
|
100
|
-
"react-dom": "^19.2.
|
|
101
|
-
"react-router-dom": "^7.
|
|
102
|
-
"rimraf": "^6.1.
|
|
103
|
-
"tailwindcss": "^4.1.
|
|
101
|
+
"prettier": "^3.7.4",
|
|
102
|
+
"react": "^19.2.3",
|
|
103
|
+
"react-dom": "^19.2.3",
|
|
104
|
+
"react-router-dom": "^7.11.0",
|
|
105
|
+
"rimraf": "^6.1.2",
|
|
106
|
+
"tailwindcss": "^4.1.18",
|
|
104
107
|
"typescript": "~5.9.3",
|
|
105
|
-
"vite": "^7.
|
|
106
|
-
"vitest": "^4.0.
|
|
108
|
+
"vite": "^7.3.0",
|
|
109
|
+
"vitest": "^4.0.16"
|
|
107
110
|
},
|
|
108
111
|
"repository": {
|
|
109
112
|
"type": "git",
|
package/src/Image.ts
CHANGED
|
@@ -146,7 +146,6 @@ export const ImageCoordinates = {
|
|
|
146
146
|
BOTTOM_LEFT: 'bottom-left',
|
|
147
147
|
BOTTOM_RIGHT: 'bottom-right',
|
|
148
148
|
} as const;
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
150
149
|
export type ImageCoordinates =
|
|
151
150
|
(typeof ImageCoordinates)[keyof typeof ImageCoordinates];
|
|
152
151
|
|
|
@@ -1087,12 +1086,13 @@ export class Image {
|
|
|
1087
1086
|
): Image {
|
|
1088
1087
|
return correctColor(this, measuredColors, referenceColors);
|
|
1089
1088
|
}
|
|
1089
|
+
|
|
1090
1090
|
/**
|
|
1091
1091
|
* Apply a median filter to the image.
|
|
1092
1092
|
* @param options - Options to apply for median filter.
|
|
1093
1093
|
* @returns Image after median filter.
|
|
1094
1094
|
*/
|
|
1095
|
-
public medianFilter(options
|
|
1095
|
+
public medianFilter(options?: MedianFilterOptions) {
|
|
1096
1096
|
return medianFilter(this, options);
|
|
1097
1097
|
}
|
|
1098
1098
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './descriptors/getBriefDescriptors.js';
|
|
2
2
|
export * from './featureMatching.types.js';
|
|
3
|
+
export * from './keypoints/getHarrisScore.js';
|
|
4
|
+
export * from './keypoints/getShiTomasiScore.js';
|
|
3
5
|
export * from './keypoints/getFastKeypoints.js';
|
|
4
6
|
export * from './keypoints/getIntensityCentroid.js';
|
|
5
7
|
export * from './keypoints/getOrientedFastKeypoints.js';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { EigenvalueDecomposition, Matrix, WrapperMatrix1D } from 'ml-matrix';
|
|
2
|
+
|
|
3
|
+
import type { Image } from '../../Image.ts';
|
|
4
|
+
import type { Point } from '../../index_full.ts';
|
|
5
|
+
import { SOBEL_X, SOBEL_Y } from '../../utils/constants/kernels.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A function that calculates eigenvalues to calculate feature score for Harris and Shi-Tomasi algorithms.
|
|
9
|
+
* @param image - Image take data from.
|
|
10
|
+
* @param origin - Center of the window, where the corner should be.
|
|
11
|
+
* @param windowSize - Size of the window, where data should be scanned.
|
|
12
|
+
* @returns Array of two eigenvalues.
|
|
13
|
+
*/
|
|
14
|
+
export function getEigenvaluesForScore(
|
|
15
|
+
image: Image,
|
|
16
|
+
origin: Point,
|
|
17
|
+
windowSize = 7,
|
|
18
|
+
) {
|
|
19
|
+
if (!(windowSize % 2)) {
|
|
20
|
+
throw new TypeError('windowSize must be an odd integer');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const cropOrigin = {
|
|
24
|
+
row: origin.row - (windowSize - 1) / 2,
|
|
25
|
+
column: origin.column - (windowSize - 1) / 2,
|
|
26
|
+
};
|
|
27
|
+
const window = image.crop({
|
|
28
|
+
origin: cropOrigin,
|
|
29
|
+
width: windowSize,
|
|
30
|
+
height: windowSize,
|
|
31
|
+
});
|
|
32
|
+
const xDerivative = window.gradientFilter({ kernelX: SOBEL_X });
|
|
33
|
+
const yDerivative = window.gradientFilter({ kernelY: SOBEL_Y });
|
|
34
|
+
|
|
35
|
+
const xMatrix = new WrapperMatrix1D(xDerivative.getRawImage().data, {
|
|
36
|
+
rows: xDerivative.height,
|
|
37
|
+
});
|
|
38
|
+
const yMatrix = new WrapperMatrix1D(yDerivative.getRawImage().data, {
|
|
39
|
+
rows: yDerivative.height,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const xx = xMatrix.mmul(xMatrix);
|
|
43
|
+
const xy = yMatrix.mmul(xMatrix);
|
|
44
|
+
const yy = yMatrix.mmul(yMatrix);
|
|
45
|
+
|
|
46
|
+
const xxSum = xx.sum();
|
|
47
|
+
const xySum = xy.sum();
|
|
48
|
+
const yySum = yy.sum();
|
|
49
|
+
|
|
50
|
+
const structureTensor = new Matrix([
|
|
51
|
+
[xxSum, xySum],
|
|
52
|
+
[xySum, yySum],
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
return new EigenvalueDecomposition(structureTensor).realEigenvalues;
|
|
56
|
+
}
|
|
@@ -13,6 +13,8 @@ import type { GetHarrisScoreOptions } from '../featureMatching.types.js';
|
|
|
13
13
|
|
|
14
14
|
import { getFastScore } from './getFastScore.js';
|
|
15
15
|
import { getHarrisScore } from './getHarrisScore.js';
|
|
16
|
+
import type { GetShiTomasiScoreOptions } from './getShiTomasiScore.ts';
|
|
17
|
+
import { getShiTomasiScore } from './getShiTomasiScore.ts';
|
|
16
18
|
import type { IsFastKeypointOptions } from './isFastKeypoint.js';
|
|
17
19
|
import { isFastKeypoint } from './isFastKeypoint.js';
|
|
18
20
|
|
|
@@ -38,11 +40,11 @@ export interface GetFastKeypointsOptions extends IsFastKeypointOptions {
|
|
|
38
40
|
* Algorithm to use to compute corners score.
|
|
39
41
|
* @default `'FAST'`
|
|
40
42
|
*/
|
|
41
|
-
scoreAlgorithm?: 'HARRIS' | 'FAST';
|
|
43
|
+
scoreAlgorithm?: 'HARRIS' | 'FAST' | 'TOMASI';
|
|
42
44
|
/**
|
|
43
45
|
* Options for the Harris score computation.
|
|
44
46
|
*/
|
|
45
|
-
|
|
47
|
+
scoreOptions?: GetHarrisScoreOptions | GetShiTomasiScoreOptions;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
export interface FastKeypoint {
|
|
@@ -69,11 +71,7 @@ export function getFastKeypoints(
|
|
|
69
71
|
image: Image,
|
|
70
72
|
options: GetFastKeypointsOptions = {},
|
|
71
73
|
): FastKeypoint[] {
|
|
72
|
-
const {
|
|
73
|
-
fastRadius = 3,
|
|
74
|
-
scoreAlgorithm = 'FAST',
|
|
75
|
-
harrisScoreOptions,
|
|
76
|
-
} = options;
|
|
74
|
+
const { fastRadius = 3, scoreAlgorithm = 'FAST', scoreOptions } = options;
|
|
77
75
|
|
|
78
76
|
const circlePoints = getCirclePoints(fastRadius);
|
|
79
77
|
const compassPoints = getCompassPoints(fastRadius);
|
|
@@ -90,15 +88,24 @@ export function getFastKeypoints(
|
|
|
90
88
|
alpha: false,
|
|
91
89
|
});
|
|
92
90
|
|
|
91
|
+
function harrisScore(image: Image, corner: Point) {
|
|
92
|
+
return getHarrisScore(image, corner, scoreOptions as GetHarrisScoreOptions);
|
|
93
|
+
}
|
|
94
|
+
function fastScore(image: Image, corner: Point) {
|
|
95
|
+
return getFastScore(image, corner, threshold, circlePoints);
|
|
96
|
+
}
|
|
97
|
+
function tomasiScore(image: Image, corner: Point) {
|
|
98
|
+
return getShiTomasiScore(
|
|
99
|
+
image,
|
|
100
|
+
corner,
|
|
101
|
+
scoreOptions as GetShiTomasiScoreOptions,
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
|
|
93
105
|
const getScore = match(scoreAlgorithm)
|
|
94
|
-
.with('HARRIS', () =>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})
|
|
98
|
-
.with('FAST', () => {
|
|
99
|
-
return (image: Image, corner: Point) =>
|
|
100
|
-
getFastScore(image, corner, threshold, circlePoints);
|
|
101
|
-
})
|
|
106
|
+
.with('HARRIS', () => harrisScore)
|
|
107
|
+
.with('FAST', () => fastScore)
|
|
108
|
+
.with('TOMASI', () => tomasiScore)
|
|
102
109
|
.exhaustive();
|
|
103
110
|
|
|
104
111
|
const allKeypoints: FastKeypoint[] = [];
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { EigenvalueDecomposition, Matrix, WrapperMatrix1D } from 'ml-matrix';
|
|
2
|
-
|
|
3
1
|
import type { Image } from '../../Image.js';
|
|
4
2
|
import type { Point } from '../../geometry/index.js';
|
|
5
|
-
import { SOBEL_X, SOBEL_Y } from '../../utils/constants/kernels.js';
|
|
6
3
|
import type { GetHarrisScoreOptions } from '../featureMatching.types.js';
|
|
7
4
|
|
|
5
|
+
import { getEigenvaluesForScore } from './getEigenvaluesForScore.js';
|
|
6
|
+
|
|
8
7
|
/**
|
|
9
8
|
* Get the Harris score of a corner. The idea behind the algorithm is that a
|
|
10
|
-
* slight shift of a window around a corner along x and y
|
|
9
|
+
* slight shift of a window around a corner along x and y should result in
|
|
11
10
|
* a very different image.
|
|
12
11
|
*
|
|
13
12
|
* We distinguish 3 cases:
|
|
14
13
|
* - the score is highly negative: you have an edge
|
|
15
|
-
* - the
|
|
14
|
+
* - the absolute value of the score is small: the region is flat
|
|
16
15
|
* - the score is highly positive: you have a corner.
|
|
17
16
|
* @see {@link https://en.wikipedia.org/wiki/Harris_corner_detector}
|
|
18
17
|
* @param image - Image to which the corner belongs. It must be a greyscale image with only one channel.
|
|
@@ -25,46 +24,8 @@ export function getHarrisScore(
|
|
|
25
24
|
origin: Point,
|
|
26
25
|
options: GetHarrisScoreOptions = {},
|
|
27
26
|
): number {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
if (!(windowSize % 2)) {
|
|
31
|
-
throw new TypeError('windowSize must be an odd integer');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const cropOrigin = {
|
|
35
|
-
row: origin.row - (windowSize - 1) / 2,
|
|
36
|
-
column: origin.column - (windowSize - 1) / 2,
|
|
37
|
-
};
|
|
38
|
-
const window = image.crop({
|
|
39
|
-
origin: cropOrigin,
|
|
40
|
-
width: windowSize,
|
|
41
|
-
height: windowSize,
|
|
42
|
-
});
|
|
43
|
-
const xDerivative = window.gradientFilter({ kernelX: SOBEL_X });
|
|
44
|
-
const yDerivative = window.gradientFilter({ kernelY: SOBEL_Y });
|
|
45
|
-
|
|
46
|
-
const xMatrix = new WrapperMatrix1D(xDerivative.getRawImage().data, {
|
|
47
|
-
rows: xDerivative.height,
|
|
48
|
-
});
|
|
49
|
-
const yMatrix = new WrapperMatrix1D(yDerivative.getRawImage().data, {
|
|
50
|
-
rows: yDerivative.height,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const xx = xMatrix.mmul(xMatrix);
|
|
54
|
-
const xy = yMatrix.mmul(xMatrix);
|
|
55
|
-
const yy = yMatrix.mmul(yMatrix);
|
|
56
|
-
|
|
57
|
-
const xxSum = xx.sum();
|
|
58
|
-
const xySum = xy.sum();
|
|
59
|
-
const yySum = yy.sum();
|
|
60
|
-
|
|
61
|
-
const structureTensor = new Matrix([
|
|
62
|
-
[xxSum, xySum],
|
|
63
|
-
[xySum, yySum],
|
|
64
|
-
]);
|
|
65
|
-
|
|
66
|
-
const eigenValues = new EigenvalueDecomposition(structureTensor)
|
|
67
|
-
.realEigenvalues;
|
|
27
|
+
const { harrisConstant = 0.04, windowSize } = options;
|
|
28
|
+
const eigenValues = getEigenvaluesForScore(image, origin, windowSize);
|
|
68
29
|
|
|
69
30
|
return (
|
|
70
31
|
eigenValues[0] * eigenValues[1] -
|
|
@@ -11,10 +11,9 @@ import type {
|
|
|
11
11
|
import { getFastKeypoints } from './getFastKeypoints.js';
|
|
12
12
|
import { getPatchIntensityCentroid } from './getPatchIntensityCentroid.js';
|
|
13
13
|
|
|
14
|
-
export interface GetOrientedFastKeypointsOptions
|
|
15
|
-
extends GetFastKeypointsOptions {
|
|
14
|
+
export interface GetOrientedFastKeypointsOptions extends GetFastKeypointsOptions {
|
|
16
15
|
/**
|
|
17
|
-
* Diameter of the circle used for
|
|
16
|
+
* Diameter of the circle used for computation of the intensity centroid.
|
|
18
17
|
* @default `7`
|
|
19
18
|
*/
|
|
20
19
|
centroidPatchDiameter?: number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Image } from '../../Image.ts';
|
|
2
|
+
import type { Point } from '../../index_full.ts';
|
|
3
|
+
|
|
4
|
+
import { getEigenvaluesForScore } from './getEigenvaluesForScore.js';
|
|
5
|
+
|
|
6
|
+
export interface GetShiTomasiScoreOptions {
|
|
7
|
+
qualityLevel?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Size of the window to compute the Harris score.
|
|
10
|
+
* Should be an odd number so that the window can be centered on the corner.
|
|
11
|
+
* @default `7`
|
|
12
|
+
*/
|
|
13
|
+
windowSize?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get the Shi-Tomasi score of a corner. The idea is similar to Harris score, but it removes constant to calculate the score and just takes the minimum from two eigenvalues.
|
|
18
|
+
* We distinguish 3 cases:
|
|
19
|
+
* - the score is highly negative: you have an edge
|
|
20
|
+
* - the absolute value of the score is small: the region is flat
|
|
21
|
+
* - the score is highly positive: you have a corner.
|
|
22
|
+
* @param image - Image to which the corner belongs. It must be a greyscale image with only one channel.
|
|
23
|
+
* @param origin - Center of the window, where the corner should be.
|
|
24
|
+
* @param options - Get Shi-Tomasi score options.
|
|
25
|
+
* @returns The Shi-Tomasi score.
|
|
26
|
+
*/
|
|
27
|
+
export function getShiTomasiScore(
|
|
28
|
+
image: Image,
|
|
29
|
+
origin: Point,
|
|
30
|
+
options: GetShiTomasiScoreOptions = {},
|
|
31
|
+
): number {
|
|
32
|
+
const { windowSize = 7 } = options;
|
|
33
|
+
|
|
34
|
+
const eigenValues = getEigenvaluesForScore(image, origin, windowSize);
|
|
35
|
+
return Math.min(eigenValues[0], eigenValues[1]);
|
|
36
|
+
}
|
|
@@ -13,7 +13,6 @@ export const MontageDisposition = {
|
|
|
13
13
|
HORIZONTAL: 'horizontal',
|
|
14
14
|
VERTICAL: 'vertical',
|
|
15
15
|
} as const;
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
17
16
|
export type MontageDisposition =
|
|
18
17
|
(typeof MontageDisposition)[keyof typeof MontageDisposition];
|
|
19
18
|
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { Image } from '../Image.js';
|
|
7
7
|
import { extendBorders } from '../operations/extendBorders.js';
|
|
8
8
|
import { getClamp } from '../utils/clamp.js';
|
|
9
|
+
import { getDefaultColor } from '../utils/getDefaultColor.ts';
|
|
9
10
|
import { getIndex } from '../utils/getIndex.js';
|
|
10
11
|
import { getOutputImage } from '../utils/getOutputImage.js';
|
|
11
12
|
import type { BorderType } from '../utils/interpolateBorder.js';
|
|
@@ -15,6 +16,7 @@ import type {
|
|
|
15
16
|
BorderInterpolationFunction,
|
|
16
17
|
ClampFunction,
|
|
17
18
|
} from '../utils/utils.types.js';
|
|
19
|
+
import { validateColor } from '../utils/validators/validators.ts';
|
|
18
20
|
|
|
19
21
|
export interface ConvolutionOptions {
|
|
20
22
|
/**
|
|
@@ -26,7 +28,7 @@ export interface ConvolutionOptions {
|
|
|
26
28
|
* Value of the border if BorderType is 'constant'.
|
|
27
29
|
* @default `0`
|
|
28
30
|
*/
|
|
29
|
-
borderValue?: number;
|
|
31
|
+
borderValue?: number | number[];
|
|
30
32
|
/**
|
|
31
33
|
* Whether the kernel should be normalized.
|
|
32
34
|
* @default `false`
|
|
@@ -83,7 +85,11 @@ export function rawDirectConvolution(
|
|
|
83
85
|
kernel: number[][],
|
|
84
86
|
options: ConvolutionOptions = {},
|
|
85
87
|
): Float64Array {
|
|
86
|
-
const { borderType = 'reflect101', borderValue =
|
|
88
|
+
const { borderType = 'reflect101', borderValue = getDefaultColor(image) } =
|
|
89
|
+
options;
|
|
90
|
+
if (Array.isArray(borderValue)) {
|
|
91
|
+
validateColor(borderValue, image);
|
|
92
|
+
}
|
|
87
93
|
const interpolateBorder = getBorderInterpolation(borderType, borderValue);
|
|
88
94
|
|
|
89
95
|
const result = new Float64Array(image.size * image.channels);
|
|
@@ -19,7 +19,6 @@ export const DerivativeFilter = {
|
|
|
19
19
|
// for 2x2 matrices, the current pixel corresponds to the top-left
|
|
20
20
|
// ROBERTS = 'roberts',
|
|
21
21
|
} as const;
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
23
22
|
export type DerivativeFilter =
|
|
24
23
|
(typeof DerivativeFilter)[keyof typeof DerivativeFilter];
|
|
25
24
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { xMedian } from 'ml-spectra-processing';
|
|
2
2
|
|
|
3
3
|
import { Image } from '../Image.js';
|
|
4
|
+
import { getDefaultColor } from '../utils/getDefaultColor.ts';
|
|
4
5
|
import type { BorderType } from '../utils/interpolateBorder.js';
|
|
5
6
|
import { getBorderInterpolation } from '../utils/interpolateBorder.js';
|
|
6
7
|
import checkProcessable from '../utils/validators/checkProcessable.js';
|
|
@@ -10,16 +11,16 @@ export interface MedianFilterOptions {
|
|
|
10
11
|
* Type of border algorithm to interpolate from.
|
|
11
12
|
* @default `'reflect101'`
|
|
12
13
|
*/
|
|
13
|
-
borderType
|
|
14
|
+
borderType?: BorderType;
|
|
14
15
|
/**
|
|
15
16
|
* Value of border.
|
|
16
17
|
*/
|
|
17
|
-
borderValue?: number;
|
|
18
|
+
borderValue?: number | number[];
|
|
18
19
|
/**
|
|
19
20
|
* The radius of the cell to extract median value from. Must be odd.
|
|
20
|
-
* @default `
|
|
21
|
+
* @default `3`
|
|
21
22
|
*/
|
|
22
|
-
cellSize
|
|
23
|
+
cellSize?: number;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Calculate a new image that replaces all pixel values by the median of neighbouring pixels.
|
|
@@ -27,8 +28,12 @@ export interface MedianFilterOptions {
|
|
|
27
28
|
* @param options - MedianFilterOptions
|
|
28
29
|
* @returns Image after median filter.
|
|
29
30
|
*/
|
|
30
|
-
export function medianFilter(image: Image, options: MedianFilterOptions) {
|
|
31
|
-
const {
|
|
31
|
+
export function medianFilter(image: Image, options: MedianFilterOptions = {}) {
|
|
32
|
+
const {
|
|
33
|
+
cellSize = 3,
|
|
34
|
+
borderType = 'reflect101',
|
|
35
|
+
borderValue = getDefaultColor(image),
|
|
36
|
+
} = options;
|
|
32
37
|
|
|
33
38
|
checkProcessable(image, {
|
|
34
39
|
bitDepth: [8, 16],
|
|
@@ -46,10 +51,7 @@ export function medianFilter(image: Image, options: MedianFilterOptions) {
|
|
|
46
51
|
);
|
|
47
52
|
}
|
|
48
53
|
|
|
49
|
-
const interpolateBorder = getBorderInterpolation(
|
|
50
|
-
borderType,
|
|
51
|
-
borderValue as number,
|
|
52
|
-
);
|
|
54
|
+
const interpolateBorder = getBorderInterpolation(borderType, borderValue);
|
|
53
55
|
|
|
54
56
|
const newImage = Image.createFrom(image);
|
|
55
57
|
const size = cellSize ** 2;
|
package/src/geometry/resize.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { Matrix, inverse } from 'ml-matrix';
|
|
|
2
2
|
|
|
3
3
|
import { Image } from '../Image.js';
|
|
4
4
|
import { getClamp } from '../utils/clamp.js';
|
|
5
|
+
import { getDefaultColor } from '../utils/getDefaultColor.ts';
|
|
5
6
|
import type { BorderType } from '../utils/interpolateBorder.js';
|
|
6
7
|
import { getBorderInterpolation } from '../utils/interpolateBorder.js';
|
|
7
8
|
import type { InterpolationType } from '../utils/interpolatePixel.js';
|
|
8
9
|
import { getInterpolationFunction } from '../utils/interpolatePixel.js';
|
|
10
|
+
import { validateColor } from '../utils/validators/validators.ts';
|
|
9
11
|
|
|
10
12
|
export interface TransformOptions {
|
|
11
13
|
/**
|
|
@@ -31,7 +33,7 @@ export interface TransformOptions {
|
|
|
31
33
|
* Value of the border if BorderType is 'constant'.
|
|
32
34
|
* @default `0`
|
|
33
35
|
*/
|
|
34
|
-
borderValue?: number;
|
|
36
|
+
borderValue?: number | number[];
|
|
35
37
|
/**
|
|
36
38
|
* Whether the transform matrix should be inverted.
|
|
37
39
|
*/
|
|
@@ -56,13 +58,17 @@ export function transform(
|
|
|
56
58
|
options: TransformOptions = {},
|
|
57
59
|
): Image {
|
|
58
60
|
const {
|
|
61
|
+
borderValue = getDefaultColor(image),
|
|
59
62
|
borderType = 'constant',
|
|
60
|
-
borderValue = 0,
|
|
61
63
|
interpolationType = 'bilinear',
|
|
62
64
|
fullImage,
|
|
63
65
|
} = options;
|
|
64
66
|
let { width = image.width, height = image.height } = options;
|
|
65
67
|
|
|
68
|
+
if (Array.isArray(borderValue)) {
|
|
69
|
+
validateColor(borderValue, image);
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
if (!isValidMatrix(transformMatrix)) {
|
|
67
73
|
throw new TypeError(
|
|
68
74
|
`transformation matrix must be 2x3 or 3x3. Received ${transformMatrix.length}x${transformMatrix[1].length}`,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Image } from '../Image.js';
|
|
2
|
+
import { getDefaultColor } from '../utils/getDefaultColor.ts';
|
|
2
3
|
import type { BorderType } from '../utils/interpolateBorder.js';
|
|
3
4
|
import { getBorderInterpolation } from '../utils/interpolateBorder.js';
|
|
5
|
+
import { validateColor } from '../utils/validators/validators.ts';
|
|
4
6
|
|
|
5
7
|
export interface ExtendBordersOptions {
|
|
6
8
|
/**
|
|
@@ -20,7 +22,7 @@ export interface ExtendBordersOptions {
|
|
|
20
22
|
* Value of the border if BorderType is 'constant'.
|
|
21
23
|
* @default `0`
|
|
22
24
|
*/
|
|
23
|
-
borderValue?: number;
|
|
25
|
+
borderValue?: number | number[];
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
/**
|
|
@@ -37,9 +39,12 @@ export function extendBorders(
|
|
|
37
39
|
horizontal,
|
|
38
40
|
vertical,
|
|
39
41
|
borderType = 'reflect101',
|
|
40
|
-
borderValue =
|
|
42
|
+
borderValue = getDefaultColor(image),
|
|
41
43
|
} = options;
|
|
42
44
|
|
|
45
|
+
if (Array.isArray(borderValue)) {
|
|
46
|
+
validateColor(borderValue, image);
|
|
47
|
+
}
|
|
43
48
|
const interpolateBorder = getBorderInterpolation(borderType, borderValue);
|
|
44
49
|
|
|
45
50
|
const newImage = Image.createFrom(image, {
|
package/src/operations/grey.ts
CHANGED
|
@@ -25,7 +25,6 @@ export const GreyAlgorithm = {
|
|
|
25
25
|
SATURATION: 'saturation',
|
|
26
26
|
LIGHTNESS: 'lightness',
|
|
27
27
|
} as const satisfies Record<string, keyof typeof greyAlgorithms>;
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
29
28
|
export type GreyAlgorithm = (typeof GreyAlgorithm)[keyof typeof GreyAlgorithm];
|
|
30
29
|
|
|
31
30
|
{
|
package/src/roi/colorRois.ts
CHANGED
|
@@ -18,7 +18,6 @@ export const RoisColorMode = {
|
|
|
18
18
|
*/
|
|
19
19
|
RAINBOW: 'rainbow',
|
|
20
20
|
} as const;
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
22
21
|
export type RoisColorMode = (typeof RoisColorMode)[keyof typeof RoisColorMode];
|
|
23
22
|
|
|
24
23
|
export interface ColorRoisOptions {
|