IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 6, 2004, 12:34:06 PM (22 years ago)
Author:
desonia
Message:

astyle fixed?

File:
1 edited

Legend:

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

    r1365 r1406  
    2929    int IMAGE_Y_SIZE = 0;
    3030    int currentId = 0;
    31    
     31
    3232    currentId = psMemGetId();
    3333    for ( nb = 0;nb < 6;nb++ ) {
    34             if ( nb == 0 ) {
    35                     IMAGE_X_SIZE = 1;
    36                     IMAGE_Y_SIZE = 1;
     34        if ( nb == 0 ) {
     35            IMAGE_X_SIZE = 1;
     36            IMAGE_Y_SIZE = 1;
     37        }
     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 );
     70            }
     71        }
     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;
    3780                }
    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 );
    70                         }
    71                 }
    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 %.2f\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 %.2f\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             psFree( myStats );
    126             psFree( tmpImage );
    127             psFree( 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 );
     81            }
    13982        }
    140        
     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 %.2f\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 %.2f\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        psFree( myStats );
     126        psFree( tmpImage );
     127        psFree( 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 );
     139    }
     140
    141141    /*************************************************************************/
    142142    /*  Test With Various Null Inputs                                        */
     
    145145                             "psImageStats functions",
    146146                             "Test With Various Null Inputs" );
    147                              
     147
    148148    tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 );
    149149    tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 );
    150150    myStats = psStatsAlloc( 0 );
    151    
     151
    152152    myStats2 = psImageStats( myStats, NULL, NULL, 0 );
    153153    if ( myStats2 != NULL ) {
    154             printf( "ERROR: myStats2 = psImageStats(myStats, NULL, NULL, 0) != NULL\n" );
    155         }
    156        
     154        printf( "ERROR: myStats2 = psImageStats(myStats, NULL, NULL, 0) != NULL\n" );
     155    }
     156
    157157    myStats2 = psImageStats( NULL, tmpImage, NULL, 0 );
    158158    if ( myStats2 != NULL ) {
    159             printf( "ERROR: myStats2 = psImageStats(NULL, tmpImage, NULL, 0) != NULL\n" );
    160         }
    161        
     159        printf( "ERROR: myStats2 = psImageStats(NULL, tmpImage, NULL, 0) != NULL\n" );
     160    }
     161
    162162    myStats2 = psImageStats( myStats, tmpImage, NULL, 0 );
    163    
     163
    164164    psFree( myStats );
    165165    psFree( tmpImage );
    166166    psFree( tmpMask );
    167    
     167
    168168    psMemCheckCorruption( 1 );
    169169    memLeaks = psMemCheckLeaks( currentId, NULL, NULL );
    170170    if ( 0 != memLeaks ) {
    171             psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
    172         }
    173        
     171        psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
     172    }
     173
    174174    printFooter( stdout,
    175175                 "psImageStats functions",
Note: See TracChangeset for help on using the changeset viewer.