IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 1, 2005, 10:47:40 AM (21 years ago)
Author:
gusciora
Message:

...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/tst_pmObjects01.c

    r3576 r3625  
    1919 * abd never deallocate, no error is generated.
    2020 *
    21  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    22  *  @date $Date: 2005-03-31 00:22:49 $
     21 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     22 *  @date $Date: 2005-04-01 20:47:40 $
    2323 *
    2424 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6363{
    6464    return !runTestSuite(stderr, "Test Point Driver", tests, argc, argv);
     65    test02();
    6566}
    6667
     
    153154
    154155#define VECTOR_SIZE 10
    155 bool test_pmFindVectorPeeks(int n)
     156bool test_pmFindVectorPeaks(int n)
    156157{
    157158    bool testStatus = true;
     
    159160    psVector *outData = NULL;
    160161
    161     printf("-------------- Calling test_pmFindVectorPeeks on an %d size vector. --------------\n", n);
     162    printf("-------------- Calling test_pmFindVectorPeaks on an %d size vector. --------------\n", n);
    162163    //
    163164    // Test first pixel peak.
    164165    //
    165     printf("Test pmFindVectorPeeks() with a first-element peak.\n");
     166    printf("Test pmFindVectorPeaks() with a first-element peak.\n");
    166167    for (psS32 i = 0 ; i < n ; i++) {
    167168        inData->data.F32[i] = (float) (n-i);
     
    169170    inData->data.F32[0] = (float) n;
    170171
    171     outData= pmFindVectorPeeks(inData, 0.0);
     172    outData= pmFindVectorPeaks(inData, 0.0);
    172173    if (outData == NULL) {
    173         printf("TEST ERROR: pmFindVectorPeeks returned a NULL psVector.\n");
     174        printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
    174175        testStatus = false;
    175176    } else {
     
    189190    // Test first pixel peak, large threshold
    190191    //
    191     printf("Test pmFindVectorPeeks() with a first-element peak, large threshold.\n");
     192    printf("Test pmFindVectorPeaks() with a first-element peak, large threshold.\n");
    192193    for (psS32 i = 0 ; i < n ; i++) {
    193194        inData->data.F32[i] = (float) (n-i);
     
    195196    inData->data.F32[0] = (float) n;
    196197
    197     outData= pmFindVectorPeeks(inData, (float) (n*n));
     198    outData= pmFindVectorPeaks(inData, (float) (n*n));
    198199    if (outData == NULL) {
    199         printf("TEST ERROR: pmFindVectorPeeks returned a NULL psVector.\n");
     200        printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
    200201        testStatus = false;
    201202    } else {
     
    217218    // Test last pixel peak.
    218219    //
    219     printf("Test pmFindVectorPeeks() with a last-element peak.\n");
     220    printf("Test pmFindVectorPeaks() with a last-element peak.\n");
    220221    for (psS32 i = 0 ; i < n ; i++) {
    221222        inData->data.F32[i] = (float) (i);
     
    223224    inData->data.F32[n-1] = (float) n;
    224225
    225     outData= pmFindVectorPeeks(inData, 0.0);
     226    outData= pmFindVectorPeaks(inData, 0.0);
    226227    if (outData == NULL) {
    227         printf("TEST ERROR: pmFindVectorPeeks returned a NULL psVector.\n");
     228        printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
    228229        testStatus = false;
    229230    } else {
     
    243244    // Test last pixel peak, large threshold.
    244245    //
    245     printf("Test pmFindVectorPeeks() with a last-element peak, large threshold.\n");
     246    printf("Test pmFindVectorPeaks() with a last-element peak, large threshold.\n");
    246247    for (psS32 i = 0 ; i < n ; i++) {
    247248        inData->data.F32[i] = (float) (i);
     
    249250    inData->data.F32[n-1] = (float) n;
    250251
    251     outData= pmFindVectorPeeks(inData, (float) (n*n));
     252    outData= pmFindVectorPeaks(inData, (float) (n*n));
    252253    if (outData == NULL) {
    253         printf("TEST ERROR: pmFindVectorPeeks returned a NULL psVector.\n");
     254        printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
    254255        testStatus = false;
    255256    } else {
     
    266267    // Set all even number elements to be peaks.
    267268    //
    268     printf("Test pmFindVectorPeeks() with all even-numbered elements peak.\n");
     269    printf("Test pmFindVectorPeaks() with all even-numbered elements peak.\n");
    269270    for (psS32 i = 0 ; i < n ; i++) {
    270271        if (0 == i%2) {
     
    277278
    278279
    279     outData= pmFindVectorPeeks(inData, 0.0);
     280    outData= pmFindVectorPeaks(inData, 0.0);
    280281    if (outData == NULL) {
    281         printf("TEST ERROR: pmFindVectorPeeks returned a NULL psVector.\n");
     282        printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
    282283        testStatus = false;
    283284    } else {
     
    301302    // Should generate an empty output psVector.
    302303    //
    303     printf("Test pmFindVectorPeeks() with all even-numbered elements peak, large threshold.\n");
    304     outData= pmFindVectorPeeks(inData, (float) (n*n));
     304    printf("Test pmFindVectorPeaks() with all even-numbered elements peak, large threshold.\n");
     305    outData= pmFindVectorPeaks(inData, (float) (n*n));
    305306    if (outData == NULL) {
    306         printf("TEST ERROR: pmFindVectorPeeks returned a NULL psVector.\n");
     307        printf("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
    307308        testStatus = false;
    308309    } else {
     
    331332
    332333    printf("----------------------------------------------------------------------------------\n");
    333     printf("Calling pmFindVectorPeeks with NULL psVector.  Should generate error and return NULL.\n");
    334     tmpVec = pmFindVectorPeeks(NULL, 0.0);
     334    printf("Calling pmFindVectorPeaks with NULL psVector.  Should generate error and return NULL.\n");
     335    tmpVec = pmFindVectorPeaks(NULL, 0.0);
    335336    if (tmpVec != NULL) {
    336         printf("TEST ERROR: pmFindVectorPeeks() returned a non-NULL psVector.\n");
     337        printf("TEST ERROR: pmFindVectorPeaks() returned a non-NULL psVector.\n");
    337338        testStatus = false;
    338339        psFree(tmpVec);
     
    340341
    341342    printf("----------------------------------------------------------------------------------\n");
    342     printf("Calling pmFindVectorPeeks with empty psVector.  Should generate error and return NULL.\n");
    343     tmpVec = pmFindVectorPeeks(tmpVecEmpty, 0.0);
     343    printf("Calling pmFindVectorPeaks with empty psVector.  Should generate error and return NULL.\n");
     344    tmpVec = pmFindVectorPeaks(tmpVecEmpty, 0.0);
    344345    if (tmpVec != NULL) {
    345         printf("TEST ERROR: pmFindVectorPeeks() returned a non-NULL psVector.\n");
     346        printf("TEST ERROR: pmFindVectorPeaks() returned a non-NULL psVector.\n");
    346347        testStatus = false;
    347348        psFree(tmpVec);
     
    349350
    350351    printf("----------------------------------------------------------------------------------\n");
    351     printf("Calling pmFindVectorPeeks with PS_TYPE_F64 psVector.  Should generate error and return NULL.\n");
    352     tmpVec = pmFindVectorPeeks(tmpVecF64, 0.0);
     352    printf("Calling pmFindVectorPeaks with PS_TYPE_F64 psVector.  Should generate error and return NULL.\n");
     353    tmpVec = pmFindVectorPeaks(tmpVecF64, 0.0);
    353354    if (tmpVec != NULL) {
    354         printf("TEST ERROR: pmFindVectorPeeks() returned a non-NULL psVector.\n");
     355        printf("TEST ERROR: pmFindVectorPeaks() returned a non-NULL psVector.\n");
    355356        testStatus = false;
    356357        psFree(tmpVec);
    357358    }
    358     testStatus&= test_pmFindVectorPeeks(1);
    359     testStatus&= test_pmFindVectorPeeks(VECTOR_SIZE);
     359    testStatus&= test_pmFindVectorPeaks(1);
     360    testStatus&= test_pmFindVectorPeaks(VECTOR_SIZE);
    360361
    361362    psFree(tmpVecF64);
     
    366367// XXX: Add tests for the PEAK_TYPE.
    367368// XXX: Add interior peaks, edge peaks, and flat peaks.
    368 bool test_pmFindImagePeeks(int numRows, int numCols)
     369bool test_pmFindImagePeaks(int numRows, int numCols)
    369370{
    370     printf("-------------- Calling test_pmFindVectorPeeks on an %d-by-%d image. --------------\n", numRows, numCols);
     371    printf("-------------- Calling test_pmFindVectorPeaks on an %d-by-%d image. --------------\n", numRows, numCols);
    371372    bool testStatus = true;
    372373    psImage *inData = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     
    392393    }
    393394
    394     outData = pmFindImagePeeks(inData, 0.0);
     395    outData = pmFindImagePeaks(inData, 0.0);
    395396
    396397    if (outData == NULL) {
    397         printf("TEST ERROR: pmFindImagePeeks returned a NULL psList.\n");
     398        printf("TEST ERROR: pmFindImagePeaks returned a NULL psList.\n");
    398399        testStatus = false;
    399400    } else {
    400401        if (outData->size != 4) {
    401             printf("TEST ERROR: pmFindImagePeeks found only %d peaks (should be 4)\n", outData->size);
     402            printf("TEST ERROR: pmFindImagePeaks found only %d peaks (should be 4)\n", outData->size);
    402403            testStatus = false;
    403404        }
    404405
     406        //HEY
    405407        psListElem *tmpPeakLE = (psListElem *) outData->head;
    406408        while (tmpPeakLE != NULL) {
     
    409411                ((tmpPeak->y == 0) || (tmpPeak->y == numCols-1))) {}
    410412            else {
    411                 printf("TEST ERROR: Peak at (%d, %d)\n", tmpPeak->x, tmpPeak->y);
     413                printf("TEST ERROR: Peak at (%d, %d) (%f)\n", tmpPeak->x, tmpPeak->y, tmpPeak->counts);
    412414                testStatus = false;
    413415            }
     
    432434
    433435    printf("----------------------------------------------------------------------------------\n");
    434     printf("Calling pmFindImagePeeks with NULL psImage.  Should generate error and return NULL.\n");
    435     tmpList = pmFindImagePeeks(NULL, 0.0);
     436    printf("Calling pmFindImagePeaks with NULL psImage.  Should generate error and return NULL.\n");
     437    tmpList = pmFindImagePeaks(NULL, 0.0);
    436438    if (tmpList != NULL) {
    437         printf("TEST ERROR: pmFindImagePeeks() returned a non-NULL psImage.\n");
     439        printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n");
    438440        testStatus = false;
    439441        psFree(tmpList);
     
    441443
    442444    printf("----------------------------------------------------------------------------------\n");
    443     printf("Calling pmFindImagePeeks with empty psImage.  Should generate error and return NULL.\n");
    444     tmpList = pmFindImagePeeks(tmpImageEmpty, 0.0);
     445    printf("Calling pmFindImagePeaks with empty psImage.  Should generate error and return NULL.\n");
     446    tmpList = pmFindImagePeaks(tmpImageEmpty, 0.0);
    445447    if (tmpList != NULL) {
    446         printf("TEST ERROR: pmFindImagePeeks() returned a non-NULL psImage.\n");
     448        printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n");
    447449        testStatus = false;
    448450        psFree(tmpList);
     
    450452
    451453    printf("----------------------------------------------------------------------------------\n");
    452     printf("Calling pmFindImagePeeks with PS_TYPE_F64 psImage.  Should generate error and return NULL.\n");
    453     tmpList = pmFindImagePeeks(tmpImageF64, 0.0);
     454    printf("Calling pmFindImagePeaks with PS_TYPE_F64 psImage.  Should generate error and return NULL.\n");
     455    tmpList = pmFindImagePeaks(tmpImageF64, 0.0);
    454456    if (tmpList != NULL) {
    455         printf("TEST ERROR: pmFindImagePeeks() returned a non-NULL psImage.\n");
     457        printf("TEST ERROR: pmFindImagePeaks() returned a non-NULL psImage.\n");
    456458        testStatus = false;
    457459        psFree(tmpList);
    458460    }
    459461    printf("----------------------------------------------------------------------------------\n");
    460     //    testStatus&= test_pmFindImagePeeks(1, 1);
    461     //    testStatus&= test_pmFindImagePeeks(2, 5);
    462     //    testStatus&= test_pmFindImagePeeks(5, 2);
    463     testStatus&= test_pmFindImagePeeks(10, 10);
     462    //    testStatus&= test_pmFindImagePeaks(1, 1);
     463    //    testStatus&= test_pmFindImagePeaks(2, 5);
     464    //    testStatus&= test_pmFindImagePeaks(5, 2);
     465    testStatus&= test_pmFindImagePeaks(10, 10);
    464466
    465467
     
    470472
    471473/******************************************************************************
    472 test03(): We first test pmCullPeeks() with various NULL and unallowable input
    473 parameters.  Then we generate a list of peaks and test that pmCullPeeks()
     474test03(): We first test pmCullPeaks() with various NULL and unallowable input
     475parameters.  Then we generate a list of peaks and test that pmCullPeaks()
    474476removes them correctly.
    475477 *****************************************************************************/
     
    481483
    482484    printf("----------------------------------------------------------------------------------\n");
    483     printf("Calling pmCullPeeks with NULL psList.  Should generate error and return NULL.\n");
    484     outData = pmCullPeeks(NULL, 0.0, NULL);
     485    printf("Calling pmCullPeaks with NULL psList.  Should generate error and return NULL.\n");
     486    outData = pmCullPeaks(NULL, 0.0, NULL);
    485487    if (outData != NULL) {
    486         printf("TEST ERROR: pmCulPeeks() returned a non-NULL psList.\n");
     488        printf("TEST ERROR: pmCulPeaks() returned a non-NULL psList.\n");
    487489        testStatus = false;
    488490    }
     
    512514
    513515    //
    514     // Call pmCullPeeks() with HUGE maxValue and NULL psRegion.  Should not
     516    // Call pmCullPeaks() with HUGE maxValue and NULL psRegion.  Should not
    515517    // remove any peaks.
    516518    //
    517519    printf("----------------------------------------------------------------------------------\n");
    518     printf("Calling pmCullPeeks with large maxValue and NULL psRegion.\n");
    519     outData = pmFindImagePeeks(imgData, 0.0);
    520     outData = pmCullPeeks(outData, PS_MAX_F32, NULL);
     520    printf("Calling pmCullPeaks with large maxValue and NULL psRegion.\n");
     521    outData = pmFindImagePeaks(imgData, 0.0);
     522    outData = pmCullPeaks(outData, PS_MAX_F32, NULL);
    521523
    522524    if (outData == NULL) {
    523         printf("TEST ERROR: pmCullPeeks() returned a non-NULL psList.\n");
     525        printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n");
    524526        testStatus = false;
    525527        return(testStatus);
    526528    }
    527529    if (outData->size != numPeaksOrig) {
    528         printf("TEST ERROR (0): pmCullPeeks incorrectly removed peaks\n");
    529         printf("The pmCullPeeks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig);
     530        printf("TEST ERROR (0): pmCullPeaks incorrectly removed peaks\n");
     531        printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig);
    530532        testStatus = false;
    531533    }
     
    533535
    534536    //
    535     // Call pmCullPeeks() with TINY maxValue and NULL psRegion.  Should
     537    // Call pmCullPeaks() with TINY maxValue and NULL psRegion.  Should
    536538    // remove all peaks.
    537539    //
    538540    printf("----------------------------------------------------------------------------------\n");
    539     printf("Calling pmCullPeeks with tiny maxValue and NULL psRegion.\n");
    540     outData = pmFindImagePeeks(imgData, 0.0);
    541     printf("pmFindImagePeeks found %d peaks\n", outData->size);
    542     outData = pmCullPeeks(outData, 0.0, NULL);
     541    printf("Calling pmCullPeaks with tiny maxValue and NULL psRegion.\n");
     542    outData = pmFindImagePeaks(imgData, 0.0);
     543    printf("pmFindImagePeaks found %d peaks\n", outData->size);
     544    outData = pmCullPeaks(outData, 0.0, NULL);
    543545
    544546    if (outData == NULL) {
    545         printf("TEST ERROR: pmCullPeeks() returned a non-NULL psList.\n");
     547        printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n");
    546548        testStatus = false;
    547549        return(testStatus);
    548550    }
    549551    if (outData->size != 0) {
    550         printf("TEST ERROR (1): pmCullPeeks incorrectly removed peaks\n");
    551         printf("The pmCullPeeks() output had %d peaks, should have had %d peaks.\n", outData->size, 0);
     552        printf("TEST ERROR (1): pmCullPeaks incorrectly removed peaks\n");
     553        printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, 0);
    552554        testStatus = false;
    553555    }
     
    555557
    556558    //
    557     // Call pmCullPeeks() with HUGE maxValue and disjoint psRegion.  Should
     559    // Call pmCullPeaks() with HUGE maxValue and disjoint psRegion.  Should
    558560    // not remove any peaks.
    559561    //
    560562    printf("----------------------------------------------------------------------------------\n");
    561     printf("Calling pmCullPeeks with large maxValue and disjoint psRegion.\n");
    562     outData = pmFindImagePeeks(imgData, 0.0);
    563     printf("pmFindImagePeeks found %d peaks\n", outData->size);
     563    printf("Calling pmCullPeaks with large maxValue and disjoint psRegion.\n");
     564    outData = pmFindImagePeaks(imgData, 0.0);
     565    printf("pmFindImagePeaks found %d peaks\n", outData->size);
    564566    psRegion *tmpRegion = psRegionAlloc(10000.0, 20000.0, 10000.0, 20000.0);
    565     outData = pmCullPeeks(outData, PS_MAX_F32, tmpRegion);
     567    outData = pmCullPeaks(outData, PS_MAX_F32, tmpRegion);
    566568
    567569    if (outData == NULL) {
    568         printf("TEST ERROR: pmCullPeeks() returned a non-NULL psList.\n");
     570        printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n");
    569571        testStatus = false;
    570572        return(testStatus);
    571573    }
    572574    if (outData->size != numPeaksOrig) {
    573         printf("TEST ERROR (2): pmCullPeeks incorrectly removed peaks\n");
    574         printf("The pmCullPeeks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig);
     575        printf("TEST ERROR (2): pmCullPeaks incorrectly removed peaks\n");
     576        printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, numPeaksOrig);
    575577        testStatus = false;
    576578    }
     
    579581
    580582    //
    581     // Call pmCullPeeks() with HUGE maxValue and non-disjoint psRegion.  Should
     583    // Call pmCullPeaks() with HUGE maxValue and non-disjoint psRegion.  Should
    582584    // remove all peaks.
    583585    //
    584586    printf("----------------------------------------------------------------------------------\n");
    585     printf("Calling pmCullPeeks with large maxValue and non-disjoint psRegion.\n");
    586     outData = pmFindImagePeeks(imgData, 0.0);
    587     printf("pmFindImagePeeks found %d peaks\n", outData->size);
     587    printf("Calling pmCullPeaks with large maxValue and non-disjoint psRegion.\n");
     588    outData = pmFindImagePeaks(imgData, 0.0);
     589    printf("pmFindImagePeaks found %d peaks\n", outData->size);
    588590    tmpRegion = psRegionAlloc(-PS_MAX_F32, PS_MAX_F32, -PS_MAX_F32, PS_MAX_F32);
    589     outData = pmCullPeeks(outData, PS_MAX_F32, tmpRegion);
     591    outData = pmCullPeaks(outData, PS_MAX_F32, tmpRegion);
    590592
    591593    if (outData == NULL) {
    592         printf("TEST ERROR: pmCullPeeks() returned a non-NULL psList.\n");
     594        printf("TEST ERROR: pmCullPeaks() returned a non-NULL psList.\n");
    593595        testStatus = false;
    594596        return(testStatus);
    595597    }
    596598    if (outData->size != 0) {
    597         printf("TEST ERROR (3): pmCullPeeks incorrectly removed peaks\n");
    598         printf("The pmCullPeeks() output had %d peaks, should have had %d peaks.\n", outData->size, 0);
     599        printf("TEST ERROR (3): pmCullPeaks incorrectly removed peaks\n");
     600        printf("The pmCullPeaks() output had %d peaks, should have had %d peaks.\n", outData->size, 0);
    599601        testStatus = false;
    600602    }
Note: See TracChangeset for help on using the changeset viewer.