1mlib_ImageNormCrossCorrel(3mMeLdIiBa)Lib Library Funcmtliiobn_sImageNormCrossCorrel(3MLIB)
2
3
4

NAME

6       mlib_ImageNormCrossCorrel - normalized cross correlation
7

SYNOPSIS

9       cc [ flag... ] file... -lmlib [ library... ]
10       #include <mlib.h>
11
12       mlib_status mlib_ImageNormCrossCorrel(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() function computes the normalized cross-
19       correlation coefficients between a pair of  images,  on  a  per-channel
20       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_BYTE, MLIB_SHORT, MLIB_USHORT or MLIB_INT.
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

PARAMETERS

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

RETURN VALUES

118       The function returns MLIB_SUCCESS if successful. Otherwise  it  returns
119       MLIB_FAILURE.
120

ATTRIBUTES

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

SEE ALSO

136       mlib_ImageAutoCorrel(3MLIB),            mlib_ImageAutoCorrel_Fp(3MLIB),
137       mlib_ImageCrossCorrel(3MLIB),          mlib_ImageCrossCorrel_Fp(3MLIB),
138       mlib_ImageNormCrossCorrel_Fp(3MLIB), attributes(5)
139
140
141
142SunOS 5.11                        2 Mar 2007  mlib_ImageNormCrossCorrel(3MLIB)
Impressum