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 44} from 'ml-convolution' ;
55
66import { Image } from '../Image' ;
7+ import { extendBorders } from '../operations/extendBorders' ;
78import { getClamp } from '../utils/clamp' ;
8- import { extendBorders } from '../utils/extendBorders' ;
99import { getIndex } from '../utils/getIndex' ;
1010import { getOutputImage } from '../utils/getOutputImage' ;
1111import { BorderType , getBorderInterpolation } from '../utils/interpolateBorder' ;
Original file line number Diff line number Diff line change 11import { extendBorders } from '../extendBorders' ;
22
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+
326test ( 'grey image with wrap' , ( ) => {
427 const image = testUtils . createGreyImage ( `
528 1 2 3 4
@@ -8,26 +31,24 @@ test('grey image with wrap', () => {
831 4 5 6 7
932 5 6 7 8
1033 ` ) ;
11-
1234 const newImage = extendBorders ( image , {
1335 horizontal : 2 ,
1436 vertical : 3 ,
1537 borderType : 'wrap' ,
1638 } ) ;
17-
1839 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+ ` ) ;
3152} ) ;
3253
3354test ( 'rgb image with default border type' , ( ) => {
Original file line number Diff line number Diff line change 11import { Image } from '../Image' ;
2+ import { BorderType , getBorderInterpolation } from '../utils/interpolateBorder' ;
23
3- import { BorderType , getBorderInterpolation } from './interpolateBorder' ;
4-
5- interface ExtendBordersOptions {
4+ export interface ExtendBordersOptions {
5+ /**
6+ * Left and right border thickness.
7+ */
68 horizontal : number ;
9+ /**
10+ *Top and bottom border thickness.
11+ */
712 vertical : number ;
13+ /**
14+ * Specify how the borders should be handled.
15+ * @default `'reflect101'`
16+ */
817 borderType ?: BorderType ;
18+ /**
19+ * Value of the border if BorderType is 'constant'.
20+ * @default `0`
21+ */
922 borderValue ?: number ;
1023}
1124
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ export * from './operations.types';
1313export * from './paintMaskOnImage' ;
1414export * from './paintMaskOnMask' ;
1515export * from './correctBackground' ;
16+ export * from './extendBorders' ;
You can’t perform that action at this time.
0 commit comments