IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 5, 2004, 12:21:53 PM (22 years ago)
Author:
evanalst
Message:

Add additional test cases for psImageSlice.

File:
1 edited

Legend:

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

    r1957 r1961  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2004-10-05 19:42:51 $
     8*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2004-10-05 22:21:53 $
    1010*
    1111*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343    psVector* out = NULL;
    4444    psImage* image = psImageAlloc( c, r, PS_TYPE_F32 );
     45    psImage* imgU8 = psImageAlloc( c, r, PS_TYPE_U8 );
    4546    psVector* positions = psVectorAlloc( r, PS_TYPE_U32 );
    4647    psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK );
     48    psImage* maskS8 = psImageAlloc( c, r, PS_TYPE_S8 );
     49    psImage* maskSz = psImageAlloc( r, c, PS_TYPE_MASK );
    4750    psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN );
    4851
     
    6366    for ( int row = 0;row < r;row++ ) {
    6467        psF32* imageRow = image->data.F32[ row ];
    65         psMaskType* maskRow = image->data.V[ row ];
     68        psU8* imgU8Row = imgU8->data.U8[ row ];
     69        psMaskType* maskRow = mask->data.V[ row ];
     70        psMaskType* maskSzRow = maskSz->data.V[ row ];
     71        psS8* maskS8Row = maskS8->data.V[ row ];
    6672        psF32 rowOffset = ( psF32 ) row / ( psF32 ) r;
    6773        for ( int col = 0;col < c;col++ ) {
    6874            imageRow[ col ] = ( psF32 ) col + rowOffset;
     75            imgU8Row[ col ] = (psU8) col;
    6976            maskRow[ col ] = 0;
     77            maskS8Row[ col ] = 0;
     78            maskSzRow[ col ] = 0;
    7079        }
    7180    }
     
    282291    }
    283292
     293    /* Verify that a mask of different size than the input image returns null and program
     294       execution doesn't stop.
     295    */
     296    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error mask size != image size.");
     297    stat->options = PS_STAT_SAMPLE_MEDIAN;
     298    out = psImageSlice( out, NULL,
     299                        image,
     300                        maskSz, 1,
     301                        c/10, r/10,
     302                        c/10+1, r/10+1,
     303                        PS_CUT_X_POS,
     304                        stat);
     305    if ( out != NULL ) {
     306        psError( __func__, "Mask size different than image size didn't return NULL as expected" );
     307        return 110;
     308    }
     309
     310    /* Verify the a invalid type mask returns null and program execution doesn't stop.
     311    */
     312    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error invalid mask type.");
     313    out =  psImageSlice( out, NULL,
     314                         image,
     315                         maskS8, 1,
     316                         c/10, r/10,
     317                         c/10+1, r/10+1,
     318                         PS_CUT_X_POS,
     319                         stat);
     320    if ( out != NULL ) {
     321        psError( __func__, "Mask invalid type didn't return NULL as expected.");
     322        return 111;
     323    }
     324
     325    /* Verify the input image is an invalid type */
     326    psLogMsg( __func__, PS_LOG_INFO, "Following should be an error invalid image type.");
     327    out = psImageSlice( out, NULL,
     328                        imgU8,
     329                        mask, 1,
     330                        c/10, r/10,
     331                        c/10+1, r/10+1,
     332                        PS_CUT_X_POS,
     333                        stat);
     334    if ( out != NULL ) {
     335        psError( __func__, "Input image with invalid type didn't return NULL as expected.");
     336        return 112;
     337    }
     338
    284339    psFree( image );
    285340    psFree( positions );
     
    287342    psFree( out );
    288343    psFree( stat );
     344    psFree( imgU8 );
     345    psFree( maskS8 );
     346    psFree( maskSz );
    289347
    290348    return 0;
Note: See TracChangeset for help on using the changeset viewer.