1mlib_ImageNormCrossCorrel_Fmpe(d3iMaLLIiBb)Library Fmulnicbt_iIomnasgeNormCrossCorrel_Fp(3MLIB)
2
3
4

NAME

6       mlib_ImageNormCrossCorrel_Fp - normalized cross correlation
7

SYNOPSIS

9       cc [ flag... ] file... -lmlib [ library... ]
10       #include <mlib.h>
11
12       mlib_status mlib_ImageNormCrossCorrel_Fp(mlib_d64 *correl,
13            const mlib_image *img1, const mlib_image *img2, const mlib_d64 *mean2,
14            const mlib_d64 *sdev2);
15
16

DESCRIPTION

18       The  mlib_ImageNormCrossCorrel_Fp()  function  computes  the normalized
19       cross-correlation coefficients between a pair of floating-point images,
20       on a per-channel basis.
21
22
23       It uses the following equations:
24
25                        w-1 h-1
26                        SUM SUM (d1[x][y][i] * d2[x][y][i])
27                        x=0 y=0
28           correl[i] = -------------------------------------
29                                  s1[i] * s2[i]
30
31         d1[x][y][i] = img1[x][y][i] - m1[i]
32
33         d2[x][y][i] = img2[x][y][i] - m2[i]
34
35                         1     w-1 h-1
36               m1[i] = ----- * SUM SUM img1[x][y][i]
37                        w*h    x=0 y=0
38
39                         1     w-1 h-1
40               m2[i] = ----- * SUM SUM img2[x][y][i]
41                        w*h    x=0 y=0
42
43                             w-1 h-1
44               s1[i] = sqrt{ SUM SUM (img1[x][y][i] - m1[i])**2 }
45                             x=0 y=0
46
47                             w-1 h-1
48               s2[i] = sqrt{ SUM SUM (img2[x][y][i] - m2[i])**2 }
49                             x=0 y=0
50
51
52
53       where  w and h are the width and height of the images, respectively; m1
54       and m2 are the mean arrays of the  first  and  second  images,  respec‐
55       tively;  s1  and  s2 are the un-normalized standard deviation arrays of
56       the first and second images, respectively.
57
58
59       In usual cases, the normalized cross-correlation coefficient is in  the
60       range  of  [-1.0,  1.0].   In the case of (s1[i] == 0) or (s2[i] == 0),
61       where a constant image channel is involved, the normalized cross-corre‐
62       lation coefficient is defined as follows:
63
64             #define signof(x) ((x > 0) ? 1 : ((x < 0) ? -1 : 0))
65
66             if ((s1[i] == 0.) || (s2[i] == 0.)) {
67                 if ((s1[i] == 0.) && (s2[i] == 0.)) {
68                    if (signof(m1[i]) == signof(m2[i]) {
69                        correl[i] = 1.0;
70                    } else {
71                        correl[i] = -1.0;
72                    }
73                 } else {
74                     correl[i] = -1.0;
75                 }
76             }
77
78
79
80       The  two  images  must  have the same type, the same size, and the same
81       number of channels. They can have 1, 2, 3 or 4 channels. They can be of
82       type MLIB_FLOAT or MLIB_DOUBLE.
83
84
85       If (mean2 == NULL) or (sdev2 == NULL), then m2 and s2 are calculated in
86       this function according to the formulas shown above.   Otherwise,  they
87       are calculated as follows:
88
89             m2[i] = mean2[i];
90             s2[i] = sdev2[i] * sqrt(w*h);
91
92
93
94       where  mean2  and  sdev2  can  be  the  output  of mlib_ImageMean() and
95       mlib_ImageStdDev(), respectively.
96
97
98       In some cases, the resulting coefficients of  this  function  could  be
99       NaN, Inf, or -Inf.
100

PARAMETERS

102       The function takes the following arguments:
103
104       correl    Pointer  to  normalized  cross correlation array on a channel
105                 basis. The array must be the size of channels in the  images.
106                 correl[i] contains the cross-correlation of channel i.
107
108
109       img1      Pointer to first image.
110
111
112       img2      Pointer to second image.
113
114
115       mean2     Pointer to the mean array of the second image.
116
117
118       sdev2     Pointer to the standard deviation array of the second image.
119
120

RETURN VALUES

122       The  function  returns MLIB_SUCCESS if successful. Otherwise it returns
123       MLIB_FAILURE.
124

ATTRIBUTES

126       See attributes(5) for descriptions of the following attributes:
127
128
129
130
131       ┌─────────────────────────────┬─────────────────────────────┐
132       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
133       ├─────────────────────────────┼─────────────────────────────┤
134       │Interface Stability          │Committed                    │
135       ├─────────────────────────────┼─────────────────────────────┤
136       │MT-Level                     │MT-Safe                      │
137       └─────────────────────────────┴─────────────────────────────┘
138

SEE ALSO

140       mlib_ImageAutoCorrel(3MLIB),            mlib_ImageAutoCorrel_Fp(3MLIB),
141       mlib_ImageCrossCorrel(3MLIB),          mlib_ImageCrossCorrel_Fp(3MLIB),
142       mlib_ImageNormCrossCorrel(3MLIB), attributes(5)
143
144
145
146SunOS 5.11                        2 Mar 2007mlib_ImageNormCrossCorrel_Fp(3MLIB)
Impressum