IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 6, 2004, 11:50:14 AM (22 years ago)
Author:
desonia
Message:

modified runTest / FullUnitTest to suppress line numbers in messages.

File:
1 edited

Legend:

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

    r1364 r1404  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2004-08-02 18:30:10 $
     8*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2004-08-06 21:50:14 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727                              }
    2828                          };
    29                          
     29
    3030int main( int argc, char* argv[] )
    3131{
     
    4141    psVector* out = NULL;
    4242    psImage* image = psImageAlloc( c, r, PS_TYPE_F32 );
     43    psVector* positions = psVectorAlloc( r, PS_TYPE_U32 );
    4344    psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK );
    4445    psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN );
    45    
     46
    4647    /*
    4748        This function shall extract pixels from a specified region of a psImage
    4849        structure into a vector using a specified statistical method.
    49    
     50
    5051        Verify the returned psVector structure contains expected data, if the
    5152        input psImage input has known data and the psStats structure specifies
     
    5758     
    5859     */
    59    
     60
    6061    for ( int row = 0;row < r;row++ ) {
    61             psF32* imageRow = image->data.F32[ row ];
    62             psMaskType* maskRow = image->data.V[ row ];
    63             psF32 rowOffset = ( psF32 ) row / ( psF32 ) r;
    64             for ( int col = 0;col < c;col++ ) {
    65                     imageRow[ col ] = ( psF32 ) col + rowOffset;
    66                     maskRow[ col ] = 0;
    67                 }
     62        psF32* imageRow = image->data.F32[ row ];
     63        psMaskType* maskRow = image->data.V[ row ];
     64        psF32 rowOffset = ( psF32 ) row / ( psF32 ) r;
     65        for ( int col = 0;col < c;col++ ) {
     66            imageRow[ col ] = ( psF32 ) col + rowOffset;
     67            maskRow[ col ] = 0;
    6868        }
    69        
     69    }
     70
    7071    // test MxN case
    71    
     72
    7273    #define PSIMAGESLICE_TEST1(M,N,DIRECTION,TRUTH_SIZE,TRUTHPIX_X,TRUTHPIX_Y,TESTNUM) \
    73     out = psImageSlice(out,image,mask,1,c/10,r/10,M,N,DIRECTION,stat); \
     74    out = psImageSlice(out,positions,image,mask,1,c/10,r/10,M,N,DIRECTION,stat); \
    7475    \
    7576    if (out->n != TRUTH_SIZE) { \
    76             psError(__func__,"Number of results is wrong (%d, not %d)", \
    77                     out->n,n); \
    78             return TESTNUM*2+1; \
    79         } \
     77        psError(__func__,"Number of results is wrong (%d, not %d)", \
     78                out->n,n); \
     79        return TESTNUM*4+1; \
     80    } \
     81    \
     82    if (positions->n != TRUTH_SIZE) { \
     83        psError(__func__,"Number of results for positions vector is wrong (%d, not %d)", \
     84                out->n,n); \
     85        return TESTNUM*4+2; \
     86    } \
    8087    \
    8188    for (int i=0;i<out->n;i++) { \
    82             if (abs(out->data.F64[i]-image->data.F32[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF32)r) { \
    83                     psError(__func__,"Improper result at position %d.",i); \
    84                     return TESTNUM*2+2; \
    85                 } \
    86         }
    87        
     89        if (abs(out->data.F64[i]-image->data.F32[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF32)r) { \
     90            psError(__func__,"Improper result at position %d.",i); \
     91            return TESTNUM*4+3; \
     92        } \
     93        if (DIRECTION == PS_CUT_X_POS || DIRECTION == PS_CUT_X_NEG) { \
     94            if (positions->data.U32[i] != c/10+TRUTHPIX_X) { \
     95                psError(__func__,"Improper postions result @ %d.",i); \
     96                return TESTNUM*4+4; \
     97            } \
     98        } else { \
     99            if (positions->data.U32[i] != r/10+TRUTHPIX_Y) { \
     100                psError(__func__,"Improper postions result @ %d.",i); \
     101                return TESTNUM*4+4; \
     102            } \
     103        } \
     104    }
     105
    88106    // test MxN case
    89107    PSIMAGESLICE_TEST1( m, n, PS_CUT_X_POS, m, i, n / 2, 0 );
     
    91109    PSIMAGESLICE_TEST1( m, n, PS_CUT_Y_POS, n, m / 2, i, 2 );
    92110    PSIMAGESLICE_TEST1( m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3 );
    93    
     111
    94112    // test Mx1 case
    95113    PSIMAGESLICE_TEST1( m, 1, PS_CUT_X_POS, m, i, 0, 4 );
     
    97115    PSIMAGESLICE_TEST1( m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6 );
    98116    PSIMAGESLICE_TEST1( m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7 );
    99    
     117
    100118    // test 1xN case
    101119    PSIMAGESLICE_TEST1( 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8 );
     
    103121    PSIMAGESLICE_TEST1( 1, n, PS_CUT_Y_POS, n, 0, n - 1 - i, 10 );
    104122    PSIMAGESLICE_TEST1( 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11 );
    105    
     123
    106124    // test 1x1 case
    107125    PSIMAGESLICE_TEST1( 1, 1, PS_CUT_X_POS, 1, 0, 0, 12 );
     
    109127    PSIMAGESLICE_TEST1( 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14 );
    110128    PSIMAGESLICE_TEST1( 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15 );
    111    
     129
    112130    /*
    113131       Verify the returned psVector structure pointer is null and program
    114132       execution doesn't stop, if input psImage input is null.
    115    
    116     */
    117     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    118     out = psImageSlice( out, NULL, NULL, 0, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
    119     if ( out != NULL ) {
    120             psError( __func__, "Giving a NULL image, psImageSlice didn't return NULL as expected" );
    121             return 41;
    122         }
    123        
    124        
     133
     134    */
     135    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
     136    out = psImageSlice( out, NULL, NULL, NULL, 0, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
     137    if ( out != NULL ) {
     138        psError( __func__, "Giving a NULL image, psImageSlice didn't return NULL as expected" );
     139        return 101;
     140    }
     141
     142
    125143    /*
    126144       Verify the returned psVector structure pointer is null and program
     
    128146    */
    129147    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    130     out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, NULL );
    131     if ( out != NULL ) {
    132             psError( __func__, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
    133             return 42;
    134         }
    135        
    136     /*
    137    
     148    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, NULL );
     149    if ( out != NULL ) {
     150        psError( __func__, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
     151        return 102;
     152    }
     153
     154    /*
     155
    138156       Verify the returned psVector structure pointer is null and program
    139157       executions doesn't stop, if the input direction is not set to one of
     
    141159    */
    142160    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    143     out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, 5, stat );
    144     if ( out != NULL ) {
    145             psError( __func__, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" );
    146             return 43;
    147         }
    148        
     161    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 1, 1, 5, stat );
     162    if ( out != NULL ) {
     163        psError( __func__, "Giving a bogus direction flag, psImageSlice didn't return NULL as expected" );
     164        return 103;
     165    }
     166
    149167    /*
    150168       Verify the returned psVector structure pointer is null and program
     
    152170    */
    153171    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    154     out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 0, 0, PS_CUT_X_POS, stat );
    155     if ( out != NULL ) {
    156             psError( __func__, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" );
    157             return 44;
    158         }
    159        
     172    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 0, 0, PS_CUT_X_POS, stat );
     173    if ( out != NULL ) {
     174        psError( __func__, "Giving a 0x0 region, psImageSlice didn't return NULL as expected" );
     175        return 104;
     176    }
     177
    160178    /*
    161179       Verify the returned psVector structure pointer is null and program
     
    164182    */
    165183    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    166     out = psImageSlice( out, image, mask, 1, c + 1, r / 10, 1, 1, PS_CUT_X_POS, stat );
    167     if ( out != NULL ) {
    168             psError( __func__, "Giving an invalid x position, psImageSlice didn't return NULL as expected" );
    169             return 45;
    170         }
    171        
    172     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    173     out = psImageSlice( out, image, mask, 1, c / 10, r + 1, 1, 1, PS_CUT_X_POS, stat );
    174     if ( out != NULL ) {
    175             psError( __func__, "Giving an invalid y position, psImageSlice didn't return NULL as expected" );
    176             return 46;
    177         }
    178        
    179     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    180     out = psImageSlice( out, image, mask, 1, c / 10, r / 10, c, 1, PS_CUT_X_POS, stat );
    181     if ( out != NULL ) {
    182             psError( __func__, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" );
    183             return 47;
    184         }
    185        
    186     psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    187     out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, r, PS_CUT_X_POS, stat );
    188     if ( out != NULL ) {
    189             psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
    190             return 48;
    191         }
    192        
     184    out = psImageSlice( out, NULL, image, mask, 1, c + 1, r / 10, 1, 1, PS_CUT_X_POS, stat );
     185    if ( out != NULL ) {
     186        psError( __func__, "Giving an invalid x position, psImageSlice didn't return NULL as expected" );
     187        return 105;
     188    }
     189
     190    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
     191    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r + 1, 1, 1, PS_CUT_X_POS, stat );
     192    if ( out != NULL ) {
     193        psError( __func__, "Giving an invalid y position, psImageSlice didn't return NULL as expected" );
     194        return 106;
     195    }
     196
     197    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
     198    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, c, 1, PS_CUT_X_POS, stat );
     199    if ( out != NULL ) {
     200        psError( __func__, "Giving an invalid numCols, psImageSlice didn't return NULL as expected" );
     201        return 107;
     202    }
     203
     204    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
     205    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 1, r, PS_CUT_X_POS, stat );
     206    if ( out != NULL ) {
     207        psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
     208        return 108;
     209    }
     210
    193211    /*
    194212       Verify the returned psVector structure pointer is null and program
     
    198216    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error." );
    199217    stat->options = 0;
    200     out = psImageSlice( out, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
    201     if ( out != NULL ) {
    202             psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
    203             return 49;
    204         }
    205        
     218    out = psImageSlice( out, NULL, image, mask, 1, c / 10, r / 10, 1, 1, PS_CUT_X_POS, stat );
     219    if ( out != NULL ) {
     220        psError( __func__, "Giving an invalid numRows, psImageSlice didn't return NULL as expected" );
     221        return 109;
     222    }
     223
    206224    psFree( image );
     225    psFree( positions );
    207226    psFree( mask );
    208227    psFree( out );
    209228    psFree( stat );
    210    
     229
    211230    return 0;
    212    
     231
    213232}
    214233
    215 
    216 
    217 
    218 
    219 
    220 
    221 
Note: See TracChangeset for help on using the changeset viewer.