IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3714


Ignore:
Timestamp:
Apr 18, 2005, 6:16:02 PM (21 years ago)
Author:
gusciora
Message:

Created tests for inverting linear psPlaneTransforms. Fixed a bug with the
linear transform inversion code.

Location:
trunk/psLib
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psCoord.c

    r3711 r3714  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-04-19 01:22:59 $
     12*  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-04-19 04:16:02 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8484 X1 = (-D + ((F*A)/C)) / (E - ((F*B)/C)) +
    8585      (X2 * -((F/C) / (E - ((F*B)/C)))) +
    86              (Y2 * (1.0 / (E - ((F*B)/C))));
    87         Y1 = (-D + ((E*A)/B))/(F - ((C*E)/B)) +
    88              (X2 * -((E/B) / (F - ((C*E)/B)))) +
    89              (Y2 * (1.0 / (F - ((C*E)/B))));
     86      (Y2 * (1.0 / (E - ((F*B)/C))));
     87 Y1 = (-D + ((E*A)/B))/(F - ((C*E)/B)) +
     88      (X2 * -((E/B) / (F - ((C*E)/B)))) +
     89      (Y2 * (1.0 / (F - ((C*E)/B))));
    9090 
    9191XXX: Since thre is now a general psPlaneTransformInvert() function, we
    9292should rename this.
     93 
     94X1, Y1 = (2, 3)
     95 
     96    X2 = 1 + 4 + 9   = 14
     97    Y2 = 4 + 10 + 18 = 32
     98 
     99in inverse
     100 
     101Y1 = (32 - ((5/2) * 14) - 4 + ((5)/2)) / (6 - ((15)/2));
     102Y1 = (32 - 35 - 4 + (5/2)) / (6 - 15/2);
     103Y1 = (-7 + (5/2)) / (12/2 - 15/2);
     104Y1 = (-7 + (5/2)) / (-3/2);
     105Y1 = (-14/2 + 5/2) / (-3/2);
     106Y1 = (-9/2) / (-3/2);
     107Y1 = (9/2) / (3/2);
     108Y1 = 3
     109 
     110X1 = (Y2 - ((F/C) * X2) - D + ((F*A)/C)) / (E - ((F*B)/C));
     111X1 = (32 - ((6/3) * 14) - 4 + ((6)/3)) / (5 - ((12)/3));
     112X1 = (32 - (2 * 14) - 4 + 2 / (5 - 4);
     113X1 = (32 - 28 - 4 + 2) / 1;
     114X1 = 2;
    93115 
    94116 *****************************************************************************/
     
    125147    psPlaneTransform *out = psPlaneTransformAlloc(2, 2);
    126148
    127     out->x->coeff[0][0] = -D + ((F*A)/C) / (E - ((F*B)/C));
     149    out->x->coeff[0][0] = (-D + ((F*A)/C)) / (E - ((F*B)/C));
    128150    out->x->coeff[1][0] = -(F/C) / (E - ((F*B)/C));
    129151    out->x->coeff[0][1] =  1.0 / (E - ((F*B)/C));
    130     out->y->coeff[0][0] = -D + ((E*A)/B) / (F - ((C*E)/B));
     152    out->y->coeff[0][0] = (-D + ((E*A)/B)) / (F - ((C*E)/B));
    131153    out->y->coeff[1][0] = -(E/B) / (F - ((C*E)/B));
    132154    out->y->coeff[0][1] =  1.0 / (F - ((C*E)/B));
     
    11401162    //
    11411163    if (p_psIsProjectionLinear((psPlaneTransform *) in)) {
    1142         printf("COOL: is linear\n");
    11431164        return(p_psPlaneTransformLinearInvert((psPlaneTransform *) in));
    11441165    }
  • trunk/psLib/src/astronomy/psCoord.c

    r3711 r3714  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-04-19 01:22:59 $
     12*  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-04-19 04:16:02 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8484 X1 = (-D + ((F*A)/C)) / (E - ((F*B)/C)) +
    8585      (X2 * -((F/C) / (E - ((F*B)/C)))) +
    86              (Y2 * (1.0 / (E - ((F*B)/C))));
    87         Y1 = (-D + ((E*A)/B))/(F - ((C*E)/B)) +
    88              (X2 * -((E/B) / (F - ((C*E)/B)))) +
    89              (Y2 * (1.0 / (F - ((C*E)/B))));
     86      (Y2 * (1.0 / (E - ((F*B)/C))));
     87 Y1 = (-D + ((E*A)/B))/(F - ((C*E)/B)) +
     88      (X2 * -((E/B) / (F - ((C*E)/B)))) +
     89      (Y2 * (1.0 / (F - ((C*E)/B))));
    9090 
    9191XXX: Since thre is now a general psPlaneTransformInvert() function, we
    9292should rename this.
     93 
     94X1, Y1 = (2, 3)
     95 
     96    X2 = 1 + 4 + 9   = 14
     97    Y2 = 4 + 10 + 18 = 32
     98 
     99in inverse
     100 
     101Y1 = (32 - ((5/2) * 14) - 4 + ((5)/2)) / (6 - ((15)/2));
     102Y1 = (32 - 35 - 4 + (5/2)) / (6 - 15/2);
     103Y1 = (-7 + (5/2)) / (12/2 - 15/2);
     104Y1 = (-7 + (5/2)) / (-3/2);
     105Y1 = (-14/2 + 5/2) / (-3/2);
     106Y1 = (-9/2) / (-3/2);
     107Y1 = (9/2) / (3/2);
     108Y1 = 3
     109 
     110X1 = (Y2 - ((F/C) * X2) - D + ((F*A)/C)) / (E - ((F*B)/C));
     111X1 = (32 - ((6/3) * 14) - 4 + ((6)/3)) / (5 - ((12)/3));
     112X1 = (32 - (2 * 14) - 4 + 2 / (5 - 4);
     113X1 = (32 - 28 - 4 + 2) / 1;
     114X1 = 2;
    93115 
    94116 *****************************************************************************/
     
    125147    psPlaneTransform *out = psPlaneTransformAlloc(2, 2);
    126148
    127     out->x->coeff[0][0] = -D + ((F*A)/C) / (E - ((F*B)/C));
     149    out->x->coeff[0][0] = (-D + ((F*A)/C)) / (E - ((F*B)/C));
    128150    out->x->coeff[1][0] = -(F/C) / (E - ((F*B)/C));
    129151    out->x->coeff[0][1] =  1.0 / (E - ((F*B)/C));
    130     out->y->coeff[0][0] = -D + ((E*A)/B) / (F - ((C*E)/B));
     152    out->y->coeff[0][0] = (-D + ((E*A)/B)) / (F - ((C*E)/B));
    131153    out->y->coeff[1][0] = -(E/B) / (F - ((C*E)/B));
    132154    out->y->coeff[0][1] =  1.0 / (F - ((C*E)/B));
     
    11401162    //
    11411163    if (p_psIsProjectionLinear((psPlaneTransform *) in)) {
    1142         printf("COOL: is linear\n");
    11431164        return(p_psPlaneTransformLinearInvert((psPlaneTransform *) in));
    11441165    }
  • trunk/psLib/src/dataManip/psFunctions.c

    r3709 r3714  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-04-19 00:34:04 $
     9 *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-04-19 04:16:02 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1313 *
    14  *  XXX: What happens if the polyEVal functions are called with data of the wrong
     14 *  XXX: What happens if the polyEval functions are called with data of the wrong
    1515 *       type?
    1616 *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
    1717 *
     18 *  XXX: In the various polyAlloc(n) functions, n is really the order of the
     19 *  polynomial plus 1.  To create a 2nd-order polynomial, n == 3.
    1820 */
    1921/*****************************************************************************/
     
    175177static void dPolynomial2DFree(psDPolynomial2D* myPoly)
    176178{
    177     psS32 x = 0;
    178 
    179     for (x = 0; x < myPoly->nX; x++) {
     179    //printf("dPolynomial2DFree(): HMMM: myPoly->nX is %d\n", myPoly->nX);
     180    //printf("dPolynomial2DFree(): HMMM: myPoly->nY is %d\n", myPoly->nY);
     181    for (psS32 x = 0; x < myPoly->nX; x++) {
    180182        psFree(myPoly->coeff[x]);
    181183        psFree(myPoly->coeffErr[x]);
  • trunk/psLib/src/image/psImageStats.c

    r3684 r3714  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.71 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-04-08 17:58:57 $
     11 *  @version $Revision: 1.72 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-04-19 04:16:02 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4040 
    4141XXX: use static psVectors
     42 
     43XXX: optimize this.  2k vs 4k, sample mean, takes8 seconds on Gene's machine.
     44Should take .2.
    4245 *****************************************************************************/
    4346psStats* psImageStats(psStats* stats,
  • trunk/psLib/src/imageops/psImageStats.c

    r3684 r3714  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.71 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-04-08 17:58:57 $
     11 *  @version $Revision: 1.72 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-04-19 04:16:02 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4040 
    4141XXX: use static psVectors
     42 
     43XXX: optimize this.  2k vs 4k, sample mean, takes8 seconds on Gene's machine.
     44Should take .2.
    4245 *****************************************************************************/
    4346psStats* psImageStats(psStats* stats,
  • trunk/psLib/src/math/psPolynomial.c

    r3709 r3714  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-04-19 00:34:04 $
     9 *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-04-19 04:16:02 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1313 *
    14  *  XXX: What happens if the polyEVal functions are called with data of the wrong
     14 *  XXX: What happens if the polyEval functions are called with data of the wrong
    1515 *       type?
    1616 *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
    1717 *
     18 *  XXX: In the various polyAlloc(n) functions, n is really the order of the
     19 *  polynomial plus 1.  To create a 2nd-order polynomial, n == 3.
    1820 */
    1921/*****************************************************************************/
     
    175177static void dPolynomial2DFree(psDPolynomial2D* myPoly)
    176178{
    177     psS32 x = 0;
    178 
    179     for (x = 0; x < myPoly->nX; x++) {
     179    //printf("dPolynomial2DFree(): HMMM: myPoly->nX is %d\n", myPoly->nX);
     180    //printf("dPolynomial2DFree(): HMMM: myPoly->nY is %d\n", myPoly->nY);
     181    for (psS32 x = 0; x < myPoly->nX; x++) {
    180182        psFree(myPoly->coeff[x]);
    181183        psFree(myPoly->coeffErr[x]);
  • trunk/psLib/src/math/psSpline.c

    r3709 r3714  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.97 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-04-19 00:34:04 $
     9 *  @version $Revision: 1.98 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-04-19 04:16:02 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    1313 *
    14  *  XXX: What happens if the polyEVal functions are called with data of the wrong
     14 *  XXX: What happens if the polyEval functions are called with data of the wrong
    1515 *       type?
    1616 *  XXX: Should the "coeffErr[]" be used as well?  Bug ???.  Ignore coeffErr
    1717 *
     18 *  XXX: In the various polyAlloc(n) functions, n is really the order of the
     19 *  polynomial plus 1.  To create a 2nd-order polynomial, n == 3.
    1820 */
    1921/*****************************************************************************/
     
    175177static void dPolynomial2DFree(psDPolynomial2D* myPoly)
    176178{
    177     psS32 x = 0;
    178 
    179     for (x = 0; x < myPoly->nX; x++) {
     179    //printf("dPolynomial2DFree(): HMMM: myPoly->nX is %d\n", myPoly->nX);
     180    //printf("dPolynomial2DFree(): HMMM: myPoly->nY is %d\n", myPoly->nY);
     181    for (psS32 x = 0; x < myPoly->nX; x++) {
    180182        psFree(myPoly->coeff[x]);
    181183        psFree(myPoly->coeffErr[x]);
  • trunk/psLib/test/astronomy/tst_psAstrometry01.c

    r3710 r3714  
    55*  @author GLG, MHPCC
    66*
    7 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-04-19 01:22:23 $
     7*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-04-19 04:16:02 $
    99*
    1010* XXX: Must test
     
    828828
    829829/******************************************************************************
    830 XXX: This is only a rudimentary test of the psPlaneTransform()
     830XXX: This is only a rudimentary test of the psPlaneTransformInvert()
    831831function.  It tests a few NULL input parameter conditions.
    832832 
     
    844844    //
    845845    trans->x->coeff[0][0] = 1.0;
    846     trans->x->coeff[0][1] = 1.0;
    847     trans->x->coeff[1][0] = 1.0;
     846    trans->x->coeff[0][1] = 3.0;
     847    trans->x->coeff[1][0] = 2.0;
    848848    trans->x->coeff[1][1] = 1.0;
    849     trans->y->coeff[0][0] = 1.0;
    850     trans->y->coeff[0][1] = 1.0;
    851     trans->y->coeff[1][0] = 1.0;
     849    trans->y->coeff[0][0] = 4.0;
     850    trans->y->coeff[0][1] = 6.0;
     851    trans->y->coeff[1][0] = 5.0;
    852852    trans->y->coeff[1][1] = 1.0;
    853853
     
    878878    }
    879879
    880     printf("----------------------------------------------------------------------------------\n");
    881     printf("Calling psPlaneTransformInvert with acceptable data.\n");
    882     transOut = psPlaneTransformInvert(NULL, trans, myRegion, 10);
    883     if (transOut == NULL) {
    884         printf("TEST ERROR: psPlaneTransformInvert() returned a NULL psPlaneTransform.\n");
    885         testStatus = false;
     880    printf("Calling psPlaneTransformInvert with an acceptable linear transformation.\n");
     881    for (psS32 n = 0 ; n < 100 ; n++) {
     882        //
     883        // We create a random linear transformation and hope it is invertible.
     884        //
     885        trans->x->coeff[0][0] = ((psF32) (random() % 1000000)) / 100000.0;
     886        trans->x->coeff[0][1] = ((psF32) (random() % 1000000)) / 100000.0;
     887        trans->x->coeff[1][0] = ((psF32) (random() % 1000000)) / 100000.0;
     888        trans->x->coeff[1][1] = 0.1;
     889        trans->y->coeff[0][0] = ((psF32) (random() % 1000000)) / 100000.0;
     890        trans->y->coeff[0][1] = ((psF32) (random() % 1000000)) / 100000.0;
     891        trans->y->coeff[1][0] = ((psF32) (random() % 1000000)) / 100000.0;
     892        trans->y->coeff[1][1] = 0.1;
     893
     894        transOut = psPlaneTransformInvert(NULL, trans, myRegion, 10);
     895        if (transOut == NULL) {
     896            printf("TEST ERROR: psPlaneTransformInvert() returned a NULL psPlaneTransform.\n");
     897            testStatus = false;
     898        }
     899        psPlane *in = psPlaneAlloc();
     900        in->x = 2.0;
     901        in->y = 3.0;
     902
     903        psPlane *mid = psPlaneTransformApply(NULL, trans, in);
     904        psPlane *out = psPlaneTransformApply(NULL, transOut, mid);
     905
     906        if (((fabs(in->x - out->x) > FLT_EPSILON)) ||
     907                ((fabs(in->y - out->y) > FLT_EPSILON))) {
     908            printf("TEST ERROR: in coords were (%f, %f), out coords were (%f, %f).\n",
     909                   in->x, in->y, out->x, out->y);
     910            testStatus = false;
     911        }
     912
     913        psFree(in);
     914        psFree(mid);
     915        psFree(out);
     916        psFree(transOut);
    886917    }
    887918
    888919    psFree(trans);
    889     psFree(transOut);
    890920    psFree(myRegion);
    891921
    892922    return(!testStatus);
    893923}
     924//This code will
  • trunk/psLib/test/image/Makefile.am

    r3684 r3714  
    2020        tst_psImageManip \
    2121        tst_psImageStats \
     22        tst_psImageStatsSpeed \
    2223        tst_psImageExtraction \
    2324        tst_psImageConvolve \
     
    4344tst_psImageManip_SOURCES =  tst_psImageManip.c
    4445tst_psImageStats_SOURCES =  tst_psImageStats.c
     46tst_psImageStatsSpeed_SOURCES =  tst_psImageStatsSpeed.c
    4547tst_psImageExtraction_SOURCES =  tst_psImageExtraction.c
    4648tst_psImageConvolve_SOURCES =  tst_psImageConvolve.c
Note: See TracChangeset for help on using the changeset viewer.