IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2007, 9:37:23 AM (19 years ago)
Author:
gusciora
Message:

Modified the FindPeaks Vector/Image tests for the new API code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/objects/tap_pmPeaks.c

    r13879 r15161  
    55#include "tap.h"
    66#include "pstap.h"
     7/* The following are tested:
     8    pmPeakAlloc()
     9    pmPeaksInVector()
     10    pmPeaksInImage()
     11    pmPeaksSubset()
     12    pmPeaksCompareAscend()
     13    pmPeaksCompareDescend()
     14Must test
     15    pmCullPeaks()
     16*/
    717
    818#define TST01_VECTOR_LENGTH 10
     
    1323
    1424/******************************************************************************
    15 test01(): we first test pmFindVectorPeaks() with a variety of bad input
     25test01(): we first test pmPeaksInVector() with a variety of bad input
    1626parameters.  Then we test it with a simple vector both 1- and multi-elements.
    1727 *****************************************************************************/
    18 bool test_pmFindVectorPeaks(int n)
     28bool test_pmPeaksInVector(int n)
    1929{
    2030    psMemId id = psMemGetId();
     
    2939    }
    3040    inData->data.F32[0] = (float) n;
    31     outData= pmFindVectorPeaks(inData, 0.0);
     41    outData= pmPeaksInVector(inData, 0.0);
    3242    if (outData == NULL) {
    33         diag("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
     43        diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n");
    3444        testStatus = false;
    3545    } else {
     
    5363    }
    5464    inData->data.F32[0] = (float) n;
    55     outData= pmFindVectorPeaks(inData, (float) (n*n));
     65    outData= pmPeaksInVector(inData, (float) (n*n));
    5666    if (outData == NULL) {
    57         diag("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
     67        diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n");
    5868        testStatus = false;
    5969    } else {
     
    7888    inData->data.F32[n-1] = (float) n;
    7989
    80     outData= pmFindVectorPeaks(inData, 0.0);
     90    outData= pmPeaksInVector(inData, 0.0);
    8191    if (outData == NULL) {
    82         diag("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
     92        diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n");
    8393        testStatus = false;
    8494    } else {
     
    100110    }
    101111    inData->data.F32[n-1] = (float) n;
    102     outData= pmFindVectorPeaks(inData, (float) (n*n));
     112    outData= pmPeaksInVector(inData, (float) (n*n));
    103113    if (outData == NULL) {
    104         diag("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
     114        diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n");
    105115        testStatus = false;
    106116    } else {
     
    125135
    126136
    127     outData= pmFindVectorPeaks(inData, 0.0);
     137    outData= pmPeaksInVector(inData, 0.0);
    128138    if (outData == NULL) {
    129         diag("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
     139        diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n");
    130140        testStatus = false;
    131141    } else {
     
    146156    // Test interior peaks, with threshold = n*n.
    147157    // Should generate an empty output psVector.
    148     outData= pmFindVectorPeaks(inData, (float) (n*n));
     158    outData= pmPeaksInVector(inData, (float) (n*n));
    149159    if (outData == NULL) {
    150         diag("TEST ERROR: pmFindVectorPeaks returned a NULL psVector.\n");
     160        diag("TEST ERROR: pmPeaksInVector returned a NULL psVector.\n");
    151161        testStatus = false;
    152162    } else {
     
    163173
    164174
    165 bool test_pmFindImagePeaks(int numRows, int numCols)
     175bool test_pmPeaksInImage(int numRows, int numCols)
    166176{
    167177    psMemId id = psMemGetId();
     
    183193    inData->data.F32[numRows/2][numCols/2] = PS_SQR(numRows) + PS_SQR(numCols);
    184194
    185     // Call pmFindImagePeaks() with a threshold of 0.0.
    186     outData = pmFindImagePeaks(inData, 0.0);
     195    // Call pmPeaksInImage() with a threshold of 0.0.
     196    outData = pmPeaksInImage(inData, 0.0);
    187197
    188198    if (outData == NULL) {
    189         diag("TEST ERROR: pmFindImagePeaks returned a NULL psList.\n");
     199        diag("TEST ERROR: pmPeaksInImage returned a NULL psList.\n");
    190200        testStatus = false;
    191201    } else {
     
    199209        }
    200210        if (outData->n != expectedNumPeaks) {
    201             diag("TEST ERROR: pmFindImagePeaks found %ld peaks (should be %d)\n", outData->n, expectedNumPeaks);
     211            diag("TEST ERROR: pmPeaksInImage found %ld peaks (should be %d)\n", outData->n, expectedNumPeaks);
    202212            testStatus = false;
    203213        }
     
    279289
    280290    // ----------------------------------------
    281     // pmFindVectorPeaks() tests
    282     // Test pmFindVectorPeaks() with bad input parameters.
    283     // Calling pmFindVectorPeaks with NULL psVector.  Should generate error.
    284     {
    285         psMemId id = psMemGetId();
    286         psVector *tmpVec = pmFindVectorPeaks(NULL, 0.0);
    287         ok(tmpVec == NULL, "pmFindVectorPeaks() returned a NULL with NULL psVector input");
     291    // pmPeaksInVector() tests
     292    // Test pmPeaksInVector() with bad input parameters.
     293    // Calling pmPeaksInVector with NULL psVector.  Should generate error.
     294    {
     295        psMemId id = psMemGetId();
     296        psVector *tmpVec = pmPeaksInVector(NULL, 0.0);
     297        ok(tmpVec == NULL, "pmPeaksInVector() returned a NULL with NULL psVector input");
    288298        psFree(tmpVec);
    289299        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    291301
    292302
    293     // Calling pmFindVectorPeaks with empty psVector.  Should generate error.
     303    // Calling pmPeaksInVector with empty psVector.  Should generate error.
    294304    {
    295305        psMemId id = psMemGetId();
    296306        psVector *tmpVecEmpty = psVectorAlloc(0, PS_TYPE_F32);
    297         psVector *tmpVec = pmFindVectorPeaks(tmpVecEmpty, 0.0);
    298         ok(tmpVec == NULL, "pmFindVectorPeaks() returned a NULL with NULL psVector input");
     307        psVector *tmpVec = pmPeaksInVector(tmpVecEmpty, 0.0);
     308        ok(tmpVec == NULL, "pmPeaksInVector() returned a NULL with NULL psVector input");
    299309        psFree(tmpVec);
    300310        psFree(tmpVecEmpty);
     
    303313
    304314
    305     // Calling pmFindVectorPeaks with PS_TYPE_F64 psVector.  Should generate error.
     315    // Calling pmPeaksInVector with PS_TYPE_F64 psVector.  Should generate error.
    306316    {
    307317        psMemId id = psMemGetId();
    308318        psVector *tmpVecF64 = psVectorAlloc(TST01_VECTOR_LENGTH, PS_TYPE_F64);
    309         psVector *tmpVec = pmFindVectorPeaks(tmpVecF64, 0.0);
    310         ok(tmpVec == NULL, "pmFindVectorPeaks() returned a NULL with F64 psVector input");
     319        psVector *tmpVec = pmPeaksInVector(tmpVecF64, 0.0);
     320        ok(tmpVec == NULL, "pmPeaksInVector() returned a NULL with F64 psVector input");
    311321        psFree(tmpVecF64);
    312322        psFree(tmpVec);
    313323        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    314324    }
    315     ok(test_pmFindVectorPeaks(1), "Tested pmFindVectorPeaks() on length 1 input vector");
    316     ok(test_pmFindVectorPeaks(10), "Tested pmFindVectorPeaks() on length 10 input vector");
     325    ok(test_pmPeaksInVector(1), "Tested pmPeaksInVector() on length 1 input vector");
     326    ok(test_pmPeaksInVector(10), "Tested pmPeaksInVector() on length 10 input vector");
    317327
    318328
    319329
    320330    // ----------------------------------------
    321     // pmFindImagePeaks() tests
    322     // Calling pmFindImagePeaks with NULL psImage.  Should generate error.
    323     {
    324         psMemId id = psMemGetId();
    325         psArray *tmpArray = pmFindImagePeaks(NULL, 0.0);
    326         ok(tmpArray == NULL, "pmFindImagePeaks() returned NULL with NULL input image");
     331    // pmPeaksInImage() tests
     332    // Calling pmPeaksInImage with NULL psImage.  Should generate error.
     333    {
     334        psMemId id = psMemGetId();
     335        psArray *tmpArray = pmPeaksInImage(NULL, 0.0);
     336        ok(tmpArray == NULL, "pmPeaksInImage() returned NULL with NULL input image");
    327337        psFree(tmpArray);
    328338        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    330340
    331341
    332     // Calling pmFindImagePeaks with empty psImage.  Should generate error.
     342    // Calling pmPeaksInImage with empty psImage.  Should generate error.
    333343    {
    334344        psMemId id = psMemGetId();
    335345        psImage *tmpImageEmpty = psImageAlloc(0, 0, PS_TYPE_F32);
    336         psArray *tmpArray = pmFindImagePeaks(tmpImageEmpty, 0.0);
    337         ok(tmpArray == NULL, "pmFindImagePeaks() returned NULL with empty input image");
     346        psArray *tmpArray = pmPeaksInImage(tmpImageEmpty, 0.0);
     347        ok(tmpArray == NULL, "pmPeaksInImage() returned NULL with empty input image");
    338348        psFree(tmpArray);
    339349        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    341351   
    342352
    343     // Calling pmFindImagePeaks with PS_TYPE_F64 psImage.  Should generate error
     353    // Calling pmPeaksInImage with PS_TYPE_F64 psImage.  Should generate error
    344354    {
    345355        psMemId id = psMemGetId();
    346356        psImage *tmpImageF64 = psImageAlloc(TST02_NUM_ROWS, TST02_NUM_COLS, PS_TYPE_F64);
    347         psArray *tmpArray = pmFindImagePeaks(tmpImageF64, 0.0);
    348         ok(tmpArray == NULL, "pmFindImagePeaks() returned NULL with F64 input image");
     357        psArray *tmpArray = pmPeaksInImage(tmpImageF64, 0.0);
     358        ok(tmpArray == NULL, "pmPeaksInImage() returned NULL with F64 input image");
    349359        psFree(tmpImageF64);
    350360        psFree(tmpArray);
     
    353363
    354364
    355     //    testStatus&= test_pmFindImagePeaks(1, 1);
    356     //    testStatus&= test_pmFindImagePeaks(2, 5);
    357     //    testStatus&= test_pmFindImagePeaks(5, 2);
     365    // XXX: Uncomment these and debug
     366    //    testStatus&= test_pmPeaksInImage(1, 1);
     367    //    testStatus&= test_pmPeaksInImage(2, 5);
     368    //    testStatus&= test_pmPeaksInImage(5, 2);
    358369    // HEY: add code for small images
    359     //    testStatus&= test_pmFindImagePeaks(1, 1);
    360     //    testStatus&= test_pmFindImagePeaks(1, 8);
    361     //    testStatus&= test_pmFindImagePeaks(8, 1);
    362     ok(test_pmFindImagePeaks(TST02_NUM_ROWS, TST02_NUM_COLS),
    363       "Tested pmFindImagePeaks() on (%d, %d) image", TST02_NUM_ROWS, TST02_NUM_COLS);
    364     ok(test_pmFindImagePeaks(2*TST02_NUM_ROWS, TST02_NUM_COLS),
    365       "Tested pmFindImagePeaks() on (%d, %d) image", 2*TST02_NUM_ROWS, TST02_NUM_COLS);
    366     ok(test_pmFindImagePeaks(TST02_NUM_ROWS, 2*TST02_NUM_COLS),
    367       "Tested pmFindImagePeaks() on (%d, %d) image", TST02_NUM_ROWS, 2*TST02_NUM_COLS);
     370    //    testStatus&= test_pmPeaksInImage(1, 1);
     371    //    testStatus&= test_pmPeaksInImage(1, 8);
     372    //    testStatus&= test_pmPeaksInImage(8, 1);
     373    ok(test_pmPeaksInImage(TST02_NUM_ROWS, TST02_NUM_COLS),
     374      "Tested pmPeaksInImage() on (%d, %d) image", TST02_NUM_ROWS, TST02_NUM_COLS);
     375    ok(test_pmPeaksInImage(2*TST02_NUM_ROWS, TST02_NUM_COLS),
     376      "Tested pmPeaksInImage() on (%d, %d) image", 2*TST02_NUM_ROWS, TST02_NUM_COLS);
     377    ok(test_pmPeaksInImage(TST02_NUM_ROWS, 2*TST02_NUM_COLS),
     378      "Tested pmPeaksInImage() on (%d, %d) image", TST02_NUM_ROWS, 2*TST02_NUM_COLS);
    368379
    369380
     
    399410    {
    400411        psMemId id = psMemGetId();
    401         psArray *outData = pmFindImagePeaks(imgData, 0.0);
     412        psArray *outData = pmPeaksInImage(imgData, 0.0);
    402413        psArray *outData2 = pmPeaksSubset(outData, PS_MAX_F32, psRegionSet(20, 20, 20, 20));
    403414        ok(outData2 != NULL && psMemCheckArray(outData),
     
    415426    {
    416427        psMemId id = psMemGetId();
    417         psArray *outData = pmFindImagePeaks(imgData, 0.0);
     428        psArray *outData = pmPeaksInImage(imgData, 0.0);
    418429        psArray *outData2 = pmPeaksSubset(outData, 0.0, psRegionSet(20, 20, 20, 20));
    419430        ok(outData2 != NULL && psMemCheckArray(outData),
     
    431442    {
    432443        psMemId id = psMemGetId();
    433         psArray *outData = pmFindImagePeaks(imgData, 0.0);
     444        psArray *outData = pmPeaksInImage(imgData, 0.0);
    434445        psRegion tmpRegion = psRegionSet(-PS_MAX_F32, PS_MAX_F32, -PS_MAX_F32, PS_MAX_F32);
    435446        psArray *outData2 = pmPeaksSubset(outData, PS_MAX_F32, tmpRegion);
     
    448459    {
    449460        psMemId id = psMemGetId();
    450         psArray *outData = pmFindImagePeaks(imgData, 0.0);
     461        psArray *outData = pmPeaksInImage(imgData, 0.0);
    451462        psRegion tmpRegion = psRegionSet(-PS_MAX_F32, PS_MAX_F32, -PS_MAX_F32, PS_MAX_F32);
    452463        psArray *outData2 = pmPeaksSubset(outData, 0.0, tmpRegion);
Note: See TracChangeset for help on using the changeset viewer.