1
+ import { overlapImages } from '../../featureMatching' ;
1
2
import { align } from '../align' ;
2
3
3
4
test ( '1 pixel source' , ( ) => {
@@ -15,3 +16,60 @@ test('1 pixel source', () => {
15
16
const result = align ( source , destination ) ;
16
17
expect ( result ) . toStrictEqual ( { row : 2 , column : 1 } ) ;
17
18
} ) ;
19
+ test ( '4 pixels source' , ( ) => {
20
+ const source = testUtils . createGreyImage ( [
21
+ [ 0 , 80 ] ,
22
+ [ 150 , 200 ] ,
23
+ ] ) ;
24
+ const destination = testUtils . createGreyImage ( [
25
+ [ 0 , 0 , 0 ] ,
26
+ [ 0 , 0 , 100 ] ,
27
+ [ 0 , 255 , 255 ] ,
28
+ ] ) ;
29
+
30
+ const result = align ( source , destination , { blurKernelSize : 1 } ) ;
31
+ expect ( result ) . toStrictEqual ( {
32
+ row : 1 ,
33
+ column : 1 ,
34
+ } ) ;
35
+ } ) ;
36
+
37
+ test ( 'twice same image' , ( ) => {
38
+ const source = testUtils . load ( 'opencv/test.png' ) . grey ( ) ;
39
+
40
+ const destination = testUtils . load ( 'opencv/test.png' ) . grey ( ) ;
41
+
42
+ const result = align ( source , destination ) ;
43
+ expect ( result ) . toStrictEqual ( { row : 0 , column : 0 } ) ;
44
+ } ) ;
45
+
46
+ test ( 'larger image and crop' , ( ) => {
47
+ const side = 100 ;
48
+ const origin = { row : 30 , column : 30 } ;
49
+ const destination = testUtils . load ( 'ssim/ssim-original.png' ) ;
50
+ const source = destination . crop ( { origin, width : side , height : side } ) ;
51
+
52
+ const result = align ( source , destination ) ;
53
+
54
+ expect ( result ) . toStrictEqual ( origin ) ;
55
+ } ) ;
56
+
57
+ test ( 'id crops' , ( ) => {
58
+ const destination = testUtils . load ( 'align/cropped.png' ) . grey ( ) ;
59
+ const source = testUtils . load ( 'align/croppedRef.png' ) . grey ( ) ;
60
+
61
+ const result = align ( source , destination ) ;
62
+
63
+ const overlap = overlapImages ( source , destination , { origin : result } ) ;
64
+
65
+ expect ( overlap ) . toMatchImageSnapshot ( ) ;
66
+ } ) ;
67
+
68
+ test ( 'other id crops' , ( ) => {
69
+ const destination = testUtils . load ( 'align/cropped1.png' ) . grey ( ) ;
70
+ const source = testUtils . load ( 'align/croppedRef1.png' ) . grey ( ) ;
71
+ const result = align ( source , destination , { level : 'uniform' } ) ;
72
+
73
+ const overlap = overlapImages ( source , destination , { origin : result } ) ;
74
+ expect ( overlap ) . toMatchImageSnapshot ( ) ;
75
+ } ) ;
0 commit comments