src/projective.c
PIX *
pixProjectivePtaGammaXform(PIX       *pixs,
                           l_float32  gamma,
                           PTA       *ptad,
                           PTA       *ptas,
                           l_float32  fract,
                           l_int32    border)
{
PIX  *pixg, *pixd;

    PROCNAME("pixProjectivePtaGammaXform");

    if (!pixs || (pixGetDepth(pixs) != 32))
        return (PIX *)ERROR_PTR("pixs undefined or not 32 bpp", procName, NULL);
    if (fract == 0.0)
        L_WARNING("fully opaque alpha; image cannot be blended", procName);
    if (gamma <= 0.0)  {
        L_WARNING("gamma must be > 0.0; setting to 1.0", procName);
        gamma = 1.0;
    }

    pixg = pixGammaTRCWithAlpha(NULL, pixs, 1.0 / gamma, 0, 255);
    pixd = pixProjectivePtaWithAlpha(pixg, ptad, ptas, NULL, fract, border);
    pixGammaTRCWithAlpha(pixd, pixd, gamma, 0, 255);
    pixDestroy(&pixg);
    return pixd;
}
/*!
 *  pixProjectivePtaGammaXform()
 *
 *      Input:  pixs (32 bpp rgb)
 *              gamma (gamma correction; must be > 0.0)
 *              ptad  (3 pts of final coordinate space)
 *              ptas  (3 pts of initial coordinate space)
 *              fract (between 0.0 and 1.0, with 1.0 fully transparent)
 *              border (of pixels to capture transformed source pixels)
 *      Return: pixd, or null on error
 *
 *  Notes:
 *      (1) This wraps a gamma/inverse-gamma photometric transform around
 *          pixProjectivePtaWithAlpha().
 *      (2) For usage, see notes in pixProjectivePtaWithAlpha() and
 *          pixGammaTRCWithAlpha().
 *      (3) The basic idea of a gamma/inverse-gamma transform is to remove
 *          any gamma correction before the projective transform, and restore
 *          it afterward.  The effects can be subtle, but important for
 *          some applications.  For example, using gamma > 1.0 will
 *          cause the dark areas to become somewhat lighter and slightly
 *          reduce aliasing effects when blending using the alpha channel.
 */


(1) This wraps a gamma/inverse-gamma photometric transform around
pixProjectivePtaWithAlpha().
(2) For usage, see notes in pixProjectivePtaWithAlpha() and
pixGammaTRCWithAlpha().
(3) The basic idea of a gamma/inverse-gamma transform is to remove
any gamma correction before the projective transform, and restore
it afterward.  The effects can be subtle, but important for
some applications.  For example, using gamma > 1.0 will
cause the dark areas to become somewhat lighter and slightly
reduce aliasing effects when blending using the alpha channel.
( 1 ) This wraps a gamma / inverse - gamma photometric transform around pixProjectivePtaWithAlpha () . ( 2 ) For usage see notes in pixProjectivePtaWithAlpha () and pixGammaTRCWithAlpha () . ( 3 ) The basic idea of a gamma / inverse - gamma transform is to remove any gamma correction before the projective transform and restore it afterward . The effects can be subtle but important for some applications . For example using gamma > 1 . 0 will cause the dark areas to become somewhat lighter and slightly reduce aliasing effects when blending using the alpha channel .
PIX *
pixProjectivePtaGammaXform(PIX       *pixs,
                           l_float32  gamma,
                           PTA       *ptad,
                           PTA       *ptas,
                           l_float32  fract,
                           l_int32    border)
{
PIX  *pixg, *pixd;
    PROCNAME("pixProjectivePtaGammaXform");
    if (!pixs || (pixGetDepth(pixs) != 32))
        return (PIX *)ERROR_PTR("pixs undefined or not 32 bpp", procName, NULL);
    if (fract == 0.0)
        L_WARNING("fully opaque alpha; image cannot be blended", procName);
    if (gamma <= 0.0)  {
        L_WARNING("gamma must be > 0.0; setting to 1.0", procName);
        gamma = 1.0;
    }
    pixg = pixGammaTRCWithAlpha(NULL, pixs, 1.0 / gamma, 0, 255);
    pixd = pixProjectivePtaWithAlpha(pixg, ptad, ptas, NULL, fract, border);
    pixGammaTRCWithAlpha(pixd, pixd, gamma, 0, 255);
    pixDestroy(&pixg);
    return pixd;
}
PIX * pixProjectivePtaGammaXform ( PIX * pixs , l_float32 gamma , PTA * ptad , PTA * ptas , l_float32 fract , l_int32 border ) { PIX * pixg , * pixd ; PROCNAME ( " " ) ; if ( ! pixs || ( pixGetDepth ( pixs ) != 32 ) ) return ( PIX * ) ERROR_PTR ( " " , procName , NULL ) ; if ( fract == 0.0 ) L_WARNING ( " " , procName ) ; if ( gamma <= 0.0 ) { L_WARNING ( " " , procName ) ; gamma = 1.0 ; } pixg = pixGammaTRCWithAlpha ( NULL , pixs , 1.0 / gamma , 0 , 255 ) ; pixd = pixProjectivePtaWithAlpha ( pixg , ptad , ptas , NULL , fract , border ) ; pixGammaTRCWithAlpha ( pixd , pixd , gamma , 0 , 255 ) ; pixDestroy ( & pixg ) ; return pixd ; }
pixProjectivePtaGammaXform()
      Input:  pixs (32 bpp rgb)
              gamma (gamma correction; must be > 0.0)
              ptad  (3 pts of final coordinate space)
              ptas  (3 pts of initial coordinate space)
              fract (between 0.0 and 1.0, with 1.0 fully transparent)
              border (of pixels to capture transformed source pixels)
      Return: pixd, or null on error
pixProjectivePtaGammaXform () Input : pixs ( 32 bpp rgb ) gamma ( gamma correction ; must be > 0 . 0 ) ptad ( 3 pts of final coordinate space ) ptas ( 3 pts of initial coordinate space ) fract ( between 0 . 0 and 1 . 0 with 1 . 0 fully transparent ) border ( of pixels to capture transformed source pixels ) Return : pixd or null on error