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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.