image-js 0.35.0 → 0.35.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 CHANGED
@@ -77,12 +77,30 @@ export declare class Image {
77
77
  min?: number;
78
78
  max?: number;
79
79
  }): this;
80
- // add
81
- // subtract
82
- // subtractImage
83
- // multiply
84
- // divide
85
- // hypotenuse
80
+ add(
81
+ value: Array<number> | Image | number,
82
+ options?: { channels?: Array<Channel> },
83
+ ): this;
84
+ subtract(
85
+ value: Array<number> | Image | number,
86
+ options?: { channels?: Array<Channel> },
87
+ ): this;
88
+ subtractImage(
89
+ otherImage: Image,
90
+ options?: { channels?: Array<Channel>; absolute?: boolean },
91
+ ): this;
92
+ multiply(
93
+ value: Array<number> | Image | number,
94
+ options?: { channels?: Array<Channel> },
95
+ ): this;
96
+ divide(
97
+ value: Array<number> | Image | number,
98
+ options?: { channels?: Array<Channel> },
99
+ ): this;
100
+ hypotenuse(
101
+ otherImage: Image,
102
+ options?: { bitDepth?: number; channels?: Array<Channel> },
103
+ ): Image;
86
104
  // background
87
105
  flipX(): this;
88
106
  flipY(): this;
@@ -106,45 +124,95 @@ export declare class Image {
106
124
  blackHat(options?: MorphologicalOptions): Image;
107
125
  morphologicalGradient(options?: MorphologicalOptions): Image;
108
126
 
109
- // warpingFourPoints
127
+ warpingFourPoints(
128
+ pts: Array<Array<number>>,
129
+ options?: {
130
+ calculateRatio?: boolean;
131
+ },
132
+ ): Image;
110
133
  crop(options?: CropOptions): Image;
111
- // cropAlpha
134
+ cropAlpha(options?: { threshold?: number }): Image;
112
135
  resize(options?: ResizeOptions): Image;
113
- // hsv
114
- // hsl
115
- // cmyk
116
- // rgba8
136
+ hsv(): Image;
137
+ hsl(): Image;
138
+ cmyk(): Image;
139
+ rgba8(): Image;
117
140
  grey(options?: GreyOptions): Image;
118
141
  mask(options?: MaskOptions): Image;
119
- // pad
120
- // colorDepth
121
- // setBorder
142
+ pad(options?: {
143
+ size?: number;
144
+ algorithm?: 'set' | 'copy';
145
+ color?: Array<number>;
146
+ }): Image;
147
+ colorDepth(newColorDepth: 8 | 16): Image;
148
+ setBorder(options?: {
149
+ size?: number;
150
+ algorithm?: 'set' | 'copy';
151
+ color?: Array<number>;
152
+ }): Image;
122
153
  rotate(angle: number, options?: RotateOptions): Image;
123
154
  rotateLeft(): Image;
124
155
  rotateRight(): Image;
125
156
 
126
- // getRow
127
- // getColumn
128
- // getMatrix
129
- // setMatrix
130
- // getPixelsArray
131
- // getIntersection
132
- // getClosestCommonParent
133
- // getThreshold
134
-
135
- // split
136
- // getChannel
137
- // combineChannels
157
+ getRow(row: number, channel?: number): Array<number>;
158
+ getColumn(row: number, channel?: number): Array<number>;
159
+ getMatrix(options?: { channel?: number }): Matrix;
160
+ setMatrix(matrix: Matrix, options?: { channel?: number });
161
+ getPixelsArray(): Array<Array<number>>;
162
+ getIntersection(mask2: Image): object;
163
+ getClosestCommonParent(mask: Image): Image;
164
+ getThreshold(options?: { algorithm?: ThresholdAlgorithm }): number;
165
+
166
+ split(options?: { preserveAlpha?: boolean }): Stack;
167
+ getChannel(
168
+ channel: Channel,
169
+ options?: { keepAlpha?: boolean; mergeAlpha?: boolean },
170
+ ): Image;
171
+ combineChannels(
172
+ method?: Function,
173
+ options?: { keepAlpha?: boolean; mergeAlpha?: boolean },
174
+ ): Image;
138
175
  setChannel(channel: any, image: Image): this;
139
- // getSimilarity
140
- // getPixelsGrid
141
- // getBestMatch
176
+ getSimilarity(
177
+ image: Image,
178
+ options?: {
179
+ shift?: Array<number>;
180
+ average?: boolean;
181
+ channels?: Array<Channel>;
182
+ defaultAlpha?: boolean;
183
+ normalize?: boolean;
184
+ border?: Array<number>;
185
+ },
186
+ ): Array<number> | number;
187
+ getPixelsGrid(options?: {
188
+ sampling?: Array<number>;
189
+ painted?: boolean;
190
+ mask?: Image;
191
+ }): { xyS: Array<number>; zS: Array<number>; painted: Image };
192
+ getBestMatch(
193
+ image: Image,
194
+ options?: { border?: Array<number> },
195
+ ): Array<number>;
142
196
 
143
197
  // cannyEdge
144
198
  convolution(kernel: Kernel, options?: ConvolutionOptions): Image;
145
- // extract
199
+ extract(
200
+ mask: Image,
201
+ options?: {
202
+ position?: Array<number>;
203
+ },
204
+ ): this;
146
205
  // floodFill
147
- // paintLabels
206
+ paintLabels(
207
+ labels: Array<string>,
208
+ positions: Array<Array<number>>,
209
+ options?: {
210
+ color?: Array<number> | string;
211
+ colors?: Array<Array<number>> | Array<string>;
212
+ font?: string | Array<string>;
213
+ rotate?: number | Array<number>;
214
+ },
215
+ ): this;
148
216
  paintMasks(
149
217
  masks: Image | Array<Image>,
150
218
  options?: {
@@ -158,35 +226,87 @@ export declare class Image {
158
226
  labelColor?: string;
159
227
  labelFont?: string;
160
228
  },
161
- ): Image;
162
- // paintPoints
163
- // paintPolyline
164
- // paintPolylines
229
+ ): this;
230
+ paintPoints(
231
+ points: Array<Array<number>>,
232
+ options?: {
233
+ color?: Array<number> | string;
234
+ colors?: Array<Array<number>> | Array<string>;
235
+ randomColors?: boolean;
236
+ distinctColors?: boolean;
237
+ shape?: object;
238
+ },
239
+ ): this;
240
+ paintPolyline(
241
+ points: Array<Array<number>>,
242
+ options?: {
243
+ color?: Array<number>;
244
+ closed?: boolean;
245
+ },
246
+ ): this;
247
+ paintPolylines(
248
+ polylines: Array<Array<Array<number>>>,
249
+ options?: {
250
+ color?: Array<number> | string;
251
+ colors?: Array<Array<number>> | Array<string>;
252
+ randomColors?: boolean;
253
+ distinctColors?: boolean;
254
+ shape?: object;
255
+ },
256
+ ): this;
165
257
  paintPolygon(
166
258
  points: Array<Array<number>>,
167
259
  options?: {
168
260
  color?: Array<number>;
169
261
  filled?: boolean;
170
262
  },
171
- ): Image;
172
-
173
- // paintPolygons
174
-
175
- // countAlphaPixels
176
- // monotoneChainConvexHull
177
- // minimalBoundingRectangle
178
- // getHistogram
179
- // getHistograms
180
- // getColorHistogram
181
- // getMin
182
- // getMax
183
- // getSum
184
- // getMoment
185
- // getLocalMaxima
186
- // getMedian
187
- // getMean
188
- // getPoints
189
- // getRelativePosition
263
+ ): this;
264
+ paintPolygons(
265
+ points: Array<Array<Array<number>>>,
266
+ options?: {
267
+ color?: Array<number> | string;
268
+ colors?: Array<Array<number>> | Array<string>;
269
+ randomColors?: boolean;
270
+ distinctColors?: boolean;
271
+ shape?: object;
272
+ },
273
+ ): this;
274
+
275
+ countAlphaPixels(options?: { alpha?: number }): number;
276
+ monotoneChainConvexHull(): Array<Array<number>>;
277
+ minimalBoundingRectangle(options?: {
278
+ originalPoints?: Array<Array<number>>;
279
+ }): Array<Array<number>>;
280
+ getHistogram(options?: {
281
+ maxSlots?: number;
282
+ channel?: number;
283
+ useAlpha?: boolean;
284
+ }): Array<number>;
285
+ getHistograms(options?: { maxSlots?: number }): Array<Array<number>>;
286
+ getColorHistogram(options?: {
287
+ useAlpha?: boolean;
288
+ nbSlots?: number;
289
+ }): Array<number>;
290
+ getMin(): Array<number>;
291
+ getMax(): Array<number>;
292
+ getSum(): Array<number>;
293
+ getMoment(xPower: number, yPower: number): number;
294
+ getLocalMaxima(options?: {
295
+ mask?: Image;
296
+ region?: number;
297
+ removeClosePoints?: number;
298
+ invert?: boolean;
299
+ maxEquals?: number;
300
+ }): Array<number>;
301
+ getMedian(): Array<number>;
302
+ getMean(): Array<number>;
303
+ getPoints(): Array<Array<number>>;
304
+ getRelativePosition(
305
+ targetImage: Image,
306
+ options?: {
307
+ defaultFurther?: boolean;
308
+ },
309
+ ): Array<number> | boolean;
190
310
  }
191
311
 
192
312
  export declare class Stack extends Array<Image> {
@@ -208,6 +328,15 @@ export declare class Stack extends Array<Image> {
208
328
 
209
329
  export declare class RoiManager {}
210
330
 
331
+ export declare class Matrix extends Array<Array<number>> {
332
+ constructor();
333
+ constructor(width: number, height: number, defaultValue?: number);
334
+
335
+ localMin(x: number, y: number): { position: Array<number>; value: number };
336
+ localMax(x: number, y: number): { position: Array<number>; value: number };
337
+ localSearch(x: number, y: number, value: number): Array<Array<number>>;
338
+ }
339
+
211
340
  export interface ImageConstructorOptions {
212
341
  width?: number;
213
342
  height?: number;
@@ -391,5 +520,6 @@ export type BinaryValue = 0 | 1;
391
520
  export type SelectedChannels = number | string | Array<number> | Array<string>;
392
521
  export type BinaryKernel = Array<Array<BinaryValue>>;
393
522
  export type Kernel = Array<Array<number>>;
523
+ export type Channel = number | string;
394
524
 
395
525
  export default Image;
@@ -10,15 +10,15 @@ var _color = require("../../util/color");
10
10
  var _model = require("../model/model");
11
11
 
12
12
  /**
13
- * Paint a mask or masks on the current image.
13
+ * Paint a label or labels on the current image.
14
14
  * @memberof Image
15
15
  * @instance
16
16
  *
17
- * @param {Array<string>} [labels] - Array of labels to display. Should the the same size as masks.
18
- * @param {Array<Array>} [positions] - Array of labels to display. Should the the same size as masks.
19
- * @param {object} [options]
20
- * @param {number[]|string} [options.color='red'] - Array of 3 elements (R, G, B) or a valid css color.
21
- * @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask
17
+ * @param {Array<string>} [labels] - Array of labels to display.
18
+ * @param {Array<Array<number>>} [positions] - Array of points [x,y] where the labels should be displayed.
19
+ * @param {object} [options]
20
+ * @param {Array<number>|string} [options.color='red'] - Array of 3 elements (R, G, B) or a valid css color.
21
+ * @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each label.
22
22
  * @param {string|Array<string>} [options.font='12px Helvetica'] - Paint the labels in a different CSS style
23
23
  * @param {number|Array<number>} [options.rotate=0] - Rotate each label of a define angle
24
24
  * @return {this} The original painted image
@@ -12,7 +12,7 @@ exports.default = paintPolygon;
12
12
  * @param {Array<Array<number>>} points - Array of [x,y] points
13
13
  * @param {object} [options]
14
14
  * @param {Array<number>} [options.color=[max,0,0]] - Array of 3 elements (R, G, B), default is red.
15
- * @param {Array<number>} [options.filled=false] - If you want the polygon to be filled or not.
15
+ * @param {boolean} [options.filled=false] - If you want the polygon to be filled or not.
16
16
  * @return {this} The original painted image
17
17
  */
18
18
  function paintPolygon(points, options = {}) {
@@ -8,10 +8,10 @@ exports.default = paintPolygons;
8
8
  var _color = require("../../util/color");
9
9
 
10
10
  /**
11
- * Paint an array of polygon on the current image.
11
+ * Paint an array of polygons on the current image.
12
12
  * @memberof Image
13
13
  * @instance
14
- * @param {Array<Array<number>>} polygons - Array of array of [x,y] points
14
+ * @param {Array<Array<Array<number>>>} polygons - Array of array of [x,y] points
15
15
  * @param {object} [options]
16
16
  * @param {Array<number>|string} [options.color] - Array of 3 elements (R, G, B) or a valid css color.
17
17
  * @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask
@@ -11,7 +11,7 @@ var _color = require("../../util/color");
11
11
  * Paint polylines on the current image.
12
12
  * @memberof Image
13
13
  * @instance
14
- * @param {Array<Array<number>>} polylines - Array of array of [x,y] points
14
+ * @param {Array<Array<Array<number>>>} polylines - Array of array of [x,y] points
15
15
  * @param {object} [options]
16
16
  * @param {Array<number>|string} [options.color] - Array of 3 elements (R, G, B) or a valid css color.
17
17
  * @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "image-js",
3
- "version": "0.35.0",
3
+ "version": "0.35.2",
4
4
  "description": "Image processing and manipulation in JavaScript",
5
5
  "keywords": [
6
6
  "image",
@@ -81,7 +81,7 @@
81
81
  "@swiftcarrot/color-fns": "^3.2.0",
82
82
  "blob-util": "^2.0.2",
83
83
  "canny-edge-detector": "^1.0.0",
84
- "fast-bmp": "^1.0.0",
84
+ "fast-bmp": "^2.0.1",
85
85
  "fast-jpeg": "^1.0.1",
86
86
  "fast-list": "^1.0.3",
87
87
  "fast-png": "^6.1.0",
@@ -2,15 +2,15 @@ import { css2array } from '../../util/color';
2
2
  import { RGB } from '../model/model';
3
3
 
4
4
  /**
5
- * Paint a mask or masks on the current image.
5
+ * Paint a label or labels on the current image.
6
6
  * @memberof Image
7
7
  * @instance
8
8
  *
9
- * @param {Array<string>} [labels] - Array of labels to display. Should the the same size as masks.
10
- * @param {Array<Array>} [positions] - Array of labels to display. Should the the same size as masks.
11
- * @param {object} [options]
12
- * @param {number[]|string} [options.color='red'] - Array of 3 elements (R, G, B) or a valid css color.
13
- * @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask
9
+ * @param {Array<string>} [labels] - Array of labels to display.
10
+ * @param {Array<Array<number>>} [positions] - Array of points [x,y] where the labels should be displayed.
11
+ * @param {object} [options]
12
+ * @param {Array<number>|string} [options.color='red'] - Array of 3 elements (R, G, B) or a valid css color.
13
+ * @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each label.
14
14
  * @param {string|Array<string>} [options.font='12px Helvetica'] - Paint the labels in a different CSS style
15
15
  * @param {number|Array<number>} [options.rotate=0] - Rotate each label of a define angle
16
16
  * @return {this} The original painted image
@@ -5,7 +5,7 @@
5
5
  * @param {Array<Array<number>>} points - Array of [x,y] points
6
6
  * @param {object} [options]
7
7
  * @param {Array<number>} [options.color=[max,0,0]] - Array of 3 elements (R, G, B), default is red.
8
- * @param {Array<number>} [options.filled=false] - If you want the polygon to be filled or not.
8
+ * @param {boolean} [options.filled=false] - If you want the polygon to be filled or not.
9
9
  * @return {this} The original painted image
10
10
  */
11
11
  export default function paintPolygon(points, options = {}) {
@@ -1,10 +1,10 @@
1
1
  import { getColors } from '../../util/color';
2
2
 
3
3
  /**
4
- * Paint an array of polygon on the current image.
4
+ * Paint an array of polygons on the current image.
5
5
  * @memberof Image
6
6
  * @instance
7
- * @param {Array<Array<number>>} polygons - Array of array of [x,y] points
7
+ * @param {Array<Array<Array<number>>>} polygons - Array of array of [x,y] points
8
8
  * @param {object} [options]
9
9
  * @param {Array<number>|string} [options.color] - Array of 3 elements (R, G, B) or a valid css color.
10
10
  * @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask
@@ -4,7 +4,7 @@ import { getColors } from '../../util/color';
4
4
  * Paint polylines on the current image.
5
5
  * @memberof Image
6
6
  * @instance
7
- * @param {Array<Array<number>>} polylines - Array of array of [x,y] points
7
+ * @param {Array<Array<Array<number>>>} polylines - Array of array of [x,y] points
8
8
  * @param {object} [options]
9
9
  * @param {Array<number>|string} [options.color] - Array of 3 elements (R, G, B) or a valid css color.
10
10
  * @param {Array<Array<number>>|Array<string>} [options.colors] - Array of Array of 3 elements (R, G, B) for each color of each mask