CORRELATE

##
CORRELATE

            CORRELATE

        Computes  correlation of two images or data cubes.  The result is an im-
        age (data cube) containing

            Out(i,j) = < In1(k-i,l-j)*In2(k,l) >         averaged over k,l
            For mode correlation (MODE$ = YES)
        or
            Out(i,j) = - < In1(k-i,l-j)**2 + In2(k,l)**2
                         - 2 * In1(k-i,l-j)*In2(k,l) >   averaged over k,l
            For mode square (MODE$ = NO). The correlation is higher when
            Out(i,j) is near 0. With the minus sign, this means that maximum
            values indicate highest correlations.

        Actually, linear conversion formulas are used to  keep  the  correlation
        image meaningful in user coordinates.  The input images must match.

        When used for example to recenter images, the position of the maximum of
        the correlation image yields the required recentering. MODE$ YES (Corre-
        lation)  is  to be used when the input distribution has a finite extent,
        while MODE$ NO (Square) can be used in any case, but is somewhat  slower
        of course.