IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1033


Ignore:
Timestamp:
Jun 14, 2004, 1:03:48 PM (22 years ago)
Author:
desonia
Message:

fixed test for psImageClip and added test for clipping of complex image.

Location:
trunk/psLib/test
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/collections/tst_psList.c

    r982 r1033  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-10 18:49:28 $
     8 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-14 23:03:43 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4242
    4343    if (! runTestSuite(stderr,"psList",tests)) {
    44         psAbort(__FILE__,"One or more tests failed");
     44        psError(__FILE__,"One or more tests failed");
     45        return 1;
    4546    }
    4647    return 0;
  • trunk/psLib/test/image/tst_psImage.c

    r981 r1033  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-06-10 18:48:35 $
     8 *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-06-14 23:03:43 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343    testImageOverlay();
    4444    if (! runTestSuite(stderr,"psImage",tests)) {
    45         psAbort(__FILE__,"One or more tests failed");
     45        psError(__FILE__,"One or more tests failed");
     46        return 1;
    4647    }
    4748    return 0;
     
    642643    #define testImageClipByType(datatype) \
    643644    img = psImageAlloc(c,r,PS_TYPE_##datatype); \
    644     for (unsigned row=0;row<r;row++) { \
     645    for (unsigned int row=0;row<r;row++) { \
    645646        ps##datatype* imgRow = img->data.datatype[row]; \
    646         for (unsigned col=0;col<c;col++) { \
     647        for (unsigned int col=0;col<c;col++) { \
    647648            imgRow[col] = (ps##datatype)(row+col); \
    648649        } \
     
    654655    \
    655656    numClipped = 0; \
    656     for (unsigned row=0;row<r;row++) { \
     657    for (unsigned int row=0;row<r;row++) { \
    657658        ps##datatype* imgRow = img->data.datatype[row]; \
    658         for (unsigned col=0;col<c;col++) { \
     659        for (unsigned int col=0;col<c;col++) { \
    659660            ps##datatype value = (ps##datatype)(row+col); \
    660661            if (value < (ps##datatype)min) { \
     
    666667            } \
    667668            if (fabsf(imgRow[col]-value) > FLT_EPSILON) { \
    668                 psError(__func__,"Pixel value is not as expected (%d vs %d) at %d,%d", \
     669                psError(__func__,"Pixel value is not as expected (%d vs %d) at %u,%u", \
    669670                        imgRow[col],value,col,row); \
    670671                return 1; \
     
    679680    psImageFree(img);
    680681
     682    #define testImageClipByComplexType(datatype) \
     683    img = psImageAlloc(c,r,PS_TYPE_##datatype); \
     684    for (unsigned int row=0;row<r;row++) { \
     685        ps##datatype* imgRow = img->data.datatype[row]; \
     686        for (unsigned int col=0;col<c;col++) { \
     687            imgRow[col] = (ps##datatype)(row+I*col); \
     688        } \
     689    } \
     690    min = (float)r/2.0f; \
     691    max = (float)r; \
     692    \
     693    retVal = psImageClip(img,min,-1.0f,max,-2.0f); \
     694    \
     695    numClipped = 0; \
     696    for (unsigned int row=0;row<r;row++) { \
     697        ps##datatype* imgRow = img->data.datatype[row]; \
     698        for (unsigned int col=0;col<c;col++) { \
     699            ps##datatype value = row+I*col; \
     700            if (cabs(value) < min) { \
     701                numClipped++; \
     702                value = -1.0f; \
     703            } else if (cabs(value) > max) { \
     704                numClipped++; \
     705                value = -2.0f; \
     706            } \
     707            if (fabsf(creal(imgRow[col])-creal(value)) > FLT_EPSILON || \
     708                    fabsf(cimag(imgRow[col])-cimag(value)) > FLT_EPSILON) { \
     709                psError(__func__,"Pixel value is not as expected (%.2f+%.2fi vs %.2f+%.2fi) at %u,%u", \
     710                        creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \
     711                return 1; \
     712            } \
     713        } \
     714    } \
     715    if (retVal != numClipped) { \
     716        psError(__func__,"Expected %d clips, but got %d", \
     717                numClipped,retVal); \
     718        return 2; \
     719    } \
     720    psImageFree(img);
     721
     722    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of F64 imagery");
    681723    testImageClipByType(F64);
     724    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of F32 imagery");
    682725    testImageClipByType(F32);
    683     testImageClipByType(S64);
     726    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of S32 imagery");
    684727    testImageClipByType(S32);
     728    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of S16 imagery");
    685729    testImageClipByType(S16);
     730    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of S8 imagery");
    686731    testImageClipByType(S8);
    687     testImageClipByType(U64);
     732    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of U32 imagery");
    688733    testImageClipByType(U32);
     734    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of U16 imagery");
    689735    testImageClipByType(U16);
     736    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of U8 imagery");
    690737    testImageClipByType(U8);
     738    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of C32 imagery");
     739    testImageClipByComplexType(C32);
     740    psLogMsg(__func__,PS_LOG_INFO,"Testing clipping of C64 imagery");
     741    testImageClipByComplexType(C64);
    691742
    692743    // Verify the retuned integer is zero, psImage structure input is unmodified
  • trunk/psLib/test/image/verified/tst_psImage.stderr

    r1018 r1033  
    105105
    106106 <DATE> <TIME> <HOST> |I|  testImageClip|psImageClip shall limit the minimum and maximum data value within a psImage structure
     107 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of F64 imagery
     108 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of F32 imagery
     109 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of S32 imagery
     110 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of S16 imagery
     111 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of S8 imagery
     112 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of U32 imagery
     113 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of U16 imagery
     114 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of U8 imagery
     115 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of C32 imagery
     116 <DATE> <TIME> <HOST> |I|  testImageClip|Testing clipping of C64 imagery
    107117 <DATE> <TIME> <HOST> |I|  testImageClip|Following should be an error (max<min)
    108118 <DATE> <TIME> <HOST> |E|    psImageClip|psImageClip can not be invoked with max < min.
Note: See TracChangeset for help on using the changeset viewer.