|
2 | 2 |
|
3 | 3 | This library has been freely inspired from [imgaug](https://github.com/aleju/imgaug) |
4 | 4 |
|
5 | | -It is made to work with [hasard](https://www.npmjs.com/package/hasard) |
6 | | - |
7 | | -## Simple Example |
8 | | - |
9 | | -```javascript |
10 | | -const ia = require('image-augment'); |
11 | | - |
12 | | -// random example images |
13 | | -const images = new Array(50).fill(1).map( () => { |
14 | | - return new ia.RandomImage({ |
15 | | - width: 128 |
16 | | - height: 128 |
17 | | - }); |
18 | | -}; |
19 | | - |
20 | | -const sometimes = ((aug) => ia.sometimes({p : 0.5, augmenter: aug})) |
21 | | - |
22 | | -const seq = new ia.Sequential({ |
23 | | - sequence : [ |
24 | | - new ia.Fliplr({p: 0.5}), |
25 | | - new ia.Flipud({p: 0.5}), |
26 | | - sometimes(new ia.CropAndPad( |
27 | | - p:[-0.05, 0.1], |
28 | | - padMode:ia.ALL, |
29 | | - padCval: [0, 255] |
30 | | - )), |
31 | | - sometimes(new ia.Affine({ |
32 | | - scale:{"x": [0.8, 1.2], "y": [0.8, 1.2]},// scale images to 80-120% of their size, individually per axis |
33 | | - translate_percent:{"x": [-0.2, 0.2], "y": [-0.2, 0.2]}, // translate by -20 to +20 percent (per axis) |
34 | | - rotate:[-45, 45], // rotate by -45 to +45 degrees |
35 | | - shear:[-16, 16], // shear by -16 to +16 degrees |
36 | | - order:[0, 1], // use nearest neighbour or bilinear interpolation (fast) |
37 | | - cval:[0, 255], // if mode is constant, use a cval between 0 and 255 |
38 | | - mode:ia.ALL // use any of scikit-image's warping modes (see 2nd image from the top for examples) |
39 | | - )) |
40 | | - ], |
41 | | - randomOrder : true |
42 | | -}) |
43 | | - |
44 | | -augmented = seq.augmentImagesAsync(images) |
45 | | -``` |
| 5 | +It is made to work with [hasard](https://www.npmjs.com/package/hasard) and [opencv4nodejs](https://github.com/justadudewhohacks/opencv4nodejs) |
0 commit comments