This repository was archived by the owner on Jul 26, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +53
-18
lines changed Expand file tree Collapse file tree 4 files changed +53
-18
lines changed Original file line number Diff line number Diff line change 4
4
} from 'ml-convolution' ;
5
5
6
6
import { Image } from '../Image' ;
7
+ import { extendBorders } from '../operations/extendBorders' ;
7
8
import { getClamp } from '../utils/clamp' ;
8
- import { extendBorders } from '../utils/extendBorders' ;
9
9
import { getIndex } from '../utils/getIndex' ;
10
10
import { getOutputImage } from '../utils/getOutputImage' ;
11
11
import { BorderType , getBorderInterpolation } from '../utils/interpolateBorder' ;
Original file line number Diff line number Diff line change 1
1
import { extendBorders } from '../extendBorders' ;
2
2
3
+ test ( 'grey image with basic value' , ( ) => {
4
+ const image = testUtils . createGreyImage ( `
5
+ 1 2
6
+ 3 4
7
+ 5 6
8
+ 7 8
9
+ ` ) ;
10
+
11
+ const newImage = extendBorders ( image , {
12
+ horizontal : 1 ,
13
+ vertical : 1 ,
14
+ borderType : 'constant' ,
15
+ } ) ;
16
+ expect ( newImage ) . toMatchImageData ( `
17
+ 0 0 0 0
18
+ 0 1 2 0
19
+ 0 3 4 0
20
+ 0 5 6 0
21
+ 0 7 8 0
22
+ 0 0 0 0
23
+ ` ) ;
24
+ } ) ;
25
+
3
26
test ( 'grey image with wrap' , ( ) => {
4
27
const image = testUtils . createGreyImage ( `
5
28
1 2 3 4
@@ -8,26 +31,24 @@ test('grey image with wrap', () => {
8
31
4 5 6 7
9
32
5 6 7 8
10
33
` ) ;
11
-
12
34
const newImage = extendBorders ( image , {
13
35
horizontal : 2 ,
14
36
vertical : 3 ,
15
37
borderType : 'wrap' ,
16
38
} ) ;
17
-
18
39
expect ( newImage ) . toMatchImageData ( `
19
- 5 6 3 4 5 6 3 4
20
- 6 7 4 5 6 7 4 5
21
- 7 8 5 6 7 8 5 6
22
- 3 4 1 2 3 4 1 2
23
- 4 5 2 3 4 5 2 3
24
- 5 6 3 4 5 6 3 4
25
- 6 7 4 5 6 7 4 5
26
- 7 8 5 6 7 8 5 6
27
- 3 4 1 2 3 4 1 2
28
- 4 5 2 3 4 5 2 3
29
- 5 6 3 4 5 6 3 4
30
- `) ;
40
+ 5 6 3 4 5 6 3 4
41
+ 6 7 4 5 6 7 4 5
42
+ 7 8 5 6 7 8 5 6
43
+ 3 4 1 2 3 4 1 2
44
+ 4 5 2 3 4 5 2 3
45
+ 5 6 3 4 5 6 3 4
46
+ 6 7 4 5 6 7 4 5
47
+ 7 8 5 6 7 8 5 6
48
+ 3 4 1 2 3 4 1 2
49
+ 4 5 2 3 4 5 2 3
50
+ 5 6 3 4 5 6 3 4
51
+ ` ) ;
31
52
} ) ;
32
53
33
54
test ( 'rgb image with default border type' , ( ) => {
Original file line number Diff line number Diff line change 1
1
import { Image } from '../Image' ;
2
+ import { BorderType , getBorderInterpolation } from '../utils/interpolateBorder' ;
2
3
3
- import { BorderType , getBorderInterpolation } from './interpolateBorder' ;
4
-
5
- interface ExtendBordersOptions {
4
+ export interface ExtendBordersOptions {
5
+ /**
6
+ * Left and right border thickness.
7
+ */
6
8
horizontal : number ;
9
+ /**
10
+ *Top and bottom border thickness.
11
+ */
7
12
vertical : number ;
13
+ /**
14
+ * Specify how the borders should be handled.
15
+ * @default `'reflect101'`
16
+ */
8
17
borderType ?: BorderType ;
18
+ /**
19
+ * Value of the border if BorderType is 'constant'.
20
+ * @default `0`
21
+ */
9
22
borderValue ?: number ;
10
23
}
11
24
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ export * from './operations.types';
13
13
export * from './paintMaskOnImage' ;
14
14
export * from './paintMaskOnMask' ;
15
15
export * from './correctBackground' ;
16
+ export * from './extendBorders' ;
You can’t perform that action at this time.
0 commit comments