MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


mediaLib Library Functions       mlibImageNormCrossCorrel(3MLIB)



NAME
     mlibImageNormCrossCorrel - normalized cross correlation

SYNOPSIS
     cc [ flag... ] file... -lmlib [ library... ]
     #include 

     mlibstatus mlibImageNormCrossCorrel(mlibd64 *correl,
          const mlibimage *img1, const mlibimage *img2, const mlibd64 *mean2,
          const mlibd64 *sdev2);


DESCRIPTION
     The mlibImageNormCrossCorrel() function computes  the  nor-
     malized  cross-correlation  coefficients  between  a pair of
     images, on a per-channel basis.


     It uses the following equations:

                      w-1 h-1
                      SUM SUM (d1[x][y][i] * d2[x][y][i])
                      x=0 y=0
         correl[i] = -------------------------------------
                                s1[i] * s2[i]

       d1[x][y][i] = img1[x][y][i] - m1[i]

       d2[x][y][i] = img2[x][y][i] - m2[i]

                       1     w-1 h-1
             m1[i] = ----- * SUM SUM img1[x][y][i]
                      w*h    x=0 y=0

                       1     w-1 h-1
             m2[i] = ----- * SUM SUM img2[x][y][i]
                      w*h    x=0 y=0

                           w-1 h-1
             s1[i] = sqrt{ SUM SUM (img1[x][y][i] - m1[i])**2 }
                           x=0 y=0

                           w-1 h-1
             s2[i] = sqrt{ SUM SUM (img2[x][y][i] - m2[i])**2 }
                           x=0 y=0



     where w and h are  the  width  and  height  of  the  images,
     respectively; m1 and m2 are the mean arrays of the first and
     second images, respectively; s1 and s2 are the un-normalized
     standard  deviation  arrays  of the first and second images,



SunOS 5.11           Last change: 2 Mar 2007                    1






mediaLib Library Functions       mlibImageNormCrossCorrel(3MLIB)



     respectively.


     In usual cases, the normalized cross-correlation coefficient
     is in the range of [-1.0, 1.0].  In the case of (s1[i] == 0)
     or (s2[i] == 0), where a constant image channel is involved,
     the  normalized  cross-correlation coefficient is defined as
     follows:

           #define signof(x) ((x > 0) ? 1 : ((x < 0) ? -1 : 0))

           if ((s1[i] == 0.)  (s2[i] == 0.)) {
               if ((s1[i] == 0.) && (s2[i] == 0.)) {
                  if (signof(m1[i]) == signof(m2[i]) {
                      correl[i] = 1.0;
                  } else {
                      correl[i] = -1.0;
                  }
               } else {
                   correl[i] = -1.0;
               }
           }



     The two images must have the same type, the same  size,  and
     the  same  number  of  channels.  They can have 1, 2, 3 or 4
     channels.  They  can  be  of  type  MLIBYTE,   MLIBSHORT,
     MLIBUSHORT or MLIBINT.


     If (mean2 == NUL) or (sdev2 == NUL), then m2  and  s2  are
     calculated  in this function according to the formulas shown
     above.  Otherwise, they are calculated as follows:

           m2[i] = mean2[i];
           s2[i] = sdev2[i] * sqrt(w*h);



     where mean2 and sdev2 can be the output of  mlibImageMean()
     and mlibImageStdDev(), respectively.

PARAMETERS
     The function takes the following arguments:

     correl    Pointer to normalized cross correlation array on a
               channel basis. The array must be the size of chan-
               nels in the images. correl[i] contains the  cross-
               correlation of channel i.





SunOS 5.11           Last change: 2 Mar 2007                    2






mediaLib Library Functions       mlibImageNormCrossCorrel(3MLIB)



     img1      Pointer to first image.


     img2      Pointer to second image.


     mean2     Pointer to the mean array of the second image.


     sdev2     Pointer to the standard  deviation  array  of  the
               second image.


RETURN VALUES
     The function returns MLIBSUCES if  successful.  Otherwise
     it returns MLIBFAILURE.

ATRIBUTES
     See attributes(5) for descriptions of the  following  attri-
     butes:



     
           ATRIBUTE TYPE               ATRIBUTE VALUE       
    
     Interface Stability          Committed                   
    
     MT-Level                     MT-Safe                     
    


SEE ALSO
     mlibImageAutoCorrel(3MLIB), mlibImageAutoCorrelFp(3MLIB),
     mlibImageCrossCorrel(3MLIB),
     mlibImageCrossCorrelFp(3MLIB),
     mlibImageNormCrossCorrelFp(3MLIB), attributes(5)


















SunOS 5.11           Last change: 2 Mar 2007                    3



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™