@@ -15,22 +15,22 @@ export interface AlignDifferentSizeOptions {
15
15
* Mask of the source image, which specifies the pixels to consider for the calculation.
16
16
* @default Mask with the dimensions of source and all pixels set to 1.
17
17
*/
18
- sourceMask ?: Image ;
18
+ sourceMask ?: Mask ;
19
19
}
20
20
21
21
/**
22
- * Compute the difference between two images that are not entirely overlapping and normalise it using the nb of pixels processed .
22
+ * Compute the difference between two images that are not entirely overlapping and normalise it using the nb of pixels overlapping .
23
23
* Only the pixels present in both images are taken into account.
24
24
* @param source - Source image.
25
25
* @param destination - Destination image.
26
- * @param translation - Translation to apply on the source image before computing the difference.
26
+ * @param sourceTranslation - Translation to apply on the source image before computing the difference.
27
27
* @param options - Options.
28
28
* @returns The normalised difference.
29
29
*/
30
30
export function getNormalisedDifference (
31
31
source : Image ,
32
32
destination : Image ,
33
- translation : Point ,
33
+ sourceTranslation : Point ,
34
34
options : AlignDifferentSizeOptions = { } ,
35
35
) : number {
36
36
const {
@@ -58,22 +58,28 @@ export function getNormalisedDifference(
58
58
let destinationXOffset = 0 ;
59
59
let destinationYOffset = 0 ;
60
60
61
- if ( translation . column < 0 ) {
62
- sourceXOffet = - translation . column ;
61
+ if ( sourceTranslation . column < 0 ) {
62
+ sourceXOffet = - sourceTranslation . column ;
63
63
} else {
64
- destinationXOffset = translation . column ;
64
+ destinationXOffset = sourceTranslation . column ;
65
65
}
66
66
67
- if ( translation . row < 0 ) {
68
- sourceYOffset = - translation . row ;
67
+ if ( sourceTranslation . row < 0 ) {
68
+ sourceYOffset = - sourceTranslation . row ;
69
69
} else {
70
- destinationYOffset = translation . row ;
70
+ destinationYOffset = sourceTranslation . row ;
71
71
}
72
72
73
- const maxX = Math . min ( destination . width , source . width + translation . column ) ;
74
- const minX = Math . max ( 0 , translation . column ) ;
75
- const maxY = Math . min ( destination . height , source . height + translation . row ) ;
76
- const minY = Math . max ( 0 , translation . row ) ;
73
+ const maxX = Math . min (
74
+ destination . width ,
75
+ source . width + sourceTranslation . column ,
76
+ ) ;
77
+ const minX = Math . max ( 0 , sourceTranslation . column ) ;
78
+ const maxY = Math . min (
79
+ destination . height ,
80
+ source . height + sourceTranslation . row ,
81
+ ) ;
82
+ const minY = Math . max ( 0 , sourceTranslation . row ) ;
77
83
78
84
const width = maxX - minX ;
79
85
const height = maxY - minY ;
0 commit comments