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?

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

Legend:

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

    r1212 r1406  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-07-13 01:37:58 $
     8 *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-08-06 22:34:06 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626
    2727testDescription tests[] = {
    28                               {testImageAlloc,546,"psImageAlloc",0,false},
    29                               {testImageAlloc,548,"psImageFree",0,true},
    30                               {testImageSubset,547,"psImageSubset",0,false},
    31                               {testImageSubset,550,"psImageSubset",0,true},
    32                               {testImageCopy,551,"psImageCopy",0,false},
    33                               {NULL}
     28                              {
     29                                  testImageAlloc,546,"psImageAlloc",0,false
     30                              },
     31                              {
     32                                  testImageAlloc,548,"psImageFree",0,true
     33                              },
     34                              {
     35                                  testImageSubset,547,"psImageSubset",0,false
     36                              },
     37                              {
     38                                  testImageSubset,550,"psImageSubset",0,true
     39                              },
     40                              {
     41                                  testImageCopy,551,"psImageCopy",0,false
     42                              },
     43                              {
     44                                  NULL
     45                              }
    3446                          };
    3547
     
    4961    psImage* image = NULL;
    5062    unsigned int sizes = 6;
    51     unsigned int numCols[] = {0,1,1,100,100,150};
    52     unsigned int numRows[] = {0,1,100,1,150,100};
     63    unsigned int numCols[] = {
     64                                 0,1,1,100,100,150
     65                             };
     66    unsigned int numRows[] = {
     67                                 0,1,100,1,150,100
     68                             };
    5369    unsigned int types = 12;
    5470    psElemType type[] = { PS_TYPE_S8, PS_TYPE_S16, PS_TYPE_S32, PS_TYPE_S64,
  • trunk/psLib/test/image/tst_psImageExtraction.c

    r1405 r1406  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2004-08-06 22:29:11 $
     8*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2004-08-06 22:34:06 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  • trunk/psLib/test/image/tst_psImageFFT.c

    r1193 r1406  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-07-08 01:05:01 $
     8 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-08-06 22:34:06 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434
    3535testDescription tests[] = {
    36                               {testImageFFT,600,"psImageFFT",0,false},
    37                               {testImageRealImaginary,601,"psImageRealImaginary",0,false},
    38                               {testImageComplex,602,"psImageComplex",0,false},
    39                               {testImageConjugate,603,"psImageConjugate",0,false},
    40                               {testImagePowerSpectrum,604,"psImagePowerSpectrum",0,false},
    41                               {NULL}
     36                              {
     37                                  testImageFFT,600,"psImageFFT",0,false
     38                              },
     39                              {
     40                                  testImageRealImaginary,601,"psImageRealImaginary",0,false
     41                              },
     42                              {
     43                                  testImageComplex,602,"psImageComplex",0,false
     44                              },
     45                              {
     46                                  testImageConjugate,603,"psImageConjugate",0,false
     47                              },
     48                              {
     49                                  testImagePowerSpectrum,604,"psImagePowerSpectrum",0,false
     50                              },
     51                              {
     52                                  NULL
     53                              }
    4254                          };
    4355
     
    89101                    psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag);
    90102                }
    91             } else if ( (col == 0 && (row == 1 || row == n-1))
     103            } else
     104                if ( (col == 0 && (row == 1 || row == n-1))
    92105                        || (row == 0 && (col==1 || col == n-1)) ) {
    93                 psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag);
    94             }
     106                    psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag);
     107                }
    95108        }
    96109    }
  • trunk/psLib/test/image/tst_psImageIO.c

    r1253 r1406  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-07-21 23:49:52 $
     8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-08-06 22:34:06 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3535
    3636testDescription tests[] = {
    37                               {testImageRead,567,"psImageReadSection",0,false},
    38                               {testImageWrite,569,"psImageWriteSection",0,false},
    39                               {NULL}
     37                              {
     38                                  testImageRead,567,"psImageReadSection",0,false
     39                              },
     40                              {
     41                                  testImageWrite,569,"psImageWriteSection",0,false
     42                              },
     43                              {
     44                                  NULL
     45                              }
    4046                          };
    4147
     
    291297    mkdir("tmpImages",0777);
    292298    remove
    293         ("writeTest.fits");
     299        ("writeTest.fits")
     300        ;
    294301    if (! psImageWriteSection(img,0,0,0,NULL,0,"tmpImages/writeTest.fits")) {
    295302        psError(__func__,"Couldn't write writeTest.fits.");
  • trunk/psLib/test/image/tst_psImageManip.c

    r1319 r1406  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-07-29 01:20:10 $
     8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-08-06 22:34:06 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3333
    3434testDescription tests[] = {
    35                               {testImageClip,571,"psImageClip",0,false},
    36                               {testImageClipNAN,572,"psImageClipNAN",0,false},
    37                               {testImageClipComplexRegion,673,"psImageClipComplexRegion",0,false},
    38                               {testImageOverlay,573,"psImageOverlay",0,false},
    39                               {testImageRebin,559,"psImageRebin",0,false},
    40                               {testImageRoll,562,"psImageRoll",0,false},
    41                               {testImageRotate,560,"psImageRotate",0,false},
    42                               {NULL}
     35                              {
     36                                  testImageClip,571,"psImageClip",0,false
     37                              },
     38                              {
     39                                  testImageClipNAN,572,"psImageClipNAN",0,false
     40                              },
     41                              {
     42                                  testImageClipComplexRegion,673,"psImageClipComplexRegion",0,false
     43                              },
     44                              {
     45                                  testImageOverlay,573,"psImageOverlay",0,false
     46                              },
     47                              {
     48                                  testImageRebin,559,"psImageRebin",0,false
     49                              },
     50                              {
     51                                  testImageRoll,562,"psImageRoll",0,false
     52                              },
     53                              {
     54                                  testImageRotate,560,"psImageRotate",0,false
     55                              },
     56                              {
     57                                  NULL
     58                              }
    4359                          };
    4460
     
    11171133    mkdir("temp",0777);
    11181134    remove
    1119         ("temp/fOut.fits");
     1135        ("temp/fOut.fits")
     1136        ;
    11201137    remove
    1121         ("temp/sOut.fits");
     1138        ("temp/sOut.fits")
     1139        ;
    11221140    int index = 0;
    11231141    bool fail = false;
  • 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}
  • 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",
  • trunk/psLib/test/image/tst_psImageStats02.c

    r1365 r1406  
    44   thouroughly tested elsewhere, we will only test psImageStats() with
    55   the PS_STAT_SAMPLE_MEAN here.
    6 
     6 
    77   NOTE: After you debug, set CHEBY_X_DIM != CHEBY_Y_DIM.
    88   Also, uses non-square images.
     
    3232    int rc = 0;
    3333    int currentId = 0;
    34    
     34
    3535    currentId = psMemGetId();
    3636    /*************************************************************************/
     
    4040    outImage = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32 );
    4141    for ( i = 0;i < IMAGE_SIZE;i++ ) {
    42             for ( j = 0;j < IMAGE_SIZE;j++ ) {
    43                     tmpImage->data.F32[ i ][ j ] = 4.0;
    44                     tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j );
    45                     tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i );
    46                     outImage->data.F32[ i ][ j ] = 0.0;
    47                 }
     42        for ( j = 0;j < IMAGE_SIZE;j++ ) {
     43            tmpImage->data.F32[ i ][ j ] = 4.0;
     44            tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j );
     45            tmpImage->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i );
     46            outImage->data.F32[ i ][ j ] = 0.0;
    4847        }
     48    }
    4949    my2DPoly = psPolynomial2DAlloc( CHEBY_X_DIM, CHEBY_Y_DIM );
    5050    /*************************************************************************/
     
    5454                             "psImageStats functions",
    5555                             "Calculate Chebyshev Polynomials, no mask" );
    56                              
     56
    5757    my2DPoly = psImageFitPolynomial( tmpImage, my2DPoly );
    5858    for ( i = 0;i < CHEBY_X_DIM;i++ ) {
    59             for ( j = 0;j < CHEBY_Y_DIM;j++ ) {
    60                     printf( "Cheby Polynomial (%d, %d) coefficient is %.2f\n", i, j, my2DPoly->coeff[ i ][ j ] );
    61                 }
     59        for ( j = 0;j < CHEBY_Y_DIM;j++ ) {
     60            printf( "Cheby Polynomial (%d, %d) coefficient is %.2f\n", i, j, my2DPoly->coeff[ i ][ j ] );
    6261        }
    63        
     62    }
     63
    6464    psMemCheckCorruption( 1 );
    6565    printFooter( stdout,
     
    7373                             "psImageStats functions",
    7474                             "Calculate Chebyshev Polynomials, no mask" );
    75                              
     75
    7676    rc = psImageEvalPolynomial( outImage, my2DPoly );
    7777    for ( i = 0;i < IMAGE_SIZE;i++ ) {
    78             for ( j = 0;j < IMAGE_SIZE;j++ ) {
    79            
    80                     //             printf("pixel[%d][%d] is (%f, %f)\n", i, j,
    81                     //                     tmpImage->data.F32[i][j],
    82                     //                     outImage->data.F32[i][j]);
    83                     if ( fabs( outImage->data.F32[ i ][ j ] - tmpImage->data.F32[ i ][ j ] ) > THRESHOLD ) {
    84                             printf( "Pixel (%d, %d) is %.2f, should be %.2f\n", i, j,
    85                                     outImage->data.F32[ i ][ j ],
    86                                     tmpImage->data.F32[ i ][ j ] );
    87                         }
    88                        
    89                 }
     78        for ( j = 0;j < IMAGE_SIZE;j++ ) {
     79
     80            //             printf("pixel[%d][%d] is (%f, %f)\n", i, j,
     81            //                     tmpImage->data.F32[i][j],
     82            //                     outImage->data.F32[i][j]);
     83            if ( fabs( outImage->data.F32[ i ][ j ] - tmpImage->data.F32[ i ][ j ] ) > THRESHOLD ) {
     84                printf( "Pixel (%d, %d) is %.2f, should be %.2f\n", i, j,
     85                        outImage->data.F32[ i ][ j ],
     86                        tmpImage->data.F32[ i ][ j ] );
     87            }
     88
    9089        }
    91        
     90    }
     91
    9292    psMemCheckCorruption( 1 );
    9393    printFooter( stdout,
     
    9595                 "Calculate Chebyshev Polynomials, no mask",
    9696                 testStatus );
    97                  
     97
    9898    /*************************************************************************/
    9999    /*  Deallocate data structures                                   */
     
    106106    psFree( outImage );
    107107    psFree( my2DPoly );
    108    
     108
    109109    psMemCheckCorruption( 1 );
    110110    memLeaks = psMemCheckLeaks( currentId, NULL, NULL );
    111111    if ( 0 != memLeaks ) {
    112             psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
    113         }
    114        
     112        psAbort( __func__, "Memory Leaks! (%d leaks)", memLeaks );
     113    }
     114
    115115    printFooter( stdout,
    116116                 "psImageStats functions",
    117117                 "Deallocate the psStats/psImage structure.",
    118118                 testStatus );
    119                  
     119
    120120    return ( !testStatus );
    121121}
Note: See TracChangeset for help on using the changeset viewer.