IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 894


Ignore:
Timestamp:
Jun 6, 2004, 5:43:22 PM (22 years ago)
Author:
gusciora
Message:

...

Location:
trunk/psLib/test/image
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/image/tst_psImageStats01.c

    r887 r894  
    1212#include "psImageStats.h"
    1313#define NUM_BINS 20
    14 #define IMAGE_SIZE 512
     14#define N 32
     15#define M 64
    1516
    1617int main()
    1718{
    1819    psStats *myStats    = NULL;
     20    psStats *myStats2   = NULL;
    1921    psImage *tmpImage   = NULL;
    2022    psImage *tmpMask    = NULL;
    2123    int testStatus      = true;
    2224    int memLeaks        = 0;
     25    int nb              = 0;
    2326    int i               = 0;
    2427    int j               = 0;
     28    int IMAGE_X_SIZE    = 0;
     29    int IMAGE_Y_SIZE    = 0;
    2530    int currentId       = 0;
    2631
    2732    currentId       = psMemGetId();
    28     /*************************************************************************/
    29     /*  Allocate and initialize data structures                      */
    30     /*************************************************************************/
    31     tmpImage = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
    32     for (i=0;i<IMAGE_SIZE;i++) {
    33         for (j=0;j<IMAGE_SIZE;j++) {
    34             tmpImage->data.F32[i][j] = (float) (i + j);
     33    for (nb=0;nb<6;nb++) {
     34        if (nb == 0) {
     35            IMAGE_X_SIZE = 1;
     36            IMAGE_Y_SIZE = 1;
    3537        }
    36     }
    37     tmpMask = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_U8);
    38     for (i=0;i<IMAGE_SIZE;i++) {
    39         for (j=0;j<IMAGE_SIZE;j++) {
    40             if ((i > (IMAGE_SIZE/2)) &&
    41                     (j > (IMAGE_SIZE/2))) {
    42                 tmpMask->data.U8[i][j] = 1;
    43             } else {
    44                 tmpMask->data.U8[i][j] = 0;
     38        if (nb == 1) {
     39            IMAGE_X_SIZE = 1;
     40            IMAGE_Y_SIZE = N;
     41        }
     42        if (nb == 2) {
     43            IMAGE_X_SIZE = N;
     44            IMAGE_Y_SIZE = 1;
     45        }
     46        if (nb == 3) {
     47            IMAGE_X_SIZE = N;
     48            IMAGE_Y_SIZE = N;
     49        }
     50        if (nb == 4) {
     51            IMAGE_X_SIZE = N;
     52            IMAGE_Y_SIZE = M;
     53        }
     54        if (nb == 5) {
     55            IMAGE_X_SIZE = M;
     56            IMAGE_Y_SIZE = N;
     57        }
     58        printf("*******************************\n");
     59        printf("* IMAGE SIZE is (%d by %d)\n", IMAGE_X_SIZE, IMAGE_Y_SIZE);
     60        printf("*******************************\n");
     61
     62        /*************************************************************************/
     63        /*  Allocate and initialize data structures                      */
     64        /*************************************************************************/
     65        tmpImage = psImageAlloc(IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32);
     66
     67        for (i=0;i<tmpImage->numRows;i++) {
     68            for (j=0;j<tmpImage->numCols;j++) {
     69                tmpImage->data.F32[i][j] = (float) (i + j);
    4570            }
    4671        }
     72        tmpMask = psImageAlloc(IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8);
     73        for (i=0;i<tmpMask->numRows;i++) {
     74            for (j=0;j<tmpMask->numCols;j++) {
     75                if ((i > (tmpMask->numRows/2)) &&
     76                        (j > (tmpMask->numCols/2))) {
     77                    tmpMask->data.U8[i][j] = 1;
     78                } else {
     79                    tmpMask->data.U8[i][j] = 0;
     80                }
     81            }
     82        }
     83
     84        myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
     85        /*************************************************************************/
     86        /*  Calculate Sample Mean with no mask                           */
     87        /*************************************************************************/
     88        printPositiveTestHeader(stdout,
     89                                "psImageStats functions",
     90                                "Calculate Sample Mean, no mask %d");
     91
     92        myStats = psImageStats(myStats, tmpImage, NULL, 0);
     93        printf("The sample mean was %f\n", myStats->sampleMean);
     94
     95        psMemCheckCorruption(1);
     96
     97        printFooter(stdout,
     98                    "psImageStats functions",
     99                    "Calculate Sample Mean, no mask",
     100                    testStatus);
     101
     102        /*************************************************************************/
     103        /*  Calculate Sample Mean with mask                              */
     104        /*************************************************************************/
     105        printPositiveTestHeader(stdout,
     106                                "psImageStats functions",
     107                                "Calculate Sample Mean with mask");
     108
     109        myStats = psImageStats(myStats, tmpImage, tmpMask, 1);
     110        printf("The sample mean was %f\n", myStats->sampleMean);
     111
     112        psMemCheckCorruption(1);
     113
     114        printFooter(stdout,
     115                    "psImageStats functions",
     116                    "Calculate Sample Mean with mask",
     117                    testStatus);
     118
     119        /*************************************************************************/
     120        /*  Deallocate data structures                                   */
     121        /*************************************************************************/
     122        printPositiveTestHeader(stdout,
     123                                "psImageStats functions",
     124                                "Deallocate the psStats/psImage structure.");
     125        psStatsFree(myStats);
     126        psImageFree(tmpImage);
     127        psImageFree(tmpMask);
     128
     129        psMemCheckCorruption(1);
     130        memLeaks = psMemCheckLeaks(currentId,NULL,NULL);
     131        if (0 != memLeaks) {
     132            psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
     133        }
     134
     135        printFooter(stdout,
     136                    "psImageStats functions",
     137                    "Deallocate the psStats/psImage structure.",
     138                    testStatus);
    47139    }
    48140
    49     myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    50141    /*************************************************************************/
    51     /*  Calculate Sample Mean with no mask                           */
     142    /*  Test With Various Null Inputs                                        */
    52143    /*************************************************************************/
    53144    printPositiveTestHeader(stdout,
    54145                            "psImageStats functions",
    55                             "Calculate Sample Mean, no mask");
     146                            "Test With Various Null Inputs");
     147
     148    tmpImage = psImageAlloc(IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32);
     149    tmpMask = psImageAlloc(IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8);
     150    myStats = psStatsAlloc(0);
     151
     152    myStats2 = psImageStats(myStats, NULL, NULL, 0);
     153    if (myStats2 != NULL) {
     154        printf("ERROR: myStats2 = psImageStats(myStats, NULL, NULL, 0) != NULL\n");
     155    }
     156
     157    myStats2 = psImageStats(NULL, tmpImage, NULL, 0);
     158    if (myStats2 != NULL) {
     159        printf("ERROR: myStats2 = psImageStats(NULL, tmpImage, NULL, 0) != NULL\n");
     160    }
    56161
    57162    myStats = psImageStats(myStats, tmpImage, NULL, 0);
    58     printf("The sample mean was %f\n", myStats->sampleMean);
     163    //
     164    // NOTE: verify that myStats is good here.
     165    //
    59166
    60     psMemCheckCorruption(1);
    61 
    62     printFooter(stdout,
    63                 "psImageStats functions",
    64                 "Calculate Sample Mean, no mask",
    65                 testStatus);
    66 
    67     /*************************************************************************/
    68     /*  Calculate Sample Mean with mask                              */
    69     /*************************************************************************/
    70     printPositiveTestHeader(stdout,
    71                             "psImageStats functions",
    72                             "Calculate Sample Mean with mask");
    73 
    74     myStats = psImageStats(myStats, tmpImage, tmpMask, 1);
    75     printf("The sample mean was %f\n", myStats->sampleMean);
    76 
    77     psMemCheckCorruption(1);
    78 
    79     printFooter(stdout,
    80                 "psImageStats functions",
    81                 "Calculate Sample Mean with mask",
    82                 testStatus);
    83 
    84     /*************************************************************************/
    85     /*  Deallocate data structures                                   */
    86     /*************************************************************************/
    87     printPositiveTestHeader(stdout,
    88                             "psImageStats functions",
    89                             "Deallocate the psStats/psImage structure.");
    90167    psStatsFree(myStats);
    91168    psImageFree(tmpImage);
     
    100177    printFooter(stdout,
    101178                "psImageStats functions",
    102                 "Deallocate the psStats/psImage structure.",
     179                "Test With Various Null Inputs",
    103180                testStatus);
    104 
    105181    return (!testStatus);
    106182}
  • trunk/psLib/test/image/verified/tst_psImageStats01.stdout

    r890 r894  
    1 /----------------------------- TESTPOINT ------------------------------------------\
    2 |             TestFile: tst_psImageStats01.c                                       |
    3 |            TestPoint: psImageStats functions{Calculate Sample Mean, no mask}     |
    4 |             TestType: Positive                                                   |
    5 \----------------------------------------------------------------------------------/
    6 
    7 The sample mean was 510.608276
    8 
    9 ---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean, no mask} | tst_psImageStats01.c)
    10 
    11 /----------------------------- TESTPOINT ------------------------------------------\
    12 |             TestFile: tst_psImageStats01.c                                       |
    13 |            TestPoint: psImageStats functions{Calculate Sample Mean with mask}    |
    14 |             TestType: Positive                                                   |
    15 \----------------------------------------------------------------------------------/
    16 
    17 The sample mean was 425.861176
    18 
    19 ---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean with mask} | tst_psImageStats01.c)
    20 
    21 /----------------------------- TESTPOINT ------------------------------------------\
    22 |             TestFile: tst_psImageStats01.c                                       |
    23 |            TestPoint: psImageStats functions{Deallocate the psStats/psImage structure.} |
    24 |             TestType: Positive                                                   |
    25 \----------------------------------------------------------------------------------/
    26 
    27 
    28 ---> TESTPOINT PASSED (psImageStats functions{Deallocate the psStats/psImage structure.} | tst_psImageStats01.c)
    29 
     1*******************************
     2* IMAGE SIZE is (1 by 1)
     3*******************************
     4/----------------------------- TESTPOINT ------------------------------------------\
     5|             TestFile: tst_psImageStats01.c                                       |
     6|            TestPoint: psImageStats functions{Calculate Sample Mean, no mask %d}  |
     7|             TestType: Positive                                                   |
     8\----------------------------------------------------------------------------------/
     9
     10The sample mean was 0.000000
     11
     12---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean, no mask} | tst_psImageStats01.c)
     13
     14/----------------------------- TESTPOINT ------------------------------------------\
     15|             TestFile: tst_psImageStats01.c                                       |
     16|            TestPoint: psImageStats functions{Calculate Sample Mean with mask}    |
     17|             TestType: Positive                                                   |
     18\----------------------------------------------------------------------------------/
     19
     20The sample mean was 0.000000
     21
     22---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean with mask} | tst_psImageStats01.c)
     23
     24/----------------------------- TESTPOINT ------------------------------------------\
     25|             TestFile: tst_psImageStats01.c                                       |
     26|            TestPoint: psImageStats functions{Deallocate the psStats/psImage structure.} |
     27|             TestType: Positive                                                   |
     28\----------------------------------------------------------------------------------/
     29
     30
     31---> TESTPOINT PASSED (psImageStats functions{Deallocate the psStats/psImage structure.} | tst_psImageStats01.c)
     32
     33*******************************
     34* IMAGE SIZE is (1 by 32)
     35*******************************
     36/----------------------------- TESTPOINT ------------------------------------------\
     37|             TestFile: tst_psImageStats01.c                                       |
     38|            TestPoint: psImageStats functions{Calculate Sample Mean, no mask %d}  |
     39|             TestType: Positive                                                   |
     40\----------------------------------------------------------------------------------/
     41
     42The sample mean was 15.500000
     43
     44---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean, no mask} | tst_psImageStats01.c)
     45
     46/----------------------------- TESTPOINT ------------------------------------------\
     47|             TestFile: tst_psImageStats01.c                                       |
     48|            TestPoint: psImageStats functions{Calculate Sample Mean with mask}    |
     49|             TestType: Positive                                                   |
     50\----------------------------------------------------------------------------------/
     51
     52The sample mean was 15.500000
     53
     54---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean with mask} | tst_psImageStats01.c)
     55
     56/----------------------------- TESTPOINT ------------------------------------------\
     57|             TestFile: tst_psImageStats01.c                                       |
     58|            TestPoint: psImageStats functions{Deallocate the psStats/psImage structure.} |
     59|             TestType: Positive                                                   |
     60\----------------------------------------------------------------------------------/
     61
     62
     63---> TESTPOINT PASSED (psImageStats functions{Deallocate the psStats/psImage structure.} | tst_psImageStats01.c)
     64
     65*******************************
     66* IMAGE SIZE is (32 by 1)
     67*******************************
     68/----------------------------- TESTPOINT ------------------------------------------\
     69|             TestFile: tst_psImageStats01.c                                       |
     70|            TestPoint: psImageStats functions{Calculate Sample Mean, no mask %d}  |
     71|             TestType: Positive                                                   |
     72\----------------------------------------------------------------------------------/
     73
     74The sample mean was 15.500000
     75
     76---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean, no mask} | tst_psImageStats01.c)
     77
     78/----------------------------- TESTPOINT ------------------------------------------\
     79|             TestFile: tst_psImageStats01.c                                       |
     80|            TestPoint: psImageStats functions{Calculate Sample Mean with mask}    |
     81|             TestType: Positive                                                   |
     82\----------------------------------------------------------------------------------/
     83
     84The sample mean was 15.500000
     85
     86---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean with mask} | tst_psImageStats01.c)
     87
     88/----------------------------- TESTPOINT ------------------------------------------\
     89|             TestFile: tst_psImageStats01.c                                       |
     90|            TestPoint: psImageStats functions{Deallocate the psStats/psImage structure.} |
     91|             TestType: Positive                                                   |
     92\----------------------------------------------------------------------------------/
     93
     94
     95---> TESTPOINT PASSED (psImageStats functions{Deallocate the psStats/psImage structure.} | tst_psImageStats01.c)
     96
     97*******************************
     98* IMAGE SIZE is (32 by 32)
     99*******************************
     100/----------------------------- TESTPOINT ------------------------------------------\
     101|             TestFile: tst_psImageStats01.c                                       |
     102|            TestPoint: psImageStats functions{Calculate Sample Mean, no mask %d}  |
     103|             TestType: Positive                                                   |
     104\----------------------------------------------------------------------------------/
     105
     106The sample mean was 31.000000
     107
     108---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean, no mask} | tst_psImageStats01.c)
     109
     110/----------------------------- TESTPOINT ------------------------------------------\
     111|             TestFile: tst_psImageStats01.c                                       |
     112|            TestPoint: psImageStats functions{Calculate Sample Mean with mask}    |
     113|             TestType: Positive                                                   |
     114\----------------------------------------------------------------------------------/
     115
     116The sample mean was 26.212767
     117
     118---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean with mask} | tst_psImageStats01.c)
     119
     120/----------------------------- TESTPOINT ------------------------------------------\
     121|             TestFile: tst_psImageStats01.c                                       |
     122|            TestPoint: psImageStats functions{Deallocate the psStats/psImage structure.} |
     123|             TestType: Positive                                                   |
     124\----------------------------------------------------------------------------------/
     125
     126
     127---> TESTPOINT PASSED (psImageStats functions{Deallocate the psStats/psImage structure.} | tst_psImageStats01.c)
     128
     129*******************************
     130* IMAGE SIZE is (32 by 64)
     131*******************************
     132/----------------------------- TESTPOINT ------------------------------------------\
     133|             TestFile: tst_psImageStats01.c                                       |
     134|            TestPoint: psImageStats functions{Calculate Sample Mean, no mask %d}  |
     135|             TestType: Positive                                                   |
     136\----------------------------------------------------------------------------------/
     137
     138The sample mean was 47.000000
     139
     140---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean, no mask} | tst_psImageStats01.c)
     141
     142/----------------------------- TESTPOINT ------------------------------------------\
     143|             TestFile: tst_psImageStats01.c                                       |
     144|            TestPoint: psImageStats functions{Calculate Sample Mean with mask}    |
     145|             TestType: Positive                                                   |
     146\----------------------------------------------------------------------------------/
     147
     148The sample mean was 39.656349
     149
     150---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean with mask} | tst_psImageStats01.c)
     151
     152/----------------------------- TESTPOINT ------------------------------------------\
     153|             TestFile: tst_psImageStats01.c                                       |
     154|            TestPoint: psImageStats functions{Deallocate the psStats/psImage structure.} |
     155|             TestType: Positive                                                   |
     156\----------------------------------------------------------------------------------/
     157
     158
     159---> TESTPOINT PASSED (psImageStats functions{Deallocate the psStats/psImage structure.} | tst_psImageStats01.c)
     160
     161*******************************
     162* IMAGE SIZE is (64 by 32)
     163*******************************
     164/----------------------------- TESTPOINT ------------------------------------------\
     165|             TestFile: tst_psImageStats01.c                                       |
     166|            TestPoint: psImageStats functions{Calculate Sample Mean, no mask %d}  |
     167|             TestType: Positive                                                   |
     168\----------------------------------------------------------------------------------/
     169
     170The sample mean was 47.000000
     171
     172---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean, no mask} | tst_psImageStats01.c)
     173
     174/----------------------------- TESTPOINT ------------------------------------------\
     175|             TestFile: tst_psImageStats01.c                                       |
     176|            TestPoint: psImageStats functions{Calculate Sample Mean with mask}    |
     177|             TestType: Positive                                                   |
     178\----------------------------------------------------------------------------------/
     179
     180The sample mean was 39.656349
     181
     182---> TESTPOINT PASSED (psImageStats functions{Calculate Sample Mean with mask} | tst_psImageStats01.c)
     183
     184/----------------------------- TESTPOINT ------------------------------------------\
     185|             TestFile: tst_psImageStats01.c                                       |
     186|            TestPoint: psImageStats functions{Deallocate the psStats/psImage structure.} |
     187|             TestType: Positive                                                   |
     188\----------------------------------------------------------------------------------/
     189
     190
     191---> TESTPOINT PASSED (psImageStats functions{Deallocate the psStats/psImage structure.} | tst_psImageStats01.c)
     192
     193/----------------------------- TESTPOINT ------------------------------------------\
     194|             TestFile: tst_psImageStats01.c                                       |
     195|            TestPoint: psImageStats functions{Test With Various Null Inputs}      |
     196|             TestType: Positive                                                   |
     197\----------------------------------------------------------------------------------/
     198
     199
     200---> TESTPOINT PASSED (psImageStats functions{Test With Various Null Inputs} | tst_psImageStats01.c)
     201
Note: See TracChangeset for help on using the changeset viewer.