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_psImageStats00.c

    r1365 r1406  
    2828    int IMAGE_Y_SIZE = 0;
    2929    int currentId = 0;
    30    
     30
    3131    currentId = psMemGetId();
    3232    for ( nb = 0;nb < 6;nb++ ) {
    33             if ( nb == 0 ) {
    34                     IMAGE_X_SIZE = 1;
    35                     IMAGE_Y_SIZE = 1;
     33        if ( nb == 0 ) {
     34            IMAGE_X_SIZE = 1;
     35            IMAGE_Y_SIZE = 1;
     36        }
     37        if ( nb == 1 ) {
     38            IMAGE_X_SIZE = 1;
     39            IMAGE_Y_SIZE = N;
     40        }
     41        if ( nb == 2 ) {
     42            IMAGE_X_SIZE = N;
     43            IMAGE_Y_SIZE = 1;
     44        }
     45        if ( nb == 3 ) {
     46            IMAGE_X_SIZE = N;
     47            IMAGE_Y_SIZE = N;
     48        }
     49        if ( nb == 4 ) {
     50            IMAGE_X_SIZE = N;
     51            IMAGE_Y_SIZE = M;
     52        }
     53        if ( nb == 5 ) {
     54            IMAGE_X_SIZE = M;
     55            IMAGE_Y_SIZE = N;
     56        }
     57        printf( "*******************************\n" );
     58        printf( "* IMAGE SIZE is (%d by %d)\n", IMAGE_X_SIZE, IMAGE_Y_SIZE );
     59        printf( "*******************************\n" );
     60        /*********************************************************************/
     61        /*  Allocate and initialize data structures                      */
     62        /*********************************************************************/
     63        tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 );
     64
     65        for ( i = 0;i < tmpImage->numRows;i++ ) {
     66            for ( j = 0;j < tmpImage->numCols;j++ ) {
     67                tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j + 0.1 );
     68            }
     69        }
     70        tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 );
     71        for ( i = 0;i < tmpMask->numRows;i++ ) {
     72            for ( j = 0;j < tmpMask->numCols;j++ ) {
     73                if ( ( i > ( tmpMask->numRows / 2 ) ) &&
     74                        ( j > ( tmpMask->numCols / 2 ) ) ) {
     75                    tmpMask->data.U8[ i ][ j ] = 1;
     76                } else {
     77                    tmpMask->data.U8[ i ][ j ] = 0;
    3678                }
    37             if ( nb == 1 ) {
    38                     IMAGE_X_SIZE = 1;
    39                     IMAGE_Y_SIZE = N;
    40                 }
    41             if ( nb == 2 ) {
    42                     IMAGE_X_SIZE = N;
    43                     IMAGE_Y_SIZE = 1;
    44                 }
    45             if ( nb == 3 ) {
    46                     IMAGE_X_SIZE = N;
    47                     IMAGE_Y_SIZE = N;
    48                 }
    49             if ( nb == 4 ) {
    50                     IMAGE_X_SIZE = N;
    51                     IMAGE_Y_SIZE = M;
    52                 }
    53             if ( nb == 5 ) {
    54                     IMAGE_X_SIZE = M;
    55                     IMAGE_Y_SIZE = N;
    56                 }
    57             printf( "*******************************\n" );
    58             printf( "* IMAGE SIZE is (%d by %d)\n", IMAGE_X_SIZE, IMAGE_Y_SIZE );
    59             printf( "*******************************\n" );
    60             /*********************************************************************/
    61             /*  Allocate and initialize data structures                      */
    62             /*********************************************************************/
    63             tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 );
    64            
    65             for ( i = 0;i < tmpImage->numRows;i++ ) {
    66                     for ( j = 0;j < tmpImage->numCols;j++ ) {
    67                             tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j + 0.1 );
    68                         }
    69                 }
    70             tmpMask = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_U8 );
    71             for ( i = 0;i < tmpMask->numRows;i++ ) {
    72                     for ( j = 0;j < tmpMask->numCols;j++ ) {
    73                             if ( ( i > ( tmpMask->numRows / 2 ) ) &&
    74                                     ( j > ( tmpMask->numCols / 2 ) ) ) {
    75                                     tmpMask->data.U8[ i ][ j ] = 1;
    76                                 } else {
    77                                     tmpMask->data.U8[ i ][ j ] = 0;
    78                                 }
    79                         }
    80                 }
    81                
    82             /*************************************************************************/
    83             /*  Calculate Histogram with no mask                             */
    84             /*************************************************************************/
    85             printPositiveTestHeader( stdout,
    86                                      "psImageStats functions",
    87                                      "Calculate Histogram, no mask" );
    88                                      
    89             myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ),
    90                                        NUM_BINS );
    91             myHist = psImageHistogram( myHist, tmpImage, NULL, 0 );
    92             for ( i = 0;i < NUM_BINS;i++ ) {
    93                     printf( "Bin number %d bounds: (%.1f - %.1f) data (%d)\n", i,
    94                             myHist->bounds->data.F32[ i ],
    95                             myHist->bounds->data.F32[ i + 1 ],
    96                             myHist->nums->data.S32[ i ] );
    97                 }
    98             psFree( myHist );
    99            
    100             psMemCheckCorruption( 1 );
    101             printFooter( stdout,
    102                          "psImageStats functions",
    103                          "Calculate Histogram, no mask",
    104                          testStatus );
    105                          
    106             /*************************************************************************/
    107             /*  Calculate Histogram with mask                                */
    108             /*************************************************************************/
    109             printPositiveTestHeader( stdout,
    110                                      "psImageStats functions",
    111                                      "Calculate Histogram with mask" );
    112                                      
    113             myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ),
    114                                        NUM_BINS );
    115             myHist = psImageHistogram( myHist, tmpImage, tmpMask, 1 );
    116             for ( i = 0;i < NUM_BINS;i++ ) {
    117                     printf( "Bin number %d bounds: (%.2f - %.2f) data (%d)\n", i,
    118                             myHist->bounds->data.F32[ i ],
    119                             myHist->bounds->data.F32[ i + 1 ],
    120                             myHist->nums->data.S32[ i ] );
    121                 }
    122                
    123             psMemCheckCorruption( 1 );
    124             printFooter( stdout,
    125                          "psImageStats functions",
    126                          "Calculate Histogram with mask",
    127                          testStatus );
    128                          
    129             /*************************************************************************/
    130             /*  Deallocate data structures                                   */
    131             /*************************************************************************/
    132             printPositiveTestHeader( stdout,
    133                                      "psImageStats functions",
    134                                      "Deallocate the psHistogram/psImage structure." );
    135             psFree( myHist );
    136             psFree( tmpImage );
    137             psFree( tmpMask );
    138            
    139             psMemCheckCorruption( 1 );
    140             memLeaks = psMemCheckLeaks( currentId, NULL, NULL );
    141             if ( 0 != memLeaks ) {
    142                     psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
    143                 }
    144                
    145             printFooter( stdout,
    146                          "psImageStats functions",
    147                          "Deallocate the psHistogram/psImage structure.",
    148                          testStatus );
     79            }
    14980        }
     81
     82        /*************************************************************************/
     83        /*  Calculate Histogram with no mask                             */
     84        /*************************************************************************/
     85        printPositiveTestHeader( stdout,
     86                                 "psImageStats functions",
     87                                 "Calculate Histogram, no mask" );
     88
     89        myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ),
     90                                   NUM_BINS );
     91        myHist = psImageHistogram( myHist, tmpImage, NULL, 0 );
     92        for ( i = 0;i < NUM_BINS;i++ ) {
     93            printf( "Bin number %d bounds: (%.1f - %.1f) data (%d)\n", i,
     94                    myHist->bounds->data.F32[ i ],
     95                    myHist->bounds->data.F32[ i + 1 ],
     96                    myHist->nums->data.S32[ i ] );
     97        }
     98        psFree( myHist );
     99
     100        psMemCheckCorruption( 1 );
     101        printFooter( stdout,
     102                     "psImageStats functions",
     103                     "Calculate Histogram, no mask",
     104                     testStatus );
     105
     106        /*************************************************************************/
     107        /*  Calculate Histogram with mask                                */
     108        /*************************************************************************/
     109        printPositiveTestHeader( stdout,
     110                                 "psImageStats functions",
     111                                 "Calculate Histogram with mask" );
     112
     113        myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ),
     114                                   NUM_BINS );
     115        myHist = psImageHistogram( myHist, tmpImage, tmpMask, 1 );
     116        for ( i = 0;i < NUM_BINS;i++ ) {
     117            printf( "Bin number %d bounds: (%.2f - %.2f) data (%d)\n", i,
     118                    myHist->bounds->data.F32[ i ],
     119                    myHist->bounds->data.F32[ i + 1 ],
     120                    myHist->nums->data.S32[ i ] );
     121        }
     122
     123        psMemCheckCorruption( 1 );
     124        printFooter( stdout,
     125                     "psImageStats functions",
     126                     "Calculate Histogram with mask",
     127                     testStatus );
     128
     129        /*************************************************************************/
     130        /*  Deallocate data structures                                   */
     131        /*************************************************************************/
     132        printPositiveTestHeader( stdout,
     133                                 "psImageStats functions",
     134                                 "Deallocate the psHistogram/psImage structure." );
     135        psFree( myHist );
     136        psFree( tmpImage );
     137        psFree( tmpMask );
     138
     139        psMemCheckCorruption( 1 );
     140        memLeaks = psMemCheckLeaks( currentId, NULL, NULL );
     141        if ( 0 != memLeaks ) {
     142            psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
     143        }
     144
     145        printFooter( stdout,
     146                     "psImageStats functions",
     147                     "Deallocate the psHistogram/psImage structure.",
     148                     testStatus );
     149    }
    150150    printPositiveTestHeader( stdout,
    151151                             "psImageStats functions",
    152152                             "Calling psImageHistogram() with NULL parameters" );
    153                              
     153
    154154    tmpImage = psImageAlloc( IMAGE_X_SIZE, IMAGE_Y_SIZE, PS_TYPE_F32 );
    155155    myHist = psHistogramAlloc( 0.0, ( float ) ( IMAGE_X_SIZE + IMAGE_Y_SIZE ),
     
    157157    myHist2 = psImageHistogram( NULL, tmpImage, NULL, 0 );
    158158    if ( myHist2 != NULL ) {
    159             printf( "ERROR: myHist2 not equal to NULL\n" );
    160         }
    161        
     159        printf( "ERROR: myHist2 not equal to NULL\n" );
     160    }
     161
    162162    myHist2 = psImageHistogram( myHist, NULL, NULL, 0 );
    163163    myHist2 = psImageHistogram( NULL, tmpImage, NULL, 0 );
    164164    if ( myHist2 != NULL ) {
    165             printf( "ERROR: myHist2 not equal to NULL\n" );
    166         }
    167        
     165        printf( "ERROR: myHist2 not equal to NULL\n" );
     166    }
     167
    168168    psMemCheckCorruption( 1 );
    169169    psFree( myHist );
     
    172172    memLeaks = psMemCheckLeaks( currentId, NULL, NULL );
    173173    if ( 0 != memLeaks ) {
    174             psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
    175         }
    176        
     174        psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
     175    }
     176
    177177    printFooter( stdout,
    178178                 "psImageStats functions",
    179179                 "Calling psImageHistogram() with NULL parameters",
    180180                 testStatus );
    181                  
     181
    182182    return ( !testStatus );
    183183}
Note: See TracChangeset for help on using the changeset viewer.