image-js 0.35.3 → 0.35.5
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 +250 -3
- package/lib/browser/environment.js +3 -6
- package/lib/browser/worker/process/background.js +1 -2
- package/lib/browser/worker/worker.js +1 -2
- package/lib/image/core/environment.js +4 -6
- package/lib/image/core/kind.js +2 -2
- package/lib/image/core/kindNames.js +7 -14
- package/lib/image/filter/gradientFilter.js +0 -1
- package/lib/image/internal/checks.js +1 -2
- package/lib/image/model/model.js +5 -10
- package/lib/image/roi/Roi.js +2 -3
- package/lib/image/transform/grey.js +0 -1
- package/lib/image/transform/greyAlgorithms.js +2 -4
- package/lib/image/transform/mask/thresholdAlgorithms.js +2 -4
- package/lib/image/utility/setMatrix.js +3 -0
- package/lib/index.js +4 -5
- package/lib/util/channel.js +2 -2
- package/lib/util/dxdy.js +2 -4
- package/lib/util/kernels.js +8 -16
- package/lib/worker/worker.js +1 -2
- package/package.json +1 -1
- package/src/image/utility/setMatrix.js +4 -0
package/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare class Image {
|
|
|
37
37
|
options?: RequestInit & { ignorePalette: boolean },
|
|
38
38
|
): Promise<Image>;
|
|
39
39
|
|
|
40
|
-
getRoiManager(): RoiManager;
|
|
40
|
+
getRoiManager(options?: RoiManagerOptions): RoiManager;
|
|
41
41
|
clone(): Image;
|
|
42
42
|
|
|
43
43
|
// valueMethods
|
|
@@ -159,7 +159,7 @@ export declare class Image {
|
|
|
159
159
|
getRow(row: number, channel?: number): Array<number>;
|
|
160
160
|
getColumn(row: number, channel?: number): Array<number>;
|
|
161
161
|
getMatrix(options?: { channel?: number }): Matrix;
|
|
162
|
-
setMatrix(matrix: Matrix, options?: { channel?: number });
|
|
162
|
+
setMatrix(matrix: Matrix, options?: { channel?: number }): this;
|
|
163
163
|
getPixelsArray(): Array<Array<number>>;
|
|
164
164
|
getIntersection(mask2: Image): object;
|
|
165
165
|
getClosestCommonParent(mask: Image): Image;
|
|
@@ -328,7 +328,254 @@ export declare class Stack extends Array<Image> {
|
|
|
328
328
|
getMinImage(): Image;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
|
|
331
|
+
type RoiMapRowInfo = {
|
|
332
|
+
row: number;
|
|
333
|
+
positivePixel: number;
|
|
334
|
+
negativePixel: number;
|
|
335
|
+
zeroPixel: number;
|
|
336
|
+
positiveRoi: number;
|
|
337
|
+
negativeRoi: number;
|
|
338
|
+
medianChange: number;
|
|
339
|
+
positiveRoiIDs: string[];
|
|
340
|
+
negativeRoiIDs: string[];
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
type RoiMapColInfo = {
|
|
344
|
+
col: number;
|
|
345
|
+
positivePixel: number;
|
|
346
|
+
negativePixel: number;
|
|
347
|
+
zeroPixel: number;
|
|
348
|
+
positiveRoi: number;
|
|
349
|
+
negativeRoi: number;
|
|
350
|
+
medianChange: number;
|
|
351
|
+
positiveRoiIDs: string[];
|
|
352
|
+
negativeRoiIDs: string[];
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export declare class RoiMap {
|
|
356
|
+
parent: Image;
|
|
357
|
+
width: number;
|
|
358
|
+
height: number;
|
|
359
|
+
data: Int32Array;
|
|
360
|
+
negative: number;
|
|
361
|
+
positive: number;
|
|
362
|
+
|
|
363
|
+
constructor(parent: Image, data: Int32Array);
|
|
364
|
+
|
|
365
|
+
get total(): number;
|
|
366
|
+
get minMax(): { min: number; max: number };
|
|
367
|
+
get commonBorderLength(): number[];
|
|
368
|
+
|
|
369
|
+
mergeRoi(options?: {
|
|
370
|
+
algorithm?: string | Function;
|
|
371
|
+
minCommonBorderLength?: number;
|
|
372
|
+
maxCommonBorderLength?: number;
|
|
373
|
+
minCommonBorderRatio?: number;
|
|
374
|
+
maxCommonBorderRatio?: number;
|
|
375
|
+
}): void;
|
|
376
|
+
|
|
377
|
+
mergeRois(rois: number[]): void;
|
|
378
|
+
|
|
379
|
+
rowsInfo(): RoiMapRowInfo[];
|
|
380
|
+
|
|
381
|
+
colsInfo(): RoiMapColInfo[];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export declare class RoiLayer {
|
|
385
|
+
roiMap: RoiMap;
|
|
386
|
+
options: Record<string, any>;
|
|
387
|
+
roi: Roi[];
|
|
388
|
+
|
|
389
|
+
constructor(roiMap: RoiMap, options?: Record<string, any>);
|
|
390
|
+
|
|
391
|
+
createRoi(): Roi[];
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export declare class Roi {
|
|
395
|
+
map: RoiMap;
|
|
396
|
+
id: number;
|
|
397
|
+
minX: number;
|
|
398
|
+
maxX: number;
|
|
399
|
+
minY: number;
|
|
400
|
+
maxY: number;
|
|
401
|
+
meanX: number;
|
|
402
|
+
meanY: number;
|
|
403
|
+
surface: number;
|
|
404
|
+
computed: this;
|
|
405
|
+
|
|
406
|
+
constructor(map: RoiMap, id: number);
|
|
407
|
+
|
|
408
|
+
getMask(options?: {
|
|
409
|
+
scale?: number;
|
|
410
|
+
kind?:
|
|
411
|
+
| 'contour'
|
|
412
|
+
| 'box'
|
|
413
|
+
| 'filled'
|
|
414
|
+
| 'center'
|
|
415
|
+
| 'mbr'
|
|
416
|
+
| 'hull'
|
|
417
|
+
| 'hullContour'
|
|
418
|
+
| 'mbrContour'
|
|
419
|
+
| 'feret'
|
|
420
|
+
| 'normal';
|
|
421
|
+
}): Image;
|
|
422
|
+
|
|
423
|
+
get height(): number;
|
|
424
|
+
get width(): number;
|
|
425
|
+
get center(): [number, number];
|
|
426
|
+
get ratio(): number;
|
|
427
|
+
get center(): [number, number];
|
|
428
|
+
get ratio(): number;
|
|
429
|
+
get width(): number;
|
|
430
|
+
get height(): number;
|
|
431
|
+
get externalIDs(): number[];
|
|
432
|
+
get externalLengths(): number[];
|
|
433
|
+
get borderIDs(): number[];
|
|
434
|
+
get borderIDs(): number[];
|
|
435
|
+
get borderLengths(): number[];
|
|
436
|
+
get boxIDs(): number[];
|
|
437
|
+
get internalIDs(): number[];
|
|
438
|
+
get box(): number;
|
|
439
|
+
get external(): number;
|
|
440
|
+
get holesInfo(): { number: number; surface: number };
|
|
441
|
+
get border(): number;
|
|
442
|
+
get contourMask(): Image;
|
|
443
|
+
get boxMask(): Image;
|
|
444
|
+
get mask(): Image;
|
|
445
|
+
get filledMask(): Image;
|
|
446
|
+
get centerMask(): Image;
|
|
447
|
+
get convexHull(): {
|
|
448
|
+
polyline: number[][];
|
|
449
|
+
surface: number;
|
|
450
|
+
perimeter: number;
|
|
451
|
+
};
|
|
452
|
+
get convexHullMask(): Image;
|
|
453
|
+
get convexHullFilledMask(): Image;
|
|
454
|
+
get mbr(): {
|
|
455
|
+
width: number;
|
|
456
|
+
height: number;
|
|
457
|
+
elongation: number;
|
|
458
|
+
aspectRatio: number;
|
|
459
|
+
surface: number;
|
|
460
|
+
perimeter: number;
|
|
461
|
+
rectangle: number[][];
|
|
462
|
+
};
|
|
463
|
+
get fillRatio(): number;
|
|
464
|
+
get feretDiameters(): {
|
|
465
|
+
min: number;
|
|
466
|
+
max: number;
|
|
467
|
+
minLine: number[][];
|
|
468
|
+
maxLine: number[][];
|
|
469
|
+
};
|
|
470
|
+
get eqpc(): number;
|
|
471
|
+
get perimeterInfo(): {
|
|
472
|
+
one: number;
|
|
473
|
+
two: number;
|
|
474
|
+
three: number;
|
|
475
|
+
four: number;
|
|
476
|
+
};
|
|
477
|
+
get perimeter(): number;
|
|
478
|
+
get ped(): number;
|
|
479
|
+
get feretMask(): Image;
|
|
480
|
+
get mbrMask(): Image;
|
|
481
|
+
get mbrFilledMask(): Image;
|
|
482
|
+
get points(): [[number, number]];
|
|
483
|
+
get maxLengthPoints(): [[number, number], [number, number]];
|
|
484
|
+
get maxLength(): number;
|
|
485
|
+
get roundness(): number;
|
|
486
|
+
get sphericality(): number;
|
|
487
|
+
get solidity(): number;
|
|
488
|
+
get angle(): number;
|
|
489
|
+
toJSON(): {
|
|
490
|
+
id: number;
|
|
491
|
+
minX: number;
|
|
492
|
+
maxX: number;
|
|
493
|
+
minY: number;
|
|
494
|
+
maxY: number;
|
|
495
|
+
meanX: number;
|
|
496
|
+
meanY: number;
|
|
497
|
+
height: number;
|
|
498
|
+
width: number;
|
|
499
|
+
surface: number;
|
|
500
|
+
mbrWidth: number;
|
|
501
|
+
mbrHeight: number;
|
|
502
|
+
mbrSurface: number;
|
|
503
|
+
eqpc: number;
|
|
504
|
+
ped: number;
|
|
505
|
+
feretDiameterMin: number;
|
|
506
|
+
feretDiameterMax: number;
|
|
507
|
+
aspectRatio: number;
|
|
508
|
+
fillRatio: number;
|
|
509
|
+
sphericity: number;
|
|
510
|
+
roundness: number;
|
|
511
|
+
solidity: number;
|
|
512
|
+
perimeter: number;
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export class RoiManager {
|
|
517
|
+
private _image: Image;
|
|
518
|
+
private _options: {
|
|
519
|
+
label?: string;
|
|
520
|
+
[key: string]: any;
|
|
521
|
+
};
|
|
522
|
+
private _layers: { [key: string]: RoiLayer };
|
|
523
|
+
private _painted: Image | null;
|
|
524
|
+
|
|
525
|
+
constructor(image: Image, options?: { label?: string });
|
|
526
|
+
|
|
527
|
+
fromMaxima(options?: Record<string, any>): void;
|
|
528
|
+
fromPoints(points: number[][], options?: Record<string, any>): this;
|
|
529
|
+
putMap(map: number[], options?: Record<string, any>): this;
|
|
530
|
+
fromWaterShed(options?: Record<string, any>): void;
|
|
531
|
+
fromMask(mask: Image, options?: Record<string, any>): this;
|
|
532
|
+
fromMaskConnectedComponentLabelingAlgorithm(
|
|
533
|
+
mask: Image,
|
|
534
|
+
options?: Record<string, any>,
|
|
535
|
+
): this;
|
|
536
|
+
getMap(options?: Record<string, any>): RoiMap;
|
|
537
|
+
rowsInfo(options?: Record<string, any>): RoiMapRowInfo[];
|
|
538
|
+
colsInfo(options?: Record<string, any>): RoiMapColInfo[];
|
|
539
|
+
getRoiIds(options?: Record<string, any>): number[];
|
|
540
|
+
getRois(options?: {
|
|
541
|
+
label?: string;
|
|
542
|
+
positive?: boolean;
|
|
543
|
+
negative?: boolean;
|
|
544
|
+
minSurface?: number;
|
|
545
|
+
maxSurface?: number;
|
|
546
|
+
minWidth?: number;
|
|
547
|
+
maxWidth?: number;
|
|
548
|
+
minHeight?: number;
|
|
549
|
+
maxHeight?: number;
|
|
550
|
+
minRatio?: number;
|
|
551
|
+
maxRatio?: number;
|
|
552
|
+
}): Roi[];
|
|
553
|
+
getRoi(roiId: number, options?: { label?: string }): Roi;
|
|
554
|
+
getMasks(options?: Record<string, any>): Image[];
|
|
555
|
+
getAnalysisMasks(options?: { analysisProperty: string }): Image[];
|
|
556
|
+
getData(options?: Record<string, any>): number[];
|
|
557
|
+
paint(options?: {
|
|
558
|
+
labelProperty?: string;
|
|
559
|
+
analysisProperty?: string;
|
|
560
|
+
analysisProperty?: string;
|
|
561
|
+
labelProperty?: string;
|
|
562
|
+
analysisProperty?: string;
|
|
563
|
+
labelProperty?: string;
|
|
564
|
+
pixelSize?: number;
|
|
565
|
+
unit?: string;
|
|
566
|
+
}): Image;
|
|
567
|
+
getMask(options?: Record<string, any>): Image;
|
|
568
|
+
resetPainted(options?: { image?: Image }): void;
|
|
569
|
+
mergeRoi(options?: {
|
|
570
|
+
algorithm?: string;
|
|
571
|
+
minCommonBorderLength?: number;
|
|
572
|
+
maxCommonBorderLength?: number;
|
|
573
|
+
minCommonBorderRatio?: number;
|
|
574
|
+
maxCommonBorderRatio?: number;
|
|
575
|
+
}): this;
|
|
576
|
+
mergeRois(roiIds: number[], options?: Record<string, any>): this;
|
|
577
|
+
findCorrespondingRoi(roiMap: number[], options?: Record<string, any>): Roi[];
|
|
578
|
+
}
|
|
332
579
|
|
|
333
580
|
export interface ImageConstructorOptions {
|
|
334
581
|
width?: number;
|
|
@@ -9,12 +9,9 @@ exports.createWriteStream = createWriteStream;
|
|
|
9
9
|
exports.env = void 0;
|
|
10
10
|
exports.fetchBinary = fetchBinary;
|
|
11
11
|
exports.writeFile = writeFile;
|
|
12
|
-
const env = 'browser';
|
|
13
|
-
exports.
|
|
14
|
-
const
|
|
15
|
-
exports.ImageData = ImageData;
|
|
16
|
-
const DOMImage = self.Image;
|
|
17
|
-
exports.DOMImage = DOMImage;
|
|
12
|
+
const env = exports.env = 'browser';
|
|
13
|
+
const ImageData = exports.ImageData = self.ImageData;
|
|
14
|
+
const DOMImage = exports.DOMImage = self.Image;
|
|
18
15
|
function createCanvas(width, height) {
|
|
19
16
|
let canvas = self.document.createElement('canvas');
|
|
20
17
|
canvas.width = width;
|
|
@@ -20,10 +20,9 @@ Object.defineProperty(exports, "writeFile", {
|
|
|
20
20
|
});
|
|
21
21
|
var _fs = require("fs");
|
|
22
22
|
const message = 'requires the canvas library. Install it with `npm install canvas@next`.';
|
|
23
|
-
let createCanvas
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.createCanvas = createCanvas;
|
|
23
|
+
let createCanvas = exports.createCanvas = void 0,
|
|
24
|
+
DOMImage = exports.DOMImage = void 0,
|
|
25
|
+
ImageData = exports.ImageData = void 0;
|
|
27
26
|
try {
|
|
28
27
|
// eslint-disable-next-line import/no-unresolved
|
|
29
28
|
const canvas = require('canvas');
|
|
@@ -41,8 +40,7 @@ try {
|
|
|
41
40
|
throw new Error(`ImageData ${message}`);
|
|
42
41
|
};
|
|
43
42
|
}
|
|
44
|
-
const env = 'node';
|
|
45
|
-
exports.env = env;
|
|
43
|
+
const env = exports.env = 'node';
|
|
46
44
|
function fetchBinary(path) {
|
|
47
45
|
return new Promise(function (resolve, reject) {
|
|
48
46
|
(0, _fs.readFile)(path, function (err, data) {
|
package/lib/image/core/kind.js
CHANGED
|
@@ -9,8 +9,8 @@ exports.getTheoreticalPixelArraySize = getTheoreticalPixelArraySize;
|
|
|
9
9
|
exports.verifyKindDefinition = verifyKindDefinition;
|
|
10
10
|
var ColorModel = _interopRequireWildcard(require("../model/model"));
|
|
11
11
|
var Kind = _interopRequireWildcard(require("./kindNames"));
|
|
12
|
-
function _getRequireWildcardCache(
|
|
13
|
-
function _interopRequireWildcard(
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
14
|
const kinds = {};
|
|
15
15
|
kinds[Kind.BINARY] = {
|
|
16
16
|
components: 1,
|
|
@@ -6,17 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
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
|
|
|
9
|
-
const BINARY = 'BINARY';
|
|
10
|
-
exports.
|
|
11
|
-
const
|
|
12
|
-
exports.
|
|
13
|
-
const
|
|
14
|
-
exports.
|
|
15
|
-
const
|
|
16
|
-
exports.RGB = RGB;
|
|
17
|
-
const RGBA = 'RGBA';
|
|
18
|
-
exports.RGBA = RGBA;
|
|
19
|
-
const CMYK = 'CMYK';
|
|
20
|
-
exports.CMYK = CMYK;
|
|
21
|
-
const CMYKA = 'CMYKA';
|
|
22
|
-
exports.CMYKA = CMYKA;
|
|
9
|
+
const BINARY = exports.BINARY = 'BINARY';
|
|
10
|
+
const GREY = exports.GREY = 'GREY';
|
|
11
|
+
const GREYA = exports.GREYA = 'GREYA';
|
|
12
|
+
const RGB = exports.RGB = 'RGB';
|
|
13
|
+
const RGBA = exports.RGBA = 'RGBA';
|
|
14
|
+
const CMYK = exports.CMYK = 'CMYK';
|
|
15
|
+
const CMYKA = exports.CMYKA = 'CMYKA';
|
|
@@ -27,12 +27,11 @@ function checkChannel(image, channel) {
|
|
|
27
27
|
/**
|
|
28
28
|
* @typedef {('nearestNeighbor'|'bilinear')} InterpolationAlgorithm
|
|
29
29
|
*/
|
|
30
|
-
const validInterpolations = {
|
|
30
|
+
const validInterpolations = exports.validInterpolations = {
|
|
31
31
|
nearestneighbor: 'nearestNeighbor',
|
|
32
32
|
nearestneighbour: 'nearestNeighbor',
|
|
33
33
|
bilinear: 'bilinear'
|
|
34
34
|
};
|
|
35
|
-
exports.validInterpolations = validInterpolations;
|
|
36
35
|
function checkInterpolation(interpolation) {
|
|
37
36
|
if (typeof interpolation !== 'string') {
|
|
38
37
|
throw new TypeError('interpolation must be a string');
|
package/lib/image/model/model.js
CHANGED
|
@@ -9,13 +9,8 @@ exports.RGB = exports.HSV = exports.HSL = exports.GREY = exports.CMYK = void 0;
|
|
|
9
9
|
* @typedef {('GREY'|'RGB'|'HSL'|'HSV'|'CMYK')} ColorModel
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
const GREY = 'GREY';
|
|
13
|
-
exports.
|
|
14
|
-
const
|
|
15
|
-
exports.
|
|
16
|
-
const
|
|
17
|
-
exports.HSL = HSL;
|
|
18
|
-
const HSV = 'HSV';
|
|
19
|
-
exports.HSV = HSV;
|
|
20
|
-
const CMYK = 'CMYK';
|
|
21
|
-
exports.CMYK = CMYK;
|
|
12
|
+
const GREY = exports.GREY = 'GREY';
|
|
13
|
+
const RGB = exports.RGB = 'RGB';
|
|
14
|
+
const HSL = exports.HSL = 'HSL';
|
|
15
|
+
const HSV = exports.HSV = 'HSV';
|
|
16
|
+
const CMYK = exports.CMYK = 'CMYK';
|
package/lib/image/roi/Roi.js
CHANGED
|
@@ -12,12 +12,11 @@ var _Image = _interopRequireDefault(require("../Image"));
|
|
|
12
12
|
var _minimalBoundingRectangle = _interopRequireDefault(require("../compute/minimalBoundingRectangle"));
|
|
13
13
|
var KindNames = _interopRequireWildcard(require("../core/kindNames"));
|
|
14
14
|
var _feretDiameters = _interopRequireDefault(require("./feretDiameters"));
|
|
15
|
-
function _getRequireWildcardCache(
|
|
16
|
-
function _interopRequireWildcard(
|
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
// Many measurements:
|
|
19
19
|
// https://www.sympatec.com/en/particle-measurement/glossary/particle-shape/#
|
|
20
|
-
|
|
21
20
|
/**
|
|
22
21
|
* Class to manage Region Of Interests
|
|
23
22
|
* @class Roi
|
|
@@ -8,7 +8,7 @@ exports.names = exports.methods = void 0;
|
|
|
8
8
|
* @typedef {('luma709'|'luma601'|'maximum'|'minimum'|'average'|'minmax'|'red'|'green'|'blue'|'cyan'|'magenta'|'yellow'|'black'|'hue'|'saturation'|'lightness')} GreyAlgorithm
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const methods = {
|
|
11
|
+
const methods = exports.methods = {
|
|
12
12
|
luma709(red, green, blue) {
|
|
13
13
|
// sRGB
|
|
14
14
|
// return red * 0.2126 + green * 0.7152 + blue * 0.0722;
|
|
@@ -96,7 +96,6 @@ const methods = {
|
|
|
96
96
|
return (max + min) / 2;
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
exports.methods = methods;
|
|
100
99
|
Object.defineProperty(methods, 'luminosity', {
|
|
101
100
|
enumerable: false,
|
|
102
101
|
value: methods.lightness
|
|
@@ -117,8 +116,7 @@ Object.defineProperty(methods, 'brightness', {
|
|
|
117
116
|
enumerable: false,
|
|
118
117
|
value: methods.maximum
|
|
119
118
|
});
|
|
120
|
-
const names = {};
|
|
121
|
-
exports.names = names;
|
|
119
|
+
const names = exports.names = {};
|
|
122
120
|
Object.keys(methods).forEach(name => {
|
|
123
121
|
names[name] = name;
|
|
124
122
|
});
|
|
@@ -24,7 +24,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
24
24
|
* @typedef {('huang'|'intermodes'|'isodata'|'li'|'maxentropy'|'mean'|'minerror'|'minimum'|'moments'|'otsu'|'percentile'|'renyientropy'|'shanbhag'|'triangle'|'yen')} ThresholdAlgorithm
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
const methods = {
|
|
27
|
+
const methods = exports.methods = {
|
|
28
28
|
huang: _huang.default,
|
|
29
29
|
intermodes: _intermodes.default,
|
|
30
30
|
isodata: _isodata.default,
|
|
@@ -41,9 +41,7 @@ const methods = {
|
|
|
41
41
|
triangle: _triangle.default,
|
|
42
42
|
yen: _yen.default
|
|
43
43
|
};
|
|
44
|
-
exports.
|
|
45
|
-
const names = {};
|
|
46
|
-
exports.names = names;
|
|
44
|
+
const names = exports.names = {};
|
|
47
45
|
Object.keys(methods).forEach(name => {
|
|
48
46
|
names[name] = name;
|
|
49
47
|
});
|
|
@@ -12,6 +12,8 @@ var _mlMatrix = require("ml-matrix");
|
|
|
12
12
|
* @param {Matrix} matrix
|
|
13
13
|
* @param {object} [options]
|
|
14
14
|
* @param {number} [options.channel]
|
|
15
|
+
*
|
|
16
|
+
* @return {this}
|
|
15
17
|
*/
|
|
16
18
|
function setMatrix(matrix, options = {}) {
|
|
17
19
|
matrix = new _mlMatrix.Matrix(matrix);
|
|
@@ -35,4 +37,5 @@ function setMatrix(matrix, options = {}) {
|
|
|
35
37
|
this.setValueXY(y, x, channel, matrix.get(x, y));
|
|
36
38
|
}
|
|
37
39
|
}
|
|
40
|
+
return this;
|
|
38
41
|
}
|
package/lib/index.js
CHANGED
|
@@ -43,11 +43,10 @@ exports.Kernel = Kernel;
|
|
|
43
43
|
var _Stack = _interopRequireDefault(require("./stack/Stack"));
|
|
44
44
|
var _Shape = _interopRequireDefault(require("./util/Shape"));
|
|
45
45
|
var _worker = _interopRequireDefault(require("./worker/worker"));
|
|
46
|
-
function _getRequireWildcardCache(
|
|
47
|
-
function _interopRequireWildcard(
|
|
46
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
47
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
48
48
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
49
|
-
const Static = {
|
|
49
|
+
const Static = exports.Static = {
|
|
50
50
|
grey: _greyAlgorithms.names,
|
|
51
51
|
threshold: _thresholdAlgorithms.names
|
|
52
|
-
};
|
|
53
|
-
exports.Static = Static;
|
|
52
|
+
};
|
package/lib/util/channel.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.validateArrayOfChannels = validateArrayOfChannels;
|
|
7
7
|
exports.validateChannel = validateChannel;
|
|
8
8
|
var Model = _interopRequireWildcard(require("../image/model/model"));
|
|
9
|
-
function _getRequireWildcardCache(
|
|
10
|
-
function _interopRequireWildcard(
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
/**
|
|
12
12
|
* Specify which channels should be processed
|
|
13
13
|
* * undefined : we take all the channels but alpha
|
package/lib/util/dxdy.js
CHANGED
|
@@ -4,7 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.dys = exports.dxs = void 0;
|
|
7
|
-
const dxs = [+1, 0, -1, 0, +1, +1, -1, -1];
|
|
8
|
-
exports.
|
|
9
|
-
const dys = [0, +1, 0, -1, +1, -1, +1, -1];
|
|
10
|
-
exports.dys = dys;
|
|
7
|
+
const dxs = exports.dxs = [+1, 0, -1, 0, +1, +1, -1, -1];
|
|
8
|
+
const dys = exports.dys = [0, +1, 0, -1, +1, -1, +1, -1];
|
package/lib/util/kernels.js
CHANGED
|
@@ -4,19 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
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
|
-
const DISCRETE_LAPLACE_4 = [[0, 1, 0], [1, -4, 1], [0, 1, 0]];
|
|
8
|
-
exports.
|
|
9
|
-
const
|
|
10
|
-
exports.
|
|
11
|
-
const
|
|
12
|
-
exports.
|
|
13
|
-
const
|
|
14
|
-
exports.
|
|
15
|
-
const SCHARR_X = [[3, 0, -3], [10, 0, -10], [3, 0, -3]];
|
|
16
|
-
exports.SCHARR_X = SCHARR_X;
|
|
17
|
-
const SCHARR_Y = [[3, 10, 3], [0, 0, 0], [-3, -10, -3]];
|
|
18
|
-
exports.SCHARR_Y = SCHARR_Y;
|
|
19
|
-
const SECOND_DERIVATIVE = [[-1, -2, 0, 2, 1], [-2, -4, 0, 4, 2], [0, 0, 0, 0, 0], [1, 2, 0, -2, -1], [2, 4, 0, -4, -2]];
|
|
20
|
-
exports.SECOND_DERIVATIVE = SECOND_DERIVATIVE;
|
|
21
|
-
const SECOND_DERIVATIVE_INV = [[1, 2, 0, -2, -1], [2, 4, 0, -4, -2], [0, 0, 0, 0, 0], [-2, -4, 0, 4, 2], [-1, -2, 0, 2, 1]];
|
|
22
|
-
exports.SECOND_DERIVATIVE_INV = SECOND_DERIVATIVE_INV;
|
|
7
|
+
const DISCRETE_LAPLACE_4 = exports.DISCRETE_LAPLACE_4 = [[0, 1, 0], [1, -4, 1], [0, 1, 0]];
|
|
8
|
+
const DISCRETE_LAPLACE_8 = exports.DISCRETE_LAPLACE_8 = [[1, 1, 1], [1, -8, 1], [1, 1, 1]];
|
|
9
|
+
const SOBEL_X = exports.SOBEL_X = [[-1, 0, +1], [-2, 0, +2], [-1, 0, +1]];
|
|
10
|
+
const SOBEL_Y = exports.SOBEL_Y = [[-1, -2, -1], [0, 0, 0], [+1, +2, +1]];
|
|
11
|
+
const SCHARR_X = exports.SCHARR_X = [[3, 0, -3], [10, 0, -10], [3, 0, -3]];
|
|
12
|
+
const SCHARR_Y = exports.SCHARR_Y = [[3, 10, 3], [0, 0, 0], [-3, -10, -3]];
|
|
13
|
+
const SECOND_DERIVATIVE = exports.SECOND_DERIVATIVE = [[-1, -2, 0, 2, 1], [-2, -4, 0, 4, 2], [0, 0, 0, 0, 0], [1, 2, 0, -2, -1], [2, 4, 0, -4, -2]];
|
|
14
|
+
const SECOND_DERIVATIVE_INV = exports.SECOND_DERIVATIVE_INV = [[1, 2, 0, -2, -1], [2, 4, 0, -4, -2], [0, 0, 0, 0, 0], [-2, -4, 0, 4, 2], [-1, -2, 0, 2, 1]];
|
package/lib/worker/worker.js
CHANGED
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@ import { Matrix } from 'ml-matrix';
|
|
|
7
7
|
* @param {Matrix} matrix
|
|
8
8
|
* @param {object} [options]
|
|
9
9
|
* @param {number} [options.channel]
|
|
10
|
+
*
|
|
11
|
+
* @return {this}
|
|
10
12
|
*/
|
|
11
13
|
export default function setMatrix(matrix, options = {}) {
|
|
12
14
|
matrix = new Matrix(matrix);
|
|
@@ -35,4 +37,6 @@ export default function setMatrix(matrix, options = {}) {
|
|
|
35
37
|
this.setValueXY(y, x, channel, matrix.get(x, y));
|
|
36
38
|
}
|
|
37
39
|
}
|
|
40
|
+
|
|
41
|
+
return this;
|
|
38
42
|
}
|