src/kernel.c
L_KERNEL *
kernelInvert(L_KERNEL  *kels)
{
l_int32    i, j, sx, sy, cx, cy;
L_KERNEL  *keld;

    PROCNAME("kernelInvert");

    if (!kels)
        return (L_KERNEL *)ERROR_PTR("kels not defined", procName, NULL);

    kernelGetParameters(kels, &sy, &sx, &cy, &cx);
    if ((keld = kernelCreate(sy, sx)) == NULL)
        return (L_KERNEL *)ERROR_PTR("keld not made", procName, NULL);
    keld->cy = sy - 1 - cy;
    keld->cx = sx - 1 - cx;

    for (i = 0; i < sy; i++)
        for (j = 0; j < sx; j++)
            keld->data[i][j] = kels->data[sy - 1 - i][sx - 1 - j];

    return keld;
}
/*!
 *  kernelInvert()
 *
 *      Input:  kels (source kel, to be inverted)
 *      Return: keld (spatially inverted, about the origin), or null on error
 *
 *  Notes:
 *      (1) For convolution, the kernel is spatially inverted before
 *          a "correlation" operation is done between the kernel and the image.
 */
kernelInvert()
Input:  kels (source kel, to be inverted)
Return: keld (spatially inverted, about the origin), or null on error

(1) For convolution, the kernel is spatially inverted before
a "correlation" operation is done between the kernel and the image.
kernelInvert () Input : kels ( source kel to be inverted ) Return : keld ( spatially inverted about the origin ) or null on error ( 1 ) For convolution the kernel is spatially inverted before a " correlation " operation is done between the kernel and the image .
L_KERNEL *
kernelInvert(L_KERNEL  *kels)
{
l_int32    i, j, sx, sy, cx, cy;
L_KERNEL  *keld;
    PROCNAME("kernelInvert");
    if (!kels)
        return (L_KERNEL *)ERROR_PTR("kels not defined", procName, NULL);
    kernelGetParameters(kels, &sy, &sx, &cy, &cx);
    if ((keld = kernelCreate(sy, sx)) == NULL)
        return (L_KERNEL *)ERROR_PTR("keld not made", procName, NULL);
    keld->cy = sy - 1 - cy;
    keld->cx = sx - 1 - cx;
    for (i = 0; i < sy; i++)
        for (j = 0; j < sx; j++)
            keld->data[i][j] = kels->data[sy - 1 - i][sx - 1 - j];
    return keld;
}
L_KERNEL * kernelInvert ( L_KERNEL * kels ) { l_int32 i , j , sx , sy , cx , cy ; L_KERNEL * keld ; PROCNAME ( " " ) ; if ( ! kels ) return ( L_KERNEL * ) ERROR_PTR ( " " , procName , NULL ) ; kernelGetParameters ( kels , & sy , & sx , & cy , & cx ) ; if ( ( keld = kernelCreate ( sy , sx ) ) == NULL ) return ( L_KERNEL * ) ERROR_PTR ( " " , procName , NULL ) ; keld -> cy = sy - 1 - cy ; keld -> cx = sx - 1 - cx ; for ( i = 0 ; i < sy ; i ++ ) for ( j = 0 ; j < sx ; j ++ ) keld -> data [ i ] [ j ] = kels -> data [ sy - 1 - i ] [ sx - 1 - j ] ; return keld ; }
kernelInvert()
      Input:  kels (source kel, to be inverted)
      Return: keld (spatially inverted, about the origin), or null on error
kernelInvert () Input : kels ( source kel to be inverted ) Return : keld ( spatially inverted about the origin ) or null on error