IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 9, 2004, 5:16:13 PM (22 years ago)
Author:
desonia
Message:

added test for psImageOverlaySection.

File:
1 edited

Legend:

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

    r953 r980  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-09 21:20:53 $
     8 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-10 03:16:13 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626static int testImageClip(void);
    2727static int testImageClipNAN(void);
     28static int testImageOverlay(void);
    2829
    2930testDescription tests[] = {
     
    3334                              {testImageClip,"571-testImageClip",0},
    3435                              {testImageClipNAN,"572-testImageClipNAN",0},
     36                              {testImageOverlay,"573-testImageOverlay",0},
    3537                              {NULL}
    3638                          };
     
    3840int main()
    3941{
    40     psSetLogLevel(PS_LOG_INFO);
    41 
     42    psLogSetLevel(PS_LOG_INFO);
     43    testImageOverlay();
    4244    if (! runTestSuite(stderr,"psImage",tests)) {
    4345        psAbort(__FILE__,"One or more tests failed");
     
    787789    return 0;
    788790}
     791
     792int testImageOverlay(void)
     793{
     794
     795    psImage* img = NULL;
     796    psImage* img2 = NULL;
     797    unsigned int c = 128;
     798    unsigned int r = 256;
     799    int retVal;
     800
     801    /*
     802    psImageSectionOverlay shall modified pixel values in a psImage structure to
     803    be equal to the value of the originaldata and an overlay image with a
     804    specified operation. Valid operations include =, +, -, *, /.
     805
     806    Verify the returned integer is equal to the number of pixels modified
     807    and the input parameter psImage structure is modified at the specified
     808    location and range with the given overlay image and the specified
     809    function. Cases should include all the valid operations. Comparison of
     810    expected values should include a delta to allow for testing on
     811    different platforms.
     812
     813    Verify the returned integer is equal to zero and the input psImage structure
     814    is unmodified, if the overlay specified is not within the data range of the
     815    input psImage structure.
     816
     817    Verify the returned integer is equal to zero, the input psImage
     818    structure is unmodified and program execution doesn't stop, if the
     819    overlay specified is null.
     820
     821    Verify the returned integer is equal to zero and program execution
     822    doesn't stop, if the input parameter image is null.
     823
     824    Verify program execution doen't stop, if the overly image contains
     825    zero values with division operation is specified.
     826    */
     827
     828
     829
     830    #define testOverlayTypeOP(DATATYPE,OP,OPSTRING) \
     831    img = psImageAlloc(c,r,PS_TYPE_##DATATYPE); \
     832    for (unsigned row=0;row<r;row++) { \
     833        ps##DATATYPE* imgRow = img->data.DATATYPE[row]; \
     834        for (unsigned col=0;col<c;col++) { \
     835            imgRow[col] = 6.0; \
     836        } \
     837    } \
     838    img2 = psImageAlloc(c/2,r/2,PS_TYPE_##DATATYPE); \
     839    for (unsigned row=0;row<r/2;row++) { \
     840        ps##DATATYPE* img2Row = img2->data.DATATYPE[row]; \
     841        for (unsigned col=0;col<c/2;col++) { \
     842            img2Row[col] = 2.0; \
     843        } \
     844    } \
     845    retVal = psImageOverlaySection(img,img2,c/4,r/4,OPSTRING); \
     846    if (retVal != 0) { \
     847        psError(__func__,"psImageOverlaySection returned non-zero %s op",OPSTRING); \
     848        return 1; \
     849    } \
     850    for (unsigned row=0;row<r;row++) { \
     851        ps##DATATYPE* imgRow = img->data.DATATYPE[row]; \
     852        for (unsigned col=0;col<c;col++) { \
     853            ps##DATATYPE val = 6.0; \
     854            if ( ! (row < r/4 || row >= r/2+r/4 || col < c/4 || col >= c/2+c/4)) { \
     855                val OP 2.0; \
     856            } \
     857            if (fabsf(imgRow[col] - val) > FLT_EPSILON) { \
     858                psError(__func__,"Value incorrect at %d,%d (%.2f vs %.2f for %s)", \
     859                        col,row,imgRow[col],val,OPSTRING); \
     860                return 2; \
     861            } \
     862        } \
     863    } \
     864    psImageFree(img); \
     865    psImageFree(img2);
     866
     867    #define testOverlayType(DATATYPE) \
     868    testOverlayTypeOP(DATATYPE,+=,"+"); \
     869    testOverlayTypeOP(DATATYPE,-=,"-"); \
     870    testOverlayTypeOP(DATATYPE,*=,"*");\
     871    testOverlayTypeOP(DATATYPE,/=,"/");\
     872    testOverlayTypeOP(DATATYPE,=,"=");
     873
     874    testOverlayType(C64);
     875    testOverlayType(C32);
     876    testOverlayType(F64);
     877    testOverlayType(F32);
     878    testOverlayType(S16);
     879    testOverlayType(S8);
     880    testOverlayType(U16);
     881    testOverlayType(U8);
     882
     883    return 0;
     884}
Note: See TracChangeset for help on using the changeset viewer.