IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 1, 2007, 6:14:33 PM (19 years ago)
Author:
gusciora
Message:

Added tabular file of all psLib functions in Chapter 6 of the SDRS (Data
Manipulation). Most of the test file changes in this check-in are fairly
cosmetic.

Location:
trunk/psLib/test/imageops
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/imageops/Makefile.am

    r13042 r13123  
    2121        tap_psImageConvolve2 \
    2222        tap_psImagePixelExtract \
    23         tap_psImageInterpolate2
     23        tap_psImageInterpolate2 \
     24        tap_psImageMaskOps
    2425
    2526#       tap_psImageShiftKernel
  • trunk/psLib/test/imageops/tap_psImageGeomManip.c

    r13084 r13123  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-05-01 00:08:52 $
     7 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-05-02 04:14:33 $
    99 *
    1010 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    154154    plan_tests(237);
    155155
    156     // testImageRebin()
    157     // This function shall generate a rescaled version of a psImage structure
    158     // derived from a specified statistics method.
     156    // test psImageRebin()
     157    // This function shall generate a rescaled version of a psImage
     158    // structure derived from a specified statistics method.
    159159    if (1) {
    160160        psMemId id = psMemGetId();
     
    295295        testRebinType(U16);
    296296        testRebinType(S8);
    297         // Verify the returned psImage structure is null and program execution
     297        // Verify the returned psImage structure is NULL and program execution
    298298        // doesn't stop, if the input image type is not supported.
    299299        // Following should be an error for unsupported type
     
    305305        ok(out == NULL, "psImageRebin returned NULL for unsupported type");
    306306
    307         // Verify the returned psImage structure is null and program execution
     307        // Verify the returned psImage structure is NULL and program execution
    308308        // doesn't stop, if the mask type is not U8
    309309        // Following should be an error for invallid mask type
     
    314314        psFree(in);
    315315
    316         // Verify the returned psImage structure is null and program execution
    317         // doesn't stop, if the input parameter input is null.
     316        // Verify the returned psImage structure is NULL and program execution
     317        // doesn't stop, if the input parameter input is NULL.
    318318        out2 = psImageRebin(NULL,NULL,NULL,0,1,&stats);
    319319        ok(out2 == NULL, "psImageRebin returned NULL with NULL input");
    320320
    321         // Verify the returned psImage structure is null and program execution
     321        // Verify the returned psImage structure is NULL and program execution
    322322        // doesn't stop, if the input parameter scale is less than or equal to zero.
    323323        in = psImageAlloc(16, 16, PS_TYPE_F32);
     
    327327        ok(out2 == NULL, "psImageRebin returned NULL when the scale was zero");
    328328
    329         // Verify the returned psImage structure is null and program execution
    330         // doesn't stop, if the input parameter stats is null.
    331         // Following should be an error for stats null
     329        // Verify the returned psImage structure is NULL and program execution
     330        // doesn't stop, if the input parameter stats is NULL.
     331        // Following should be an error for stats NULL
    332332        // XXX: Verify error
    333333        out2 = psImageRebin(NULL,in,NULL,0,1,NULL);
    334334        ok(out2 == NULL, "psImageRebin returned an NULL when the stats was NULL");
    335335
    336         // Verify the returned psImage structure is null and program execution
     336        // Verify the returned psImage structure is NULL and program execution
    337337        // doesn't stop, if the input parameter psStats structure member options
    338338        // is zero or any value which doesn't correspond to a valid statistical
     
    350350        ok(out2 == NULL, "psImageRebin returned an image though the stats options was PS_STAT_USE_RANGE");
    351351
    352         // Verify the returned psImage structure is null and program execution
     352        // Verify the returned psImage structure is NULL and program execution
    353353        // doesn't stop, if the input parameter psStats structure member options
    354354        // specifies more than one valid statistical method.
     
    363363    }
    364364
    365     // testImageRoll()
     365    // test psImageRoll()
    366366    if (1) {
    367367        psMemId id = psMemGetId();
     
    387387
    388388        in = psImageAlloc(cols,rows,PS_TYPE_F32);
    389         for (psS32 row=0;row<rows;row++)
    390         {
    391             psF32 *inRow = in->data.F32[row];
    392             for (psS32 col=0;col<cols;col++) {
    393                 inRow[col] = (psF32)row+(psF32)col/1000.0f;
     389        for (psS32 row=0;row<rows;row++) {
     390            for (psS32 col=0;col<cols;col++) {
     391                in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f;
    394392            }
    395393        }
     
    397395        out = psImageRoll(NULL,in,0,0);
    398396        bool errorFlag = false;
    399         for (psS32 row=0;row<rows;row++)
    400         {
     397        for (psS32 row=0;row<rows;row++) {
    401398            psF32 *inRow = in->data.F32[row];
    402399            psF32 *outRow = out->data.F32[row];
     
    519516
    520517
    521         // Verify the returned psImage structure pointer is null and program
    522         // execution doesn't stop, if input parameter input is null.
     518        // Verify the returned psImage structure pointer is NULL and program
     519        // execution doesn't stop, if input parameter input is NULL.
    523520        out2 = psImageRoll(NULL,NULL,0,0);
    524         if (out2 != NULL)
    525         {
     521        if (out2 != NULL) {
    526522            psError(PS_ERR_UNKNOWN, true,"psImageRoll did not return NULL though input image was NULL!?");
    527523            return 2;
     
    567563    }
    568564
    569 
    570     // testImageRotate()
     565    // test psImageRotate()
    571566    if (1) {
    572567        psMemId id = psMemGetId();
     
    599594        psImage *sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
    600595
    601         for(psS32 row=0;row<rows;row++)
    602         {
     596        for(psS32 row=0;row<rows;row++) {
    603597            psF32 *fRow = fImg->data.F32[row];
    604598            psS16 *sRow = sImg->data.S16[row];
     
    612606        // is to verify the results manually and bless it for automated comparison
    613607        // thereafter
    614 
    615608
    616609        // write results of various rotates to a file and verify with truth images
     
    796789        }
    797790//HERE
    798         // Verify the returned psImage structure pointer is null and program
    799         // execution doesn't stop, if the input parameter input is null.
     791        // Verify the returned psImage structure pointer is NULL and program
     792        // execution doesn't stop, if the input parameter input is NULL.
    800793        // Following should be an error
    801794        // XXX: Verify error
     
    803796        ok(fOut == NULL, "NULL was returned when the input image was NULL");
    804797
    805         // Verify the returned psImage structure pointer is null and program
     798        // Verify the returned psImage structure pointer is NULL and program
    806799        // execution doesn't stop, if the specified interpolation mode is unallowed
    807800        // Following should be an error for unallowed interpolation type
     
    882875        ok(fRecycle == fOut, "psImageShift did recycle my image");
    883876
    884         // Verify the returned psImage structure pointer is null and program
    885         // execution doesn't stop, if the input psImage structure pointer is null.
     877        // Verify the returned psImage structure pointer is NULL and program
     878        // execution doesn't stop, if the input psImage structure pointer is NULL.
    886879        // Following should be an error
    887880        // XXX: Verify error
     
    889882        ok(fOut == NULL, "psImageShift did return NULL given a NULL input image");
    890883
    891         // Verify the returned psImage structure is null and program execution
     884        // Verify the returned psImage structure is NULL and program execution
    892885        // doesn't stop, if the specified interpolation mode is unallowed.
    893886        // Following should be an error for unallowed interpolation mode
     
    901894
    902895
    903     // testImageResample()
     896    // test psImageResample()
    904897    if (1) {
    905898        psMemId id = psMemGetId();
    906 
    907899        psS32 rows = 60;
    908900        psS32 cols = 80;
     
    911903        psErr *err;
    912904
    913         psImage *image = psImageAlloc(cols,rows,PS_TYPE_F32);
    914         for(psS32 row=0;row<rows;row++)
    915         {
    916             psF32 *imageRow = image->data.F32[row];
    917             for (psS32 col=0;col<cols;col++) {
    918                 imageRow[col] = row+2*col;
     905        psImage *image = psImageAlloc(cols, rows, PS_TYPE_F32);
     906        for(psS32 row=0;row<rows;row++) {
     907            for (psS32 col=0;col<cols;col++) {
     908                image->data.F32[row][col] = row+2*col;
    919909            }
    920910        }
     
    925915        ok(result == orig, "psImageResample() recycled image");
    926916        ok(result->type.type == PS_TYPE_F32, "psImageResample() produced the correct type");
    927 
    928 
    929917        ok(result->numCols == image->numCols*scale && result->numRows == image->numRows*scale,
    930918           "psImageResample() produced the correct size");
    931 
    932919
    933920        bool errorFlag = false;
     
    939926            psMaskType maskVal;
    940927            psF32 truthValue;
    941             for(psS32 row=0;row<result->numRows;row++)
    942             {
     928            for(psS32 row=0;row<result->numRows;row++) {
    943929                for (psS32 col=0;col<result->numCols;col++) {
    944930//                    truthValue = psImagePixelInterpolate(image,
     
    961947        ok(!errorFlag, "psImageResample() produced the correct data values");
    962948
    963         // verify that image=null is handled properly.
     949        // verify that image=NULL is handled properly.
    964950        psErrorClear();
    965951        result = psImageResample(result,NULL,scale,PS_INTERPOLATE_FLAT);
     
    1002988
    1003989
    1004     // testImageTransform()
     990    // test psImageTransform()
    1005991    if (1) {
    1006992        psMemId id = psMemGetId();
     
    1013999
    10141000        psImage *in = psImageAlloc(cols,rows,PS_TYPE_F32);
    1015         for (psS32 row=0;row<rows;row++)
    1016         {
    1017             psF32 *inRow = in->data.F32[row];
    1018             for (psS32 col=0;col<cols;col++) {
    1019                 inRow[col] = (psF32)row+(psF32)col/1000.0f;
     1001        for (psS32 row=0;row<rows;row++) {
     1002            for (psS32 col=0;col<cols;col++) {
     1003                in->data.F32[row][col] = (psF32)row+(psF32)col/1000.0f;
    10201004            }
    10211005        }
    10221006        P_PSIMAGE_SET_COL0(in, 1);
    1023         psImage *out = psImageTransform(NULL,
    1024                                         NULL,
    1025                                         in,
    1026                                         NULL,
    1027                                         0,
    1028                                         trans,
    1029                                         psRegionSet(1,1+cols*2,0,rows*2),
    1030                                         NULL,
    1031                                         PS_INTERPOLATE_FLAT,
    1032                                         -1);
     1007        psImage *out = psImageTransform(NULL, NULL, in, NULL, 0, trans,
     1008                                        psRegionSet(1,1+cols*2,0,rows*2), NULL,
     1009                                        PS_INTERPOLATE_FLAT, -1);
    10331010
    10341011        ok(out != NULL, "psImageTransform() returned non-NULL");
     
    10361013        ok(out->numRows == rows*2 && out->numCols == cols*2, "psImageTransform() produced the correct size");
    10371014
    1038         if (0) {
     1015        if (1) {
    10391016            psMemId id = psMemGetId();
    10401017            psImageInterpolateOptions *tmpIntOpts = psImageInterpolateOptionsAlloc(
     
    10451022            psMaskType maskVal;
    10461023            bool errorFlag = false;
    1047             for (psS32 row=0;row<out->numRows;row++)
    1048             {
    1049                 psF32 *outRow = out->data.F32[row];
     1024            for (psS32 row=0;row<out->numRows;row++) {
    10501025                for (psS32 col=0;col<cols;col++) {
    10511026                    psImageInterpolate(&imgVal, &varVal, &maskVal,
     
    10541029                                       tmpIntOpts);
    10551030                    float inValue = imgVal;
    1056                     if (fabsf(outRow[col] - inValue) > 0.01) {
    1057                         diag("out at %d,%d was %g, expected %g", col,row,outRow[col], inValue);
     1031                    if (fabsf(out->data.F32[row][col] - inValue) > 0.01) {
     1032                        diag("out at %d,%d was %g, expected %g", col,row,
     1033                              out->data.F32[row][col], inValue);
    10581034                        errorFlag = true;
    10591035                    }
  • trunk/psLib/test/imageops/tap_psImageMaskOps.c

    r11729 r13123  
    33 *  @brief Contains the tests for psMaskOps.[ch]
    44 *
    5  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2007-02-09 20:40:22 $
     5 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2007-05-02 04:14:33 $
    77 *
    88 *  XXX: In general, the image tests with (1, N) and (N, 1) failed and have
     
    721721        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    722722    }
     723    // XXX: These seg fault
    723724    if (0) genericImageMaskCircleTest(N, 1, N/2, 1, N/4);
    724725    if (0) genericImageMaskCircleTest(1, N, 1, N/2, N/4);
     
    734735        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    735736    }
     737    // XXX: These seg fault
    736738    if (0) genericImageKeepCircleTest(N, 1, N/2, 1, N/4);
    737739    if (0) genericImageKeepCircleTest(1, N, 1, N/2, N/4);
  • trunk/psLib/test/imageops/tap_psImagePixelExtract.c

    r13042 r13123  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2007-04-26 22:18:03 $
     8*  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2007-05-02 04:14:33 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1717#include "pstap.h"
    1818
    19 psS32 main( psS32 argc, char* argv[] )
     19psS32 main(psS32 argc, char* argv[])
    2020{
    2121    psLogSetFormat("HLNM");
     
    2323    plan_tests(248);
    2424
    25     // testImageSlice()
     25    // test psImageSlice()
    2626    {
    2727        psMemId id = psMemGetId();
     
    3131        const psS32 n = r / 4 -1;
    3232        psImage* image;
    33         psPixels* positions = psPixelsAlloc( r );
    34         psImage* mask = psImageAlloc( c, r, PS_TYPE_MASK );
    35         psStats* stat = psStatsAlloc( PS_STAT_SAMPLE_MEDIAN );
     33        psPixels* positions = psPixelsAlloc(r);
     34        psImage* mask = psImageAlloc(c, r, PS_TYPE_MASK);
     35        psStats* stat = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
    3636   
    3737
     
    4646        // cases should be used for each possible direction. Data region cases
    4747        // should include 0x0, 1x1, Nx1, 1xN, NxN, MxN
    48         for ( psS32 row = 0;row < r;row++ ) {
     48        for (psS32 row = 0;row < r;row++) {
    4949            psMaskType* maskRow = mask->data.PS_TYPE_MASK_DATA[row];
    50             for ( psS32 col = 0;col < c;col++ ) {
    51                 maskRow[ col ] = 0;
     50            for (psS32 col = 0;col < c;col++) {
     51                maskRow[col] = 0;
    5252            }
    5353        }
     
    5858            psVector* out = NULL; \
    5959            bool errorFlag = false; \
    60             image = psImageAlloc( c, r, PS_TYPE_##TYPE ); \
    61             for ( psS32 row = 0;row < r;row++ ) { \
    62                 ps##TYPE *imageRow = image->data.TYPE[ row ]; \
     60            image = psImageAlloc(c, r, PS_TYPE_##TYPE); \
     61            for (psS32 row = 0;row < r;row++) { \
     62                ps##TYPE *imageRow = image->data.TYPE[row]; \
    6363                ps##TYPE rowOffset = row * 2; \
    64                 for ( psS32 col = 0;col < c;col++ ) { \
    65                     imageRow[ col ] = col + rowOffset; \
     64                for (psS32 col = 0;col < c;col++) { \
     65                    imageRow[col] = col + rowOffset; \
    6666                } \
    6767            } \
     
    111111        //
    112112        #define PSIMAGESLICE_TEST(TYPE) \
    113         PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0 ); \
    114         PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1 ); \
    115         PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2 ); \
    116         PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3 ); \
     113        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_POS, m, i, n / 2, 0); \
     114        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_X_NEG, m, m - 1 - i, n / 2, 1); \
     115        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_POS, n, m / 2, i, 2); \
     116        PSIMAGESLICE_TEST1(TYPE, m, n, PS_CUT_Y_NEG, n, m / 2, n - 1 - i, 3); \
    117117        \
    118         PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4 ); \
    119         PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5 ); \
    120         PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6 ); \
    121         PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7 ); \
     118        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_POS, m, i, 0, 4); \
     119        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_X_NEG, m, m - 1 - i, 0, 5); \
     120        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_POS, 1, m / 2, 0, 6); \
     121        PSIMAGESLICE_TEST1(TYPE, m, 1, PS_CUT_Y_NEG, 1, m / 2, 0, 7); \
    122122        \
    123         PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8 ); \
    124         PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9 ); \
    125         PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10 ); \
    126         PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11 ); \
     123        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_POS, 1, 0, n / 2, 8); \
     124        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_X_NEG, 1, 0, n / 2, 9); \
     125        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_POS, n, 0, i, 10); \
     126        PSIMAGESLICE_TEST1(TYPE, 1, n, PS_CUT_Y_NEG, n, 0, n - 1 - i, 11); \
    127127        \
    128         PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12 ); \
    129         PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13 ); \
    130         PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14 ); \
    131         PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15 ); \
     128        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_POS, 1, 0, 0, 12); \
     129        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_X_NEG, 1, 0, 0, 13); \
     130        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_POS, 1, 0, 0, 14); \
     131        PSIMAGESLICE_TEST1(TYPE, 1, 1, PS_CUT_Y_NEG, 1, 0, 0, 15); \
    132132   
    133133        PSIMAGESLICE_TEST(F32);
     
    149149                           psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1),
    150150                           PS_CUT_X_POS,
    151                            stat );
     151                           stat);
    152152        ok(out == NULL, "psImageSlice() returned NULL with NULL input");
    153153   
     
    156156        // Following should be an error
    157157        // XXX: Verify error
    158         out = psImageSlice( out,
     158        out = psImageSlice(out,
    159159                            NULL, image,
    160160                            mask, 1,
    161161                            psRegionSet(c/10, c/10 + 1, r/10, r/10 + 1),
    162162                            PS_CUT_X_POS,
    163                             NULL );
     163                            NULL);
    164164        ok(out == NULL, "psImageSlice() returned NULL with NULL psStats");
    165             psError( PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected" );
     165            psError(PS_ERR_UNKNOWN,true, "Giving a NULL stat struct, psImageSlice didn't return NULL as expected");
    166166
    167167        // Verify the returned psVector structure pointer is null and program
     
    182182        // Following should be an error
    183183        // XXX: Verify error
    184         out = psImageSlice( out,
     184        out = psImageSlice(out,
    185185                            NULL,
    186186                            image,
     
    188188                            psRegionSet(c/10, c/10, r/10, r/10),
    189189                            PS_CUT_X_POS,
    190                             stat );
     190                            stat);
    191191        ok(out == NULL, "psImageSlice() returned NULL with 0x0 region");
    192192   
     
    196196        // Following should be an error
    197197        // XXX: Verify error
    198         out = psImageSlice( out, NULL,
     198        out = psImageSlice(out, NULL,
    199199                            image,
    200200                            mask, 1,
    201201                            psRegionSet(c+1, c+2, r/10, r/10 + 10),
    202202                            PS_CUT_X_POS,
    203                             stat );
     203                            stat);
    204204        ok(out == NULL, "psImageSlice() returned NULL with unallowed x position");
    205205   
    206206        // Following should be an error
    207207        // XXX: Verify error
    208         out = psImageSlice( out, NULL,
     208        out = psImageSlice(out, NULL,
    209209                            image,
    210210                            mask, 1,
    211211                            psRegionSet(c/10, c/10 + 1, r+1,r+5),
    212212                            PS_CUT_X_POS,
    213                             stat );
     213                            stat);
    214214        ok(out == NULL, "psImageSlice() returned NULL with unallowed y position");
    215215   
    216216        // Following should be an error
    217217        // XXX: Verify error
    218         out = psImageSlice( out, NULL,
     218        out = psImageSlice(out, NULL,
    219219                            image,
    220220                            mask, 1,
     
    226226        // Following should be an error
    227227        // XXX: Verify error
    228         out = psImageSlice( out, NULL,
     228        out = psImageSlice(out, NULL,
    229229                            image,
    230230                            mask, 1,
     
    240240        // XXX: Verify error
    241241        stat->options = 0;
    242         out = psImageSlice( out, NULL,
     242        out = psImageSlice(out, NULL,
    243243                            image,
    244244                            mask, 1,
     
    253253        // XXX: Verify error
    254254        stat->options = PS_STAT_SAMPLE_MEDIAN;
    255         psImage* maskSz = psImageAlloc( r, c, PS_TYPE_MASK );
    256         out = psImageSlice( out, NULL,
     255        psImage* maskSz = psImageAlloc(r, c, PS_TYPE_MASK);
     256        out = psImageSlice(out, NULL,
    257257                            image,
    258258                            maskSz, 1,
     
    265265        // Following should be an error unallowed mask type
    266266        // XXX: Verify error
    267         psImage* maskS8 = psImageAlloc( c, r, PS_TYPE_S8 );
    268         out =  psImageSlice( out, NULL,
     267        psImage* maskS8 = psImageAlloc(c, r, PS_TYPE_S8);
     268        out =  psImageSlice(out, NULL,
    269269                             image,
    270270                             maskS8, 1,
     
    276276        //Added tests after subimage changes.
    277277        psFree(image);
    278         image = psImageAlloc( c, r, PS_TYPE_F64 );
    279         for ( psS32 row = 0;row < r;row++ ) {
    280             psF64 *imageRow = image->data.F64[ row ];
     278        image = psImageAlloc(c, r, PS_TYPE_F64);
     279        for (psS32 row = 0;row < r;row++) {
     280            psF64 *imageRow = image->data.F64[row];
    281281            psF64 rowOffset = row * 2;
    282             for ( psS32 col = 0;col < c;col++ ) {
    283                 imageRow[ col ] = col + rowOffset;
     282            for (psS32 col = 0;col < c;col++) {
     283                imageRow[col] = col + rowOffset;
    284284            }
    285285        }
     
    441441                    float y = (float)startRow[n]+(float)i*deltaRow;
    442442                    if (n == 1) {
    443 //                        truth = psImagePixelInterpolate( image, x, y,
     443//                        truth = psImagePixelInterpolate(image, x, y,
    444444//                                                         NULL,0,0,PS_INTERPOLATE_FLAT);
    445445                          psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsNoMask);
    446446                          truth = imgVal;
    447447                    } else {
    448 //                        truth = psImagePixelInterpolate( image, x, y,
     448//                        truth = psImagePixelInterpolate(image, x, y,
    449449//                                                         mask,1,0,PS_INTERPOLATE_FLAT);
    450450                          psImageInterpolate(&imgVal, &varVal, &maskVal, x, y, tmpIntOptsMask);
     
    520520
    521521
    522     // testImageRadialCut()
     522    // test psImageRadialCut()
    523523    {
    524524        psMemId id = psMemGetId();
     
    557557                if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) {
    558558                    diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)",
    559                           result->data.F64[i], (15.0+i*10) );
     559                          result->data.F64[i], (15.0+i*10));
    560560                    errorFlag = true;
    561561                }
     
    574574                if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) {
    575575                    diag("Result was not as expected for radii #%d (%g, expected %d +/- 1)",
    576                           result->data.F64[i], (15.0+i*10) );
     576                          result->data.F64[i], (15.0+i*10));
    577577                    errorFlag = true;
    578578                }
     
    709709        // Following should generate error message(for row)
    710710        // XXX: Verify error
    711         out = psImageRow(NULL, image, num);
     711        out = psImageRow(NULL, NULL, num);
    712712        ok(out == NULL, "psImageRow() returned NULL with NULL input image");
    713713
    714714        // Following should generate error message(for col)
    715715        // XXX: Verify error
    716         out = psImageCol(NULL, image, num);
     716        out = psImageCol(NULL, NULL, num);
    717717        ok(out == NULL, "psImagecol() returned NULL with NULL input image");
    718    
    719718        image = psImageAlloc(3, 3, PS_TYPE_F64);
    720719
    721720
    722721        //Test for unallowed row0.
    723         *(psS32*)&(image->row0) = -1;
     722        P_PSIMAGE_SET_ROW0(image, -2);
    724723        // Following should generate error message(for row)
    725724        // XXX: Verify error
     
    810809   
    811810        //Test valid cases.
     811        //XXX: We do not verify the data values.
    812812        P_PSIMAGE_SET_COL0(image, 10);
    813813        P_PSIMAGE_SET_ROW0(image, 5);
     
    875875   
    876876        //Test for error with NULL image
    877         empty = psImageCol(empty, emptyImage, 0);
     877        empty = psImageCol(empty, NULL, 0);
    878878        ok(empty == NULL, "psImageCol returned NULL for NULL image input");
    879879        //Test for error with Out of Range Row
     
    894894        test1 = fabs(rowcol->data.F64[0]-66.6);
    895895        test2 = fabs(rowcol->data.F64[2]-666.66);
    896         ok(!( (test1>TOLTST) || (test2>TOLTST)),
     896        ok(!((test1>TOLTST) || (test2>TOLTST)),
    897897           "psImageRow returned correct values");
    898898        psFree(rowcol);
  • trunk/psLib/test/imageops/tap_psImagePixelManip.c

    r12440 r13123  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-03-14 21:20:28 $
     8 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-05-02 04:14:33 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2222    psLogSetFormat("HLNM");
    2323    psLogSetLevel(PS_LOG_INFO);
    24     plan_tests(47);
    25 
    26     // testImageClip()
     24    plan_tests(107);
     25
     26    // test psImageClip()
    2727    {
    2828        psMemId id = psMemGetId();
     
    4444        // Verify the retuned integer is zero, psImage structure input is unmodified
    4545        // and program executions doesn't stop, if input parameter psImage structure
    46         // pointer is null.
     46        // pointer is NULL.
    4747        //
    4848        // Verify the retuned integer is zero, psImage structure input is unmodified
     
    111111        // Verify the retuned integer is zero, psImage structure input is unmodified
    112112        // and program executions doesn't stop, if input parameter psImage structure
    113         // pointer is null.
     113        // pointer is NULL.
    114114        retVal = psImageClip(NULL,min,-1.0f,max,-2.0f);
    115115        ok(retVal == 0, "Expected zero return for clips of a NULL image");
     
    144144        //
    145145        // Verify the returned integer is zero and program execution doesn't stop,
    146         // if the input parameter psImage structure pointer is null.
     146        // if the input parameter psImage structure pointer is NULL.
    147147        // create image
    148148        #define testImageClipNaNByType(datatype) \
     
    193193        // Verify the retuned integer is zero, psImage structure input is unmodified
    194194        // and program executions doesn't stop, if input parameter psImage structure
    195         // pointer is null.
     195        // pointer is NULL.
    196196        retVal = psImageClipNaN(NULL,-1.0f);
    197197        ok(retVal == 0, "Expected zero return for clips of a NULL image");
     
    286286        testOverlayTypeOP(DATATYPE,=,"=");
    287287
    288 
    289         //        testOverlayType(F64);
    290         //        testOverlayType(F32);
    291         //        testOverlayType(S16);
    292         //        testOverlayType(S8);
    293         //        testOverlayType(U16);
    294         //        testOverlayType(U8);
     288        testOverlayType(F64);
     289        testOverlayType(F32);
     290        testOverlayType(S16);
     291        testOverlayType(S8);
     292        testOverlayType(U16);
     293        testOverlayType(U8);
    295294
    296295        // Verify the returned integer is equal to non-zero and the input psImage structure
     
    351350        // Verify the returned integer is equal to non-zero, the input psImage
    352351        // structure is unmodified and program execution doesn't stop, if the
    353         // overlay specified is null.
     352        // overlay specified is NULL.
    354353        // Following should error as overlay is NULL
    355354        // XXX: Verify error
     
    371370
    372371        // Verify the returned integer is equal to non-zero and program execution
    373         // doesn't stop, if the input parameter image is null.
     372        // doesn't stop, if the input parameter image is NULL.
    374373        // Following should error as image input is NULL
    375374        // XXX: Verify error
     
    416415        ok(retVal != 0, "psImageOverlaySection returned non-zero when checking divide-by-zero");
    417416        errorFlag = false;
    418 
    419 
    420 
    421 
    422 
    423 
    424 
    425 
    426 
    427 
    428 
    429 
    430 
    431 
    432 
    433 
    434 
    435 
    436 
    437 
    438 
    439 
    440 
    441 
    442 
    443 
    444 
    445 
    446 
    447 
    448417
    449418        for (unsigned row=0;row<r;row++)
  • trunk/psLib/test/imageops/tap_psImageStats.c

    r11729 r13123  
    273273    const int CHEBY_Y_DIM = 8;
    274274    const int THRESHOLD = 1;
    275     psImage *imgIn = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32 );
    276     psImage *imgOut = psImageAlloc( IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32 );
    277     for (int i = 0;i < IMAGE_SIZE;i++ ) {
    278         for (int j = 0;j < IMAGE_SIZE;j++ ) {
     275    psImage *imgIn = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
     276    psImage *imgOut = psImageAlloc(IMAGE_SIZE, IMAGE_SIZE, PS_TYPE_F32);
     277    for (int i = 0;i < IMAGE_SIZE;i++) {
     278        for (int j = 0;j < IMAGE_SIZE;j++) {
    279279            imgIn->data.F32[ i ][ j ] = 4.0;
    280             imgIn->data.F32[ i ][ j ] = ( float ) ( i + j );
    281             imgIn->data.F32[ i ][ j ] = ( float ) ( i + j ) + ( 4.0 * ( float ) i );
     280            imgIn->data.F32[ i ][ j ] = (float) (i + j);
     281            imgIn->data.F32[ i ][ j ] = (float) (i + j) + (4.0 * (float) i);
    282282            imgOut->data.F32[ i ][ j ] = 0.0;
    283283        }
    284284    }
    285285    psPolynomial2D *my2DPoly = psPolynomial2DAlloc(PS_POLYNOMIAL_CHEB, CHEBY_X_DIM-1, CHEBY_Y_DIM-1);
    286     my2DPoly = psImageFitPolynomial(my2DPoly, imgIn );
     286    my2DPoly = psImageFitPolynomial(my2DPoly, imgIn);
    287287    ok(my2DPoly != NULL, "psImageFitPolynomial() returned non-NULL");
    288288
    289     imgOut = psImageEvalPolynomial( imgOut, my2DPoly );
     289    imgOut = psImageEvalPolynomial(imgOut, my2DPoly);
    290290    bool errorFlag = false;
    291     for (int i = 0;i < IMAGE_SIZE;i++ ) {
    292         for (int j = 0;j < IMAGE_SIZE;j++ ) {
    293             if ( fabs( imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ] ) > THRESHOLD ) {
     291    for (int i = 0;i < IMAGE_SIZE;i++) {
     292        for (int j = 0;j < IMAGE_SIZE;j++) {
     293            if (fabs(imgOut->data.F32[ i ][ j ] - imgIn->data.F32[ i ][ j ]) > THRESHOLD) {
    294294                diag("Pixel (%d, %d) is %.2f, should be %.2f\n", i, j,
    295295                     imgOut->data.F32[ i ][ j ],
     
    357357        ok(hist2 == hist, "psImageHistogram() correctly recycled the input psHistogram");
    358358        bool errorFlag = false;
    359         for (int i = 0;i < numBins;i++ ) {
     359        for (int i = 0;i < numBins;i++) {
    360360            if (hist2->nums->data.F32[i] != (numCols * (numRows/numBins))) {
    361361                diag("ERROR: Bin number %d bounds: (%.1f - %.1f) data (%.2f)\n", i,
     
    434434    }
    435435
    436     // Ensure psImageCountPixelMask returns -1 for NULL input image
     436    // Ensure psImageCountPixelMask returns -1 for wrong input image type
    437437    // Following should generate error
    438438    // XXX: Verify error
     
    486486    // --------------------------------------------------------------
    487487    // psImageStats()
    488     // Ensure psImageStats() returnes NULL for NULL input image
     488    // Ensure psImageStats() returns NULL for NULL input image
    489489    // Following should generate error
    490490    // XXX: Verify error
     
    499499    }
    500500
    501     // Ensure psImageStats() returnes NULL for NULL psStats
     501    // Ensure psImageStats() returns NULL for NULL psStats
    502502    // Following should generate error
    503503    // XXX: Verify error
  • trunk/psLib/test/imageops/tap_psImageStructManip.c

    r11688 r13123  
    1 /** @file  tst_psImageExtraction.c
     1/** @file  tap_psImageStructManip.c
    22*
    33*  @brief Contains the tests for psImageExtraction.[ch]
    44*
    5 *
    65*  @author Robert DeSonia, MHPCC
    76*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2007-02-08 01:21:50 $
     7*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2007-05-02 04:14:33 $
    109*
    1110*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2625    // psImageSubset shall create child image of a specified size from a
    2726    // parent psImage structure
    28 
    2927    // psImageSubset()
    3028    {
     
    3331        psS32 c = 128;
    3432        psS32 r = 256;
    35         psRegion region1 = psRegionSet(0,c/2,0,r/2);
    36         psRegion region2 = psRegionSet(c/4,c/4+c/2,r/4,r/4+r/2);
     33        psRegion region1 = psRegionSet(0, c/2, 0, r/2);
     34        psRegion region2 = psRegionSet(c/4, c/4+c/2, r/4, r/4+r/2);
    3735
    3836        psImage* original = psImageAlloc(c,r,PS_TYPE_U32);
    39         for (psS32 row=0;row<r;row++)
    40         {
     37        for (psS32 row=0;row<r;row++) {
    4138            for (psS32 col=0;col<c;col++) {
    4239                original->data.F32[row][col] = row*1000+col;
     
    6360
    6461        bool errorFlag = false;
    65         for (psS32 row=0;row<r/2;row++)
    66         {
     62        for (psS32 row=0;row<r/2;row++) {
    6763            for (psS32 col=0;col<c/2;col++) {
    6864                if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) {
     
    9995        ok(subset2->children == NULL && subset3->children == NULL, "psImageSubset() set ->children correctly");
    10096
    101 
    10297        // Verify the input psImage structure image only has the following members
    10398        // changed: 1) Nchildren is increased by one. 2) parent contains pointer psImage structure
     
    107102           "psImageSubset did properly store the children pointers.");
    108103
     104
    109105        // Verify the returned psImage structure pointer is null and program
    110106        // execution doesn't stop, if the input parameter image is null.
     
    114110        psImage* subset1 = psImageSubset(NULL,region1);
    115111        ok(subset1 == NULL, "psImageSubset returned NULL when input image was NULL.");
     112
    116113
    117114        // Verify the returned psImage structure pointer is null and program
     
    153150        ok(subset1 == NULL,
    154151           "psImageSubset returned NULL when subset origin was outside of image (row0=-1)");
     152
    155153
    156154        // Verify the returned psImage structure pointer is null and program
     
    205203        psU32 r = 256;
    206204
    207         psImage* img = psImageAlloc(c,r,PS_TYPE_F32);
    208         for (unsigned row=0;row<r;row++)
    209         {
    210             psF32* imgRow = img->data.F32[row];
     205        psImage *img = psImageAlloc(c,r,PS_TYPE_F32);
     206        for (unsigned row=0;row<r;row++) {
    211207            for (unsigned col=0;col<c;col++) {
    212                 imgRow[col] = (psF32)(row+col);
    213             }
    214         }
    215         psImage* img2 = psImageAlloc(c,r,PS_TYPE_F32);
    216         for (unsigned row=0;row<r;row++)
    217         {
    218             psF32* img2Row = img2->data.F32[row];
     208                img->data.F32[row][col] = (psF32)(row+col);
     209            }
     210        }
     211        psImage *img2 = psImageAlloc(c,r,PS_TYPE_F32);
     212        for (unsigned row=0;row<r;row++) {
    219213            for (unsigned col=0;col<c;col++) {
    220                 img2Row[col] = 0.0f;
    221             }
    222         }
    223 
    224         psImage* img3 = psImageCopy(img2,img,PS_TYPE_F32);
    225         // Verify the returned psImage structure pointer is equal to the input parameter output.
     214                img2->data.F32[row][col] = 0.0f;
     215            }
     216        }
     217
     218        psImage *img3 = psImageCopy(img2,img,PS_TYPE_F32);
     219        // Verify the returned psImage structure pointer is equal to the input
     220        // parameter output.
    226221        ok(img2 == img3, "psImageCopy(): recycled input image");
    227222
    228         // Verify the returned psImage structure is the same type as the input image structure
    229         // if the specified output argument is NULL.
    230         psImage* img4 = psImageCopy(NULL,img,PS_TYPE_F32);
     223        // Verify the returned psImage structure is the same type as the input image
     224        // structure if the specified output argument is NULL.
     225        psImage *img4 = psImageCopy(NULL,img,PS_TYPE_F32);
    231226        ok(img4 != NULL, "psImageCopy() returned non-NULL with NULL output argument");
    232227        ok(img4->type.type == img->type.type, "psImageCopy() set the correct image type");
    233228        bool errorFlag = false;
    234         for (psU32 row=0;row<r;row++)
    235         {
     229        for (psU32 row=0;row<r;row++) {
    236230            psF32* imgInRow = img->data.F32[row];
    237231            psF32* imgOutRow = img4->data.F32[row];
     
    326320        psS32 halfR = r/2;
    327321        psS32 halfC = c/2;
    328         psRegion centerHalf = {qtrC,qtrC+halfC,qtrR,qtrR+halfR};
     322        psRegion centerHalf = {qtrC, qtrC+halfC, qtrR, qtrR+halfR};
    329323
    330324        psImage* image = psImageAlloc(c,r,PS_TYPE_F32);
    331         for (psS32 row = 0; row < image->numRows; row++)
    332         {
     325        for (psS32 row = 0; row < image->numRows; row++) {
    333326            for (psS32 col = 0; col < image->numCols; col++) {
    334327                image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f;
    335328            }
    336329        }
    337 
    338330        // invoke psImageTrim with non-NULL image, and a valid region
    339331        // x0,y0->x1,y1 (using only positive values). Verify that:
     
    350342
    351343        bool errorFlag = false;
    352         for (psS32 row = 0; row < image2->numRows; row++)
    353         {
     344        for (psS32 row = 0; row < image2->numRows; row++) {
    354345            for (psS32 col = 0; col < image2->numCols; col++) {
    355346                if (fabsf(image2->data.F32[row][col] - image->data.F32[row+qtrR][col+qtrC])
     
    379370           image->numCols-qtrC, image->numRows-qtrR);
    380371
    381         for (psS32 row = 0; row < image2->numRows; row++)
    382         {
     372        for (psS32 row = 0; row < image2->numRows; row++) {
    383373            for (psS32 col = 0; col < image2->numCols; col++) {
    384374                if (fabsf(image2->data.F32[row][col] -
     
    394384        ok(!errorFlag, "psImageTrim() set image data correctly");
    395385
    396         //  4. invoke psImageTrim with x1<0, y1<0. Verify:
     386
     387        //  Invoke psImageTrim with x1<0, y1<0. Verify:
    397388        //      a. the psImage size is (numCols+x1)-x0 by (numRows+y1)-y0.
    398389        //      b. the pixel values coorespond to the region
     
    405396           image2->numCols, image2->numRows,
    406397           image->numCols-qtrC, image->numRows-qtrR);
    407 
    408         for (psS32 row = 0; row < image2->numRows; row++)
    409         {
     398        for (psS32 row = 0; row < image2->numRows; row++) {
    410399            for (psS32 col = 0; col < image2->numCols; col++) {
    411400                if (fabsf(image2->data.F32[row][col] -
     
    422411        psFree(image1);
    423412
    424         //  6. invoke psImageTrim with image=NULL Verify:
     413
     414        //  Invoke psImageTrim with image=NULL Verify:
    425415        //      a. execution does not cease.
    426416        //      b. return value is NULL
     
    428418        // An error should follow...
    429419        // XXX: Verify errors
    430 
    431 
    432420        image2 = psImageTrim(NULL, psRegionSet(qtrC,0,qtrR,0));
    433421        ok(image2 == NULL, "psImageTrim returned NULL given a NULL input image");
     
    438426
    439427
     428        // Verify when psRegion has a coord at -1
    440429        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    441430        image2 = psImageTrim(image1, psRegionSet(-1,0,0,0));
     
    447436
    448437
     438        // Verify when psRegion has a coord at -1
    449439        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    450440        image2 = psImageTrim(image1, psRegionSet(0,0,-1,0));
     
    456446
    457447
     448        // Verify when psRegion has a coord at outside the image range
    458449        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    459450        image2 = psImageTrim(image1, psRegionSet(0,image->numCols+1,0,0));
     
    465456
    466457
     458        // Verify when psRegion has a coord at outside the image range
    467459        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    468460        image2 = psImageTrim(image1, psRegionSet(0,0,0,image->numRows+1));
     
    474466
    475467
     468        // Verify when psRegion has a coord at outside the image range
    476469        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    477470        image2 = psImageTrim(image1, psRegionSet(0,0,0,(((psF32)image->numRows)*-1.0)));
     
    483476
    484477
     478        // Verify when psRegion has a coord at outside the image range
    485479        image1 = psImageCopy(NULL,image,PS_TYPE_F32);
    486480        image2 = psImageTrim(image1, psRegionSet(0,(((psF32)image->numCols)*-1.0),0,0));
Note: See TracChangeset for help on using the changeset viewer.