IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1926


Ignore:
Timestamp:
Sep 29, 2004, 9:50:43 AM (22 years ago)
Author:
evanalst
Message:

Add additional cases for psImageRebin to include mask, updated verified
file.

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

Legend:

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

    r1922 r1926  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-09-29 00:28:21 $
     8 *  @version $Revision: 1.23 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-09-29 19:50:43 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    860860    psImage* out = NULL;
    861861    psImage* out2 = NULL;
     862    psImage* out3 = NULL;
     863    psImage* mask = NULL;
    862864    psImage* meanTruth = NULL;
     865    psImage* meanTruthWMask = NULL;
    863866    psImage* maxTruth = NULL;
    864867    psStats stats;
     
    875878    #define testRebinType(DATATYPE)  \
    876879    in = psImageAlloc(16,16,PS_TYPE_##DATATYPE); \
     880    mask = psImageAlloc(16,16,PS_TYPE_U8); \
    877881    meanTruth = psImageAlloc(4,4,PS_TYPE_F32); \
     882    meanTruthWMask = psImageAlloc(4,4,PS_TYPE_F32); \
    878883    maxTruth = psImageAlloc(6,6,PS_TYPE_F32); \
    879884    memset(meanTruth->data.F32[0],0,sizeof(psF32)*4*4); \
     885    memset(meanTruthWMask->data.F32[0],0,sizeof(psF32)*4*4); \
    880886    memset(maxTruth->data.F32[0],0,sizeof(psF32)*6*6); \
    881887    for (int row = 0; row<16; row++) { \
    882888        ps##DATATYPE* inRow = in->data.DATATYPE[row]; \
    883889        psF32* meanTruthRow = meanTruth->data.F32[row/4]; \
     890        psF32* meanTruthWMaskRow = meanTruthWMask->data.F32[row/4]; \
    884891        psF32* maxTruthRow = maxTruth->data.F32[row/3]; \
     892        psU8* maskRow = mask->data.U8[row]; \
    885893        for (int col = 0; col<16; col++) { \
     894            if(col != 15) { \
     895                maskRow[col] = 0; \
     896            } else { \
     897                maskRow[col] = 1; \
     898            } \
    886899            inRow[col] = row + col; \
    887900            meanTruthRow[col/4] += row + col; \
     
    889902                maxTruthRow[col/3] = row+col; \
    890903            } \
     904            if(maskRow[col] == 0 ) { \
     905                meanTruthWMaskRow[col/4] += row + col; \
     906            } \
    891907        } \
    892908    } \
    893909    for (int row = 0; row<4; row++) { \
    894910        psF32* meanTruthRow = meanTruth->data.F32[row]; \
     911        psF32* meanTruthWMaskRow = meanTruthWMask->data.F32[row]; \
    895912        for (int col = 0; col<4; col++) { \
    896913            meanTruthRow[col] /= 16; \
     914            if ( col == 3 ) { \
     915                meanTruthWMaskRow[col] /= 12; \
     916            } else { \
     917                meanTruthWMaskRow[col] /= 16; \
     918            } \
    897919        } \
    898920    } \
     
    921943        } \
    922944    } \
     945    stats.options = PS_STAT_SAMPLE_MEAN; \
     946    out3 = psImageRebin(NULL,in,mask,1,4,&stats); \
     947    for (int row = 0; row<4; row++) { \
     948        ps##DATATYPE* outRow = out3->data.DATATYPE[row]; \
     949        psF32* truthRow = meanTruthWMask->data.F32[row]; \
     950        for ( int col = 0; col<4; col++) { \
     951            if(abs((int)outRow[col]-(int)truthRow[col]) > FLT_EPSILON) { \
     952                psError(__func__,"psImageRebin with mask didn't produce the proper mean " \
     953                        "result at (%d,%d) [%f vs %f].", \
     954                        col,row,outRow[col],truthRow[col]); \
     955                return 3; \
     956            } \
     957        } \
     958    } \
    923959    stats.options = PS_STAT_MAX; \
    924960    out2 = psImageRebin(out,in,NULL,0,3,&stats); \
     
    951987    psFree(in); \
    952988    psFree(out); \
     989    psFree(out3); \
     990    psFree(mask); \
    953991    psFree(meanTruth); \
     992    psFree(meanTruthWMask); \
    954993    psFree(maxTruth);
    955994
     
    9611000    // Verify the returned psImage structure is null and program execution
    9621001    // doesn't stop, if the input image type is not supported.
    963     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     1002    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for unsupported type.");
    9641003    in = psImageAlloc(16,16,PS_TYPE_U8);
     1004    mask = psImageAlloc(16,16,PS_TYPE_F32);
    9651005    stats.options = PS_STAT_SAMPLE_MEAN;
    9661006    out = psImageRebin(NULL,in,NULL,0,4,&stats);
     
    9701010        return 14;
    9711011    }
     1012    // Verify the returned psImage structure is null and program execution
     1013    // doesn't stop, if the mask type is not U8
     1014    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invallid mask type.");
     1015    out = psImageRebin(NULL,in,mask,1,4,&stats);
     1016    if(out != NULL) {
     1017        psError(__func__,"psImageRebin return an image eventhough the "
     1018                "mask is not the correct type.");
     1019        return 17;
     1020    }
     1021    psFree(mask);
    9721022    psFree(in);
    9731023
     
    9861036    // doesn't stop, if the input parameter scale is less than or equal to zero.
    9871037    in = psImageAlloc(16, 16, PS_TYPE_F32);
    988     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     1038    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for scale < 0.");
    9891039    out2 = psImageRebin(NULL,in,NULL,0,0,&stats);
    9901040
     
    9971047    // Verify the returned psImage structure is null and program execution
    9981048    // doesn't stop, if the input parameter stats is null.
    999     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     1049    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats null.");
    10001050    out2 = psImageRebin(NULL,in,NULL,0,1,NULL);
    10011051
     
    10101060    // is zero or any value which doesn't correspond to a valid statistical
    10111061    // method.
    1012     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     1062    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats options 0.");
    10131063    stats.options = 0;
    10141064    out2 = psImageRebin(NULL,in,NULL,0,1,&stats);
     
    10201070    }
    10211071
    1022     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     1072    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stat options use range.");
    10231073    stats.options = PS_STAT_USE_RANGE;
    10241074    out2 = psImageRebin(NULL,in,NULL,0,1,&stats);
     
    10331083    // doesn't stop, if the input parameter psStats structure member options
    10341084    // specifies more than one valid statistical method.
    1035     psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     1085    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for stats with multiple options.");
    10361086    stats.options = PS_STAT_SAMPLE_MEAN + PS_STAT_MAX;
    10371087    out2 = psImageRebin(NULL,in,NULL,0,1,&stats);
  • trunk/psLib/test/image/verified/tst_psImageManip.stderr

    r1923 r1926  
    125125    Following should error as overlay isn't within image boundaries
    126126<DATE><TIME>|<HOST>|E|psLib.image.psImageOverlaySection
    127     Specified subset range, [32:<LINENO>,64:<LINENO>], lies outside psImage's boundaries, [0:<LINENO>,0:<LINENO>].
     127    Specified subset range, [32:<LINENO>,64:<LINENO>], is invalid or outside input psImage's boundaries, [0:<LINENO>,0:<LINENO>].
    128128<DATE><TIME>|<HOST>|I|testImageOverlay
    129129    Following should error as overlay is NULL
     
    160160
    161161<DATE><TIME>|<HOST>|I|testImageRebin
    162     Following should be an error.
     162    Following should be an error for unsupported type.
    163163<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
    164164    Specified psImage type, psU8, is not supported.
    165 <DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
    166     Can not operate on a NULL psImage.
    167 <DATE><TIME>|<HOST>|I|testImageRebin
    168     Following should be an error.
     165<DATE><TIME>|<HOST>|I|testImageRebin
     166    Following should be an error for invallid mask type.
     167<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
     168    Input psImage mask type, psF32, is not the supported mask datatype of psU8.
     169<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
     170    Can not operate on a NULL psImage.
     171<DATE><TIME>|<HOST>|I|testImageRebin
     172    Following should be an error for scale < 0.
    169173<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
    170174    Specified scale value, 0, must be a positive value.
    171175<DATE><TIME>|<HOST>|I|testImageRebin
    172     Following should be an error.
     176    Following should be an error for stats null.
    173177<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
    174178    Specified statistic can not be NULL.
    175179<DATE><TIME>|<HOST>|I|testImageRebin
    176     Following should be an error.
     180    Following should be an error for stats options 0.
    177181<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
    178182    Specified statistic option, 0, is not valid.  Must specify one and only one statistic type.
    179183<DATE><TIME>|<HOST>|I|testImageRebin
    180     Following should be an error.
     184    Following should be an error for stat options use range.
    181185<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
    182186    Specified statistic option, 8192, is not valid.  Must specify one and only one statistic type.
    183187<DATE><TIME>|<HOST>|I|testImageRebin
    184     Following should be an error.
     188    Following should be an error for stats with multiple options.
    185189<DATE><TIME>|<HOST>|E|psLib.image.psImageRebin
    186190    Specified statistic option, 2049, is not valid.  Must specify one and only one statistic type.
Note: See TracChangeset for help on using the changeset viewer.