IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5254


Ignore:
Timestamp:
Oct 7, 2005, 5:51:20 PM (21 years ago)
Author:
drobbin
Message:

Implemented and fixed/tested ImageGrowMask

Location:
trunk/psLib/test
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astro/tst_psSphereOps.c

    r5235 r5254  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-07 21:27:50 $
     8*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-10-08 03:51:20 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4848#define ERROR_TOL   0.0001
    4949
    50 #define ALPHA_P 1.0
    51 #define DELTA_P 2.0
    52 #define PHI_P 3.0
     50#define ALPHA_P 0.5 * M_PI
     51#define DELTA_P 1.0 * M_PI
     52#define PHI_P 1.5 * M_PI
    5353
    5454psS32 testSphereRotAlloc( void )
     
    6363    }
    6464    // Verify sin member is updated
    65     //    double vx = cos(DELTA_P)*cos(ALPHA_P);
    66     //    double vy = cos(DELTA_P)*sin(ALPHA_P);
    67     //    double vz = sin(DELTA_P);
    68     //    double q0 = vx * sin(PHI_P/2.0);
    69     //    double q1 = vy * sin(PHI_P/2.0);
    70     //    double q2 = vz * sin(PHI_P/2.0);
    71     //    double q3 = cos(PHI_P/2.0);
    72     /*
    73         if (FLT_EPSILON < fabs(q0 - myST->q0)) {
    74             psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0);
    75             return 2;
    76         }
    77         if (FLT_EPSILON < fabs(q1 - myST->q1)) {
    78             psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1);
    79             return 3;
    80         }
    81         if (FLT_EPSILON < fabs(q2 - myST->q2)) {
    82             psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2);
    83             return 4;
    84         }
    85         if (FLT_EPSILON < fabs(q3 - myST->q3)) {
    86             psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3);
    87             return 5;
    88         }
    89     */
     65    double vx = cos(DELTA_P)*cos(ALPHA_P);
     66    double vy = cos(DELTA_P)*sin(ALPHA_P);
     67    double vz = sin(DELTA_P);
     68    double q0 = vx * sin(PHI_P/2.0);
     69    double q1 = vy * sin(PHI_P/2.0);
     70    double q2 = vz * sin(PHI_P/2.0);
     71    double q3 = cos(PHI_P/2.0);
     72    double len = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3);
     73    printf("\nvz = %lf\n", vz);
     74    q0 = q0/len;
     75    q1 = q1/len;
     76    q2 = q2/len;
     77    q3 = q3/len;
     78
     79    if (FLT_EPSILON < fabs(q0 - myST->q0)) {
     80        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0);
     81        return 2;
     82    }
     83    if (FLT_EPSILON < fabs(q1 - myST->q1)) {
     84        psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1);
     85        return 3;
     86    }
     87    if (FLT_EPSILON < fabs(q2 - myST->q2)) {
     88        psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2);
     89        return 4;
     90    }
     91    if (FLT_EPSILON < fabs(q3 - myST->q3)) {
     92        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3);
     93        return 5;
     94    }
     95
    9096    // Free data structure
    9197    psFree(myST);
     
    103109        psSphere *rc = NULL;
    104110        psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0);
    105      
     111
    106112        for (float r=0.0;r<180.0;r+=DEG_INC) {
    107113            for (float d=0.0;d<90.0;d+=DEG_INC) {
     
    110116                in->rErr = 0.0;
    111117                in->dErr = 0.0;
    112      
     118
    113119                if(psSphereRotApply(out, myST, in) != out) {
    114120                    psError(PS_ERR_UNKNOWN,true,"Did not return output pointer.");
     
    125131            }
    126132        }
    127      
     133
    128134        // Verify new sphere object is created if out parameter NULL
    129135        temp = psSphereRotApply(NULL, myST, in);
     
    133139        }
    134140        psFree(temp);
    135      
     141
    136142        // Verify NULL returned if transform structure null
    137143        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
     
    141147            return 5;
    142148        }
    143      
     149
    144150        // Verify NULL returned when input sphere is NULL
    145151        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
     
    149155            return 6;
    150156        }
    151      
     157
    152158        psFree(myST);
    153159        psFree(out);
     
    180186        psSphereRot *mySphereRotForward = NULL;
    181187        psSphereRot *mySphereRotReverse = NULL;
    182      
    183      
     188
     189
    184190        mySphereRotForward = psSphereRotAlloc(DEG_TO_RAD(22.0),
    185191                                              0.0,
     
    188194                                              0.0,
    189195                                              0.0);
    190      
     196
    191197        for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) {
    192198            for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) {
     
    195201                in.rErr = 0.0;
    196202                in.dErr = 0.0;
    197      
     203
    198204                psSphereRotApply(&out, mySphereRotForward, &in);
    199205                psSphereRotApply(&out2, mySphereRotReverse, &out);
    200      
     206
    201207                if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) ||
    202208                        (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) {
     
    210216        psFree(mySphereRotForward);
    211217        psFree(mySphereRotReverse);
    212      
     218
    213219        mySphereRotForward = psSphereRotAlloc(0.0,
    214220                                              DEG_TO_RAD(33.0),
     
    223229                in.rErr = 0.0;
    224230                in.dErr = 0.0;
    225      
     231
    226232                psSphereRotApply(&out, mySphereRotForward, &in);
    227233                psSphereRotApply(&out2, mySphereRotReverse, &out);
    228      
     234
    229235                if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) ||
    230236                        (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) {
     
    238244        psFree(mySphereRotForward);
    239245        psFree(mySphereRotReverse);
    240      
     246
    241247        return(testStatus);
    242248        */
     
    257263        double l[] =     { 96.337272, 122.93192, 195.639488};
    258264        double b[] =     {-60.188553,  27.12825,  78.353806};
    259      
     265
    260266        double t[] =     {  MJD_2000,  MJD_2000,   MJD_2100};
    261      
     267
    262268        double TOLERANCE = 0.001;
    263      
    264      
    265      
     269
     270
     271
    266272        for (int x = 0; x < numTestPoints; x++) {
    267      
     273
    268274            psTime* time = psTimeFromMJD(t[x]);
    269275            psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time);
     
    272278            psSphereRot* fromGalactic = psSphereRotGalacticToICRS();
    273279            psFree(time);
    274      
     280
    275281            // set the ICRS coordinate
    276282            psSphere* icrs = psSphereAlloc();
    277283            icrs->r = DEG_TO_RAD(alpha[x]);
    278284            icrs->d = DEG_TO_RAD(delta[x]);
    279      
     285
    280286            // apply/unapply Ecliptic
    281287            psSphere* ecliptic = psSphereRotApply(NULL, toEcliptic, icrs);
    282288            psSphere* icrsFromEcliptic = psSphereRotApply(NULL, fromEcliptic, ecliptic);
    283      
     289
    284290            // check ecliptic transforms for correctness
    285291            if (abs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE ||
     
    301307            psFree(ecliptic);
    302308            psFree(icrsFromEcliptic);
    303      
     309
    304310            // apply/unapply Galactic
    305311            psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs);
    306312            psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic);
    307      
     313
    308314            // check ecliptic transforms for correctness
    309315            if (abs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE ||
     
    325331            psFree(galactic);
    326332            psFree(icrsFromGalactic);
    327      
     333
    328334            psFree(toEcliptic);
    329335            psFree(fromEcliptic);
    330336            psFree(toGalactic);
    331337            psFree(fromGalactic);
    332      
     338
    333339        }
    334340    */
     
    356362        psTime*       fromTime    = psTimeFromMJD(MJD_2100);
    357363        psTime*       toTime      = psTimeFromMJD(MJD_1900);
    358      
     364
    359365        // Set input coordinate
    360366        inputCoord->r = SPHERE_PRECESS_TP1_R;
     
    362368        inputCoord->rErr = 0.0;
    363369        inputCoord->dErr = 0.0;
    364      
     370
    365371        // Calculate precess
    366372        outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     
    382388        }
    383389        psFree(outputCoord);
    384      
     390
    385391        // Set input coordinate
    386392        inputCoord->r = SPHERE_PRECESS_TP2_R;
     
    388394        inputCoord->rErr = 0.0;
    389395        inputCoord->dErr = 0.0;
    390      
     396
    391397        // Calculate precess
    392398        outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     
    408414        }
    409415        psFree(outputCoord);
    410      
     416
    411417        // Set input coordinate
    412418        inputCoord->r = SPHERE_PRECESS_TP3_R;
     
    414420        inputCoord->rErr = 0.0;
    415421        inputCoord->dErr = 0.0;
    416      
     422
    417423        // Calculate precess
    418424        outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     
    434440        }
    435441        psFree(outputCoord);
    436      
     442
    437443        // Invoke precess with invalid parameter
    438444        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     
    442448            return 10;
    443449        }
    444      
     450
    445451        // Invoke precess with invalid parameter
    446452        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     
    450456            return 11;
    451457        }
    452      
     458
    453459        // Invoke precess with invalid parameter
    454460        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     
    458464            return 12;
    459465        }
    460      
     466
    461467        // Free objects
    462468        psFree(fromTime);
  • trunk/psLib/test/imageops/tst_psImageMaskOps.c

    r5227 r5254  
    66 *  @author David Robbins, MHPCC
    77 *
    8  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-10-06 02:41:07 $
     8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-10-08 03:51:20 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    152152        return 1;
    153153    }
    154     in = psImageAlloc(3, 3, PS_TYPE_MASK);
     154    in = psImageAlloc(5, 5, PS_TYPE_MASK);
    155155    //return null for incompatible image size
    156156    test = psImageAlloc(2, 2, PS_TYPE_MASK);
     
    161161        return 2;
    162162    }
    163     //return null for incompatible image type
    164     test = psImageRecycle(test, 3, 3, PS_TYPE_F32);
     163    //return null for incompatible out image type
     164    test = psImageRecycle(test, 5, 5, PS_TYPE_F32);
    165165    out = psImageGrowMask(test, in, maskVal, growSize, growVal);
    166166    if (out != NULL) {
    167167        fprintf(stderr,
    168                 "psImageGrowMask failed to return NULL for incompatible image type.\n");
     168                "psImageGrowMask failed to return NULL for incompatible output image type.\n");
    169169        return 3;
    170170    }
    171 
    172 
     171    //return NULL for input image that doesn't match PS_TYPE_MASK
     172    in = psImageRecycle(in, 5, 5, PS_TYPE_F32);
     173    out = psImageGrowMask(test, in, maskVal, growSize, growVal);
     174    if (out != NULL) {
     175        fprintf(stderr,
     176                "psImageGrowMask failed to return NULL for incompatible input image type.\n");
     177        return 4;
     178    }
     179    //Test for valid function (image growth)
     180    in = psImageRecycle(in, 5, 5, PS_TYPE_MASK);
     181    in->data.PS_TYPE_MASK_DATA[0][0] = 1;
     182    in->data.PS_TYPE_MASK_DATA[0][1] = 1;
     183    in->data.PS_TYPE_MASK_DATA[0][2] = 1;
     184    in->data.PS_TYPE_MASK_DATA[0][3] = 1;
     185    in->data.PS_TYPE_MASK_DATA[0][4] = 1;
     186    in->data.PS_TYPE_MASK_DATA[1][0] = 1;
     187    in->data.PS_TYPE_MASK_DATA[1][1] = 1;
     188    in->data.PS_TYPE_MASK_DATA[1][2] = 2;
     189    in->data.PS_TYPE_MASK_DATA[1][3] = 1;
     190    in->data.PS_TYPE_MASK_DATA[1][4] = 1;
     191    in->data.PS_TYPE_MASK_DATA[2][0] = 1;
     192    in->data.PS_TYPE_MASK_DATA[2][1] = 1;
     193    in->data.PS_TYPE_MASK_DATA[2][2] = 2;
     194    in->data.PS_TYPE_MASK_DATA[2][3] = 1;
     195    in->data.PS_TYPE_MASK_DATA[2][4] = 1;
     196    in->data.PS_TYPE_MASK_DATA[3][0] = 1;
     197    in->data.PS_TYPE_MASK_DATA[3][1] = 1;
     198    in->data.PS_TYPE_MASK_DATA[3][2] = 1;
     199    in->data.PS_TYPE_MASK_DATA[3][3] = 1;
     200    in->data.PS_TYPE_MASK_DATA[3][4] = 2;
     201    in->data.PS_TYPE_MASK_DATA[4][0] = 1;
     202    in->data.PS_TYPE_MASK_DATA[4][1] = 1;
     203    in->data.PS_TYPE_MASK_DATA[4][2] = 1;
     204    in->data.PS_TYPE_MASK_DATA[4][3] = 1;
     205    in->data.PS_TYPE_MASK_DATA[4][4] = 1;
     206    maskVal = 2;
     207    growSize = 1;
     208    growVal = 2;
     209
     210    out = psImageGrowMask(out, in, maskVal, growSize, growVal);
     211    //0,2 1,1 1,3 2,1 2,3 3,2 should all be 3.  All other should be unchanged.
     212    for (int i = 0; i < 5; i++) {
     213        printf("\n ");
     214        for (int j = 0; j < 5; j++) {
     215            printf("  %d,%d= %d  ", i, j, out->data.PS_TYPE_MASK_DATA[i][j]);
     216        }
     217    }
     218    psFree(out);
    173219    psFree(in);
    174220    psFree(test);
  • trunk/psLib/test/imageops/verified/tst_psImageMaskOps.stderr

    r5227 r5254  
    2424<DATE><TIME>|<HOST>|E|psImageGrowMask (FILE:LINENO)
    2525    Invalid out image.  Type of out does not match type of in.
     26<DATE><TIME>|<HOST>|E|psImageGrowMask (FILE:LINENO)
     27    Invalid input image.  Input image type must match psMaskType.
    2628
    2729---> TESTPOINT PASSED (psImage{psImageGrowMask} | tst_psImageMaskOps.c)
  • trunk/psLib/test/imageops/verified/tst_psImageMaskOps.stdout

    r5227 r5254  
    4040in->data.u8 [i][j] i=2, j=1 = 1
    4141in->data.u8 [i][j] i=2, j=2 = 2
     42
     43   0,0= 1    0,1= 1    0,2= 3    0,3= 1    0,4= 1 
     44   1,0= 1    1,1= 3    1,2= 2    1,3= 3    1,4= 1 
     45   2,0= 1    2,1= 3    2,2= 2    2,3= 3    2,4= 3 
     46   3,0= 1    3,1= 1    3,2= 3    3,3= 3    3,4= 2 
     47   4,0= 1    4,1= 1    4,2= 1    4,3= 1    4,4= 3 
Note: See TracChangeset for help on using the changeset viewer.