src/pixarith.c
PIX *
pixAbsDifference(PIX  *pixs1,
                 PIX  *pixs2)
{
l_int32    w, h, w2, h2, d, wpls, wpld;
l_uint32  *datas1, *datas2, *datad;
PIX       *pixd;

    PROCNAME("pixAbsDifference");

    if (!pixs1)
        return (PIX *)ERROR_PTR("pixs1 not defined", procName, NULL);
    if (!pixs2)
        return (PIX *)ERROR_PTR("pixs2 not defined", procName, NULL);
    d = pixGetDepth(pixs1);
    if (d != pixGetDepth(pixs2))
        return (PIX *)ERROR_PTR("src1 and src2 depths unequal", procName, NULL);
    if (d != 8 && d != 16 && d != 32)
        return (PIX *)ERROR_PTR("depths not in {8, 16, 32}", procName, NULL);

    pixGetDimensions(pixs1, &w, &h, NULL);
    pixGetDimensions(pixs2, &w2, &h2, NULL);
    w = L_MIN(w, w2);
    h = L_MIN(h, h2);
    if ((pixd = pixCreate(w, h, d)) == NULL)
        return (PIX *)ERROR_PTR("pixd not made", procName, NULL);
    pixCopyResolution(pixd, pixs1);
    datas1 = pixGetData(pixs1);
    datas2 = pixGetData(pixs2);
    datad = pixGetData(pixd);
    wpls = pixGetWpl(pixs1);
    wpld = pixGetWpl(pixd);

    absDifferenceLow(datad, w, h, wpld, datas1, datas2, d, wpls);

    return pixd;
}
/*!
 *  pixAbsDifference()
 *
 *      Input:  pixs1, pixs2  (both either 8 or 16 bpp gray, or 32 bpp RGB)
 *      Return: pixd, or null on error
 *
 *  Notes:
 *      (1) The depth of pixs1 and pixs2 must be equal.
 *      (2) Clips computation to the min size, aligning the UL corners
 *      (3) For 8 and 16 bpp, assumes one gray component.
 *      (4) For 32 bpp, assumes 3 color components, and ignores the
 *          LSB of each word (the alpha channel)
 *      (5) Computes the absolute value of the difference between
 *          each component value.
 */
pixAbsDifference()
Input:  pixs1, pixs2  (both either 8 or 16 bpp gray, or 32 bpp RGB)
Return: pixd, or null on error

(1) The depth of pixs1 and pixs2 must be equal.
(2) Clips computation to the min size, aligning the UL corners
(3) For 8 and 16 bpp, assumes one gray component.
(4) For 32 bpp, assumes 3 color components, and ignores the
LSB of each word (the alpha channel)
(5) Computes the absolute value of the difference between
each component value.
pixAbsDifference () Input : pixs1 pixs2 ( both either 8 or 16 bpp gray or 32 bpp RGB ) Return : pixd or null on error ( 1 ) The depth of pixs1 and pixs2 must be equal . ( 2 ) Clips computation to the min size aligning the UL corners ( 3 ) For 8 and 16 bpp assumes one gray component . ( 4 ) For 32 bpp assumes 3 color components and ignores the LSB of each word ( the alpha channel ) ( 5 ) Computes the absolute value of the difference between each component value .
PIX *
pixAbsDifference(PIX  *pixs1,
                 PIX  *pixs2)
{
l_int32    w, h, w2, h2, d, wpls, wpld;
l_uint32  *datas1, *datas2, *datad;
PIX       *pixd;
    PROCNAME("pixAbsDifference");
    if (!pixs1)
        return (PIX *)ERROR_PTR("pixs1 not defined", procName, NULL);
    if (!pixs2)
        return (PIX *)ERROR_PTR("pixs2 not defined", procName, NULL);
    d = pixGetDepth(pixs1);
    if (d != pixGetDepth(pixs2))
        return (PIX *)ERROR_PTR("src1 and src2 depths unequal", procName, NULL);
    if (d != 8 && d != 16 && d != 32)
        return (PIX *)ERROR_PTR("depths not in {8, 16, 32}", procName, NULL);
    pixGetDimensions(pixs1, &w, &h, NULL);
    pixGetDimensions(pixs2, &w2, &h2, NULL);
    w = L_MIN(w, w2);
    h = L_MIN(h, h2);
    if ((pixd = pixCreate(w, h, d)) == NULL)
        return (PIX *)ERROR_PTR("pixd not made", procName, NULL);
    pixCopyResolution(pixd, pixs1);
    datas1 = pixGetData(pixs1);
    datas2 = pixGetData(pixs2);
    datad = pixGetData(pixd);
    wpls = pixGetWpl(pixs1);
    wpld = pixGetWpl(pixd);
    absDifferenceLow(datad, w, h, wpld, datas1, datas2, d, wpls);
    return pixd;
}
PIX * pixAbsDifference ( PIX * pixs1 , PIX * pixs2 ) { l_int32 w , h , w2 , h2 , d , wpls , wpld ; l_uint32 * datas1 , * datas2 , * datad ; PIX * pixd ; PROCNAME ( " " ) ; if ( ! pixs1 ) return ( PIX * ) ERROR_PTR ( " " , procName , NULL ) ; if ( ! pixs2 ) return ( PIX * ) ERROR_PTR ( " " , procName , NULL ) ; d = pixGetDepth ( pixs1 ) ; if ( d != pixGetDepth ( pixs2 ) ) return ( PIX * ) ERROR_PTR ( " " , procName , NULL ) ; if ( d != 8 && d != 16 && d != 32 ) return ( PIX * ) ERROR_PTR ( " " , procName , NULL ) ; pixGetDimensions ( pixs1 , & w , & h , NULL ) ; pixGetDimensions ( pixs2 , & w2 , & h2 , NULL ) ; w = L_MIN ( w , w2 ) ; h = L_MIN ( h , h2 ) ; if ( ( pixd = pixCreate ( w , h , d ) ) == NULL ) return ( PIX * ) ERROR_PTR ( " " , procName , NULL ) ; pixCopyResolution ( pixd , pixs1 ) ; datas1 = pixGetData ( pixs1 ) ; datas2 = pixGetData ( pixs2 ) ; datad = pixGetData ( pixd ) ; wpls = pixGetWpl ( pixs1 ) ; wpld = pixGetWpl ( pixd ) ; absDifferenceLow ( datad , w , h , wpld , datas1 , datas2 , d , wpls ) ; return pixd ; }
pixAbsDifference()
      Input:  pixs1, pixs2  (both either 8 or 16 bpp gray, or 32 bpp RGB)
      Return: pixd, or null on error
pixAbsDifference () Input : pixs1 pixs2 ( both either 8 or 16 bpp gray or 32 bpp RGB ) Return : pixd or null on error