image-js 0.32.0 → 0.33.2
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/index.d.ts +5 -1
- package/lib/browser/environment.js +3 -2
- package/lib/image/compute/extendedPoints.js +6 -0
- package/lib/image/core/environment.js +3 -2
- package/lib/image/core/kind.js +2 -2
- package/lib/image/core/kindNames.js +1 -1
- package/lib/image/internal/checks.js +2 -2
- package/lib/image/model/model.js +1 -1
- package/lib/image/utility/getMatrix.js +2 -4
- package/lib/index.js +9 -8
- package/lib/util/base64.js +1 -1
- package/lib/util/color.js +1 -1
- package/lib/util/converter.js +1 -1
- package/lib/util/histogram.js +1 -1
- package/lib/util/kernels.js +1 -1
- package/lib/util/points.js +7 -7
- package/package.json +14 -14
- package/src/image/compute/extendedPoints.js +11 -0
- package/src/image/utility/getMatrix.js +1 -1
package/index.d.ts
CHANGED
|
@@ -149,7 +149,11 @@ export declare class Image {
|
|
|
149
149
|
// paintPoints
|
|
150
150
|
// paintPolyline
|
|
151
151
|
// paintPolylines
|
|
152
|
-
|
|
152
|
+
paintPolygon(points: Array<Array<number>>, options?: {
|
|
153
|
+
color?: Array<number>;
|
|
154
|
+
filled?: boolean;
|
|
155
|
+
}): Image;
|
|
156
|
+
|
|
153
157
|
// paintPolygons
|
|
154
158
|
|
|
155
159
|
// countAlphaPixels
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.ImageData = exports.DOMImage = void 0;
|
|
6
7
|
exports.createCanvas = createCanvas;
|
|
7
|
-
exports.fetchBinary = fetchBinary;
|
|
8
8
|
exports.createWriteStream = createWriteStream;
|
|
9
|
+
exports.env = void 0;
|
|
10
|
+
exports.fetchBinary = fetchBinary;
|
|
9
11
|
exports.writeFile = writeFile;
|
|
10
|
-
exports.DOMImage = exports.ImageData = exports.env = void 0;
|
|
11
12
|
const env = 'browser';
|
|
12
13
|
exports.env = env;
|
|
13
14
|
const ImageData = self.ImageData;
|
|
@@ -8,6 +8,7 @@ exports.default = extendedPoints;
|
|
|
8
8
|
/**
|
|
9
9
|
* Allows to generate an array of points for a binary image (bit depth = 1)
|
|
10
10
|
* The points consider the beginning and the end of each pixel
|
|
11
|
+
* This method is only used to calculate minimalBoundRectangle
|
|
11
12
|
* @memberof Image
|
|
12
13
|
* @instance
|
|
13
14
|
* @return {Array<Array<number>>} - an array of [x,y] corresponding to the set pixels in the binary image
|
|
@@ -35,6 +36,11 @@ function extendedPoints() {
|
|
|
35
36
|
pixels.push([x, y + 1]);
|
|
36
37
|
pixels.push([x + 1, y + 1]);
|
|
37
38
|
}
|
|
39
|
+
} // this small optimization allows to reduce dramatically the number of points for MBR calculation
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
while (x < this.width - 2 && this.getBitXY(x + 1, y) === 1 && this.getBitXY(x + 2, y) === 1) {
|
|
43
|
+
x++;
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
46
|
}
|
|
@@ -3,20 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createCanvas = exports.ImageData = exports.DOMImage = void 0;
|
|
7
7
|
Object.defineProperty(exports, "createWriteStream", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function () {
|
|
10
10
|
return _fs.createWriteStream;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
+
exports.env = void 0;
|
|
14
|
+
exports.fetchBinary = fetchBinary;
|
|
13
15
|
Object.defineProperty(exports, "writeFile", {
|
|
14
16
|
enumerable: true,
|
|
15
17
|
get: function () {
|
|
16
18
|
return _fs.writeFile;
|
|
17
19
|
}
|
|
18
20
|
});
|
|
19
|
-
exports.DOMImage = exports.ImageData = exports.createCanvas = exports.env = void 0;
|
|
20
21
|
|
|
21
22
|
var _fs = require("fs");
|
|
22
23
|
|
package/lib/image/core/kind.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.createPixelArray = createPixelArray;
|
|
6
7
|
exports.getKind = getKind;
|
|
7
|
-
exports.verifyKindDefinition = verifyKindDefinition;
|
|
8
8
|
exports.getTheoreticalPixelArraySize = getTheoreticalPixelArraySize;
|
|
9
|
-
exports.
|
|
9
|
+
exports.verifyKindDefinition = verifyKindDefinition;
|
|
10
10
|
|
|
11
11
|
var ColorModel = _interopRequireWildcard(require("../model/model"));
|
|
12
12
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.RGBA = exports.RGB = exports.GREYA = exports.GREY = exports.CMYKA = exports.CMYK = exports.BINARY = void 0;
|
|
7
7
|
// Shortcuts for common image kinds
|
|
8
8
|
const BINARY = 'BINARY';
|
|
9
9
|
exports.BINARY = BINARY;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.checkRow = checkRow;
|
|
7
|
-
exports.checkColumn = checkColumn;
|
|
8
6
|
exports.checkChannel = checkChannel;
|
|
7
|
+
exports.checkColumn = checkColumn;
|
|
9
8
|
exports.checkInterpolation = checkInterpolation;
|
|
9
|
+
exports.checkRow = checkRow;
|
|
10
10
|
exports.validInterpolations = void 0;
|
|
11
11
|
|
|
12
12
|
function checkRow(image, row) {
|
package/lib/image/model/model.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.RGB = exports.HSV = exports.HSL = exports.GREY = exports.CMYK = void 0;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Color model of an image
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getMatrix;
|
|
7
7
|
|
|
8
|
-
var _mlMatrix =
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
var _mlMatrix = require("ml-matrix");
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* @memberof Image
|
|
@@ -32,7 +30,7 @@ function getMatrix(options = {}) {
|
|
|
32
30
|
channel = 0;
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
let matrix = new _mlMatrix.
|
|
33
|
+
let matrix = new _mlMatrix.Matrix(this.height, this.width);
|
|
36
34
|
|
|
37
35
|
for (let x = 0; x < this.height; x++) {
|
|
38
36
|
for (let y = 0; y < this.width; y++) {
|
package/lib/index.js
CHANGED
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "Image", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
9
|
return _Image.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
exports.Kernel = void 0;
|
|
13
|
+
Object.defineProperty(exports, "Shape", {
|
|
13
14
|
enumerable: true,
|
|
14
15
|
get: function () {
|
|
15
|
-
return
|
|
16
|
+
return _Shape.default;
|
|
16
17
|
}
|
|
17
18
|
});
|
|
18
19
|
Object.defineProperty(exports, "Stack", {
|
|
@@ -21,19 +22,19 @@ Object.defineProperty(exports, "Stack", {
|
|
|
21
22
|
return _Stack.default;
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
|
-
|
|
25
|
+
exports.Static = void 0;
|
|
26
|
+
Object.defineProperty(exports, "Worker", {
|
|
25
27
|
enumerable: true,
|
|
26
28
|
get: function () {
|
|
27
|
-
return
|
|
29
|
+
return _worker.default;
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
32
|
+
Object.defineProperty(exports, "default", {
|
|
31
33
|
enumerable: true,
|
|
32
34
|
get: function () {
|
|
33
|
-
return
|
|
35
|
+
return _Image.default;
|
|
34
36
|
}
|
|
35
37
|
});
|
|
36
|
-
exports.Kernel = exports.Static = void 0;
|
|
37
38
|
|
|
38
39
|
var _Image = _interopRequireDefault(require("./image/Image"));
|
|
39
40
|
|
package/lib/util/base64.js
CHANGED
package/lib/util/color.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.css2array = css2array;
|
|
7
|
+
exports.getColors = getColors;
|
|
7
8
|
exports.getDistinctColors = getDistinctColors;
|
|
8
9
|
exports.getRandomColor = getRandomColor;
|
|
9
|
-
exports.getColors = getColors;
|
|
10
10
|
|
|
11
11
|
var _colorFns = require("@swiftcarrot/color-fns");
|
|
12
12
|
|
package/lib/util/converter.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.factorDimensions = factorDimensions;
|
|
6
7
|
exports.getFactor = getFactor;
|
|
7
8
|
exports.getThreshold = getThreshold;
|
|
8
|
-
exports.factorDimensions = factorDimensions;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Converts a factor value to a number between 0 and 1
|
package/lib/util/histogram.js
CHANGED
package/lib/util/kernels.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.SOBEL_Y = exports.SOBEL_X = exports.SECOND_DERIVATIVE_INV = exports.SECOND_DERIVATIVE = exports.SCHARR_Y = exports.SCHARR_X = exports.DISCRETE_LAPLACE_8 = exports.DISCRETE_LAPLACE_4 = void 0;
|
|
7
7
|
const DISCRETE_LAPLACE_4 = [[0, 1, 0], [1, -4, 1], [0, 1, 0]];
|
|
8
8
|
exports.DISCRETE_LAPLACE_4 = DISCRETE_LAPLACE_4;
|
|
9
9
|
const DISCRETE_LAPLACE_8 = [[1, 1, 1], [1, -8, 1], [1, 1, 1]];
|
package/lib/util/points.js
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.round = round;
|
|
7
|
-
exports.difference = difference;
|
|
8
|
-
exports.normalize = normalize;
|
|
9
|
-
exports.rotate = rotate;
|
|
10
|
-
exports.dot = dot;
|
|
11
6
|
exports.angle = angle;
|
|
12
7
|
exports.boundary = boundary;
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
8
|
+
exports.difference = difference;
|
|
9
|
+
exports.dot = dot;
|
|
15
10
|
exports.minMax = minMax;
|
|
16
11
|
exports.moveToZeroZero = moveToZeroZero;
|
|
12
|
+
exports.normalize = normalize;
|
|
13
|
+
exports.perimeter = perimeter;
|
|
14
|
+
exports.rotate = rotate;
|
|
15
|
+
exports.round = round;
|
|
16
|
+
exports.surface = surface;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Rounds all the x and y values of an array of points
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.2",
|
|
4
4
|
"description": "Image processing and manipulation in JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"image",
|
|
@@ -59,21 +59,21 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@babel/cli": "^7.
|
|
63
|
-
"@babel/core": "^7.
|
|
64
|
-
"@babel/plugin-transform-block-scoping": "^7.
|
|
65
|
-
"@babel/plugin-transform-modules-commonjs": "^7.
|
|
66
|
-
"@babel/preset-env": "^7.
|
|
67
|
-
"@types/jest": "^
|
|
62
|
+
"@babel/cli": "^7.16.0",
|
|
63
|
+
"@babel/core": "^7.16.0",
|
|
64
|
+
"@babel/plugin-transform-block-scoping": "^7.16.0",
|
|
65
|
+
"@babel/plugin-transform-modules-commonjs": "^7.16.0",
|
|
66
|
+
"@babel/preset-env": "^7.16.0",
|
|
67
|
+
"@types/jest": "^27.0.2",
|
|
68
68
|
"benchmark": "^2.1.4",
|
|
69
69
|
"cheminfo-build": "^1.1.11",
|
|
70
70
|
"cross-env": "^7.0.3",
|
|
71
|
-
"eslint": "^
|
|
72
|
-
"eslint-config-cheminfo": "^
|
|
71
|
+
"eslint": "^8.1.0",
|
|
72
|
+
"eslint-config-cheminfo": "^7.1.2",
|
|
73
73
|
"esm": "^3.2.25",
|
|
74
|
-
"jest": "^27.
|
|
75
|
-
"jest-matcher-deep-close-to": "^
|
|
76
|
-
"prettier": "^2.
|
|
74
|
+
"jest": "^27.3.1",
|
|
75
|
+
"jest-matcher-deep-close-to": "^3.0.2",
|
|
76
|
+
"prettier": "^2.4.1",
|
|
77
77
|
"rimraf": "^3.0.2",
|
|
78
78
|
"sha.js": "^2.4.11"
|
|
79
79
|
},
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"fast-bmp": "^1.0.0",
|
|
85
85
|
"fast-jpeg": "^1.0.1",
|
|
86
86
|
"fast-list": "^1.0.3",
|
|
87
|
-
"fast-png": "^
|
|
87
|
+
"fast-png": "^6.1.0",
|
|
88
88
|
"has-own": "^1.0.1",
|
|
89
89
|
"image-type": "^4.1.0",
|
|
90
90
|
"is-array-type": "^1.0.0",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"monotone-chain-convex-hull": "^1.0.0",
|
|
102
102
|
"new-array": "^1.0.0",
|
|
103
103
|
"robust-point-in-polygon": "^1.0.3",
|
|
104
|
-
"tiff": "^5.0.
|
|
104
|
+
"tiff": "^5.0.2",
|
|
105
105
|
"web-worker-manager": "^0.2.0"
|
|
106
106
|
},
|
|
107
107
|
"engines": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Allows to generate an array of points for a binary image (bit depth = 1)
|
|
3
3
|
* The points consider the beginning and the end of each pixel
|
|
4
|
+
* This method is only used to calculate minimalBoundRectangle
|
|
4
5
|
* @memberof Image
|
|
5
6
|
* @instance
|
|
6
7
|
* @return {Array<Array<number>>} - an array of [x,y] corresponding to the set pixels in the binary image
|
|
@@ -15,6 +16,7 @@ export default function extendedPoints() {
|
|
|
15
16
|
for (let x = 0; x < this.width; x++) {
|
|
16
17
|
if (this.getBitXY(x, y) === 1) {
|
|
17
18
|
pixels.push([x, y]);
|
|
19
|
+
|
|
18
20
|
if (this.getBitXY(x + 1, y) !== 1) {
|
|
19
21
|
pixels.push([x + 1, y]);
|
|
20
22
|
pixels.push([x + 1, y + 1]);
|
|
@@ -27,6 +29,15 @@ export default function extendedPoints() {
|
|
|
27
29
|
pixels.push([x + 1, y + 1]);
|
|
28
30
|
}
|
|
29
31
|
}
|
|
32
|
+
|
|
33
|
+
// this small optimization allows to reduce dramatically the number of points for MBR calculation
|
|
34
|
+
while (
|
|
35
|
+
x < this.width - 2 &&
|
|
36
|
+
this.getBitXY(x + 1, y) === 1 &&
|
|
37
|
+
this.getBitXY(x + 2, y) === 1
|
|
38
|
+
) {
|
|
39
|
+
x++;
|
|
40
|
+
}
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
43
|
}
|