IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 13, 2007, 2:39:51 PM (19 years ago)
Author:
Paul Price
Message:

Removing complex number support. No-one was using it, and it prevents compilation on Solaris.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/imageops/tap_psImagePixelManip.c

    r12405 r12431  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2007-03-12 20:46:45 $
     8 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2007-03-14 00:39:51 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    9696        }
    9797
    98         #define testImageClipByComplexType(datatype) \
    99         { \
    100             psU32 c = 128; \
    101             psU32 r = 256; \
    102             psF64 min; \
    103             psF64 max; \
    104             psS32 numClipped = 0; \
    105             psS32 retVal; \
    106             psMemId id = psMemGetId(); \
    107             psImage *img = psImageAlloc(c,r,PS_TYPE_##datatype); \
    108             for (psU32 row=0;row<r;row++) { \
    109                 ps##datatype* imgRow = img->data.datatype[row]; \
    110                 for (psU32 col=0;col<c;col++) { \
    111                     imgRow[col] = (ps##datatype)(row+I*col); \
    112                 } \
    113             } \
    114             min = (float)r/2.0f; \
    115             max = (float)r; \
    116             \
    117             retVal = psImageClip(img,min,-1.0f,max,-2.0f); \
    118             \
    119             numClipped = 0; \
    120             bool errorFlag = false; \
    121             for (psU32 row=0;row<r;row++) { \
    122                 ps##datatype* imgRow = img->data.datatype[row]; \
    123                 for (psU32 col=0;col<c;col++) { \
    124                     ps##datatype value = row+I*col; \
    125                     if (cabs(value) < min) { \
    126                         numClipped++; \
    127                         value = -1.0f; \
    128                     } else if (cabs(value) > max) { \
    129                         numClipped++; \
    130                         value = -2.0f; \
    131                     } \
    132                     if (fabsf(creal(imgRow[col])-creal(value)) > FLT_EPSILON || \
    133                             fabsf(cimag(imgRow[col])-cimag(value)) > FLT_EPSILON) { \
    134                         diag("Pixel value is not as expected (%.2f+%.2fi vs %.2f+%.2fi) at %u,%u", \
    135                              creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \
    136                         errorFlag = true; \
    137                     } \
    138                 } \
    139             } \
    140             ok(!errorFlag, "psImageClip() produced the correct data values"); \
    141             ok(retVal == numClipped, "Got the expected number of clips"); \
    142             psFree(img); \
    143             ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); \
    144         }
    145 
    14698        testImageClipByType(F64);
    14799        testImageClipByType(F32);
     
    152104        testImageClipByType(U16);
    153105        testImageClipByType(U8);
    154         testImageClipByComplexType(C32);
    155         testImageClipByComplexType(C64);
    156 
    157106
    158107        psF64 min=0.0;
     
    241190        testImageClipNaNByType(F32);
    242191        testImageClipNaNByType(F64);
    243         testImageClipNaNByType(C32);
    244         testImageClipNaNByType(C64);
    245192
    246193        // Verify the retuned integer is zero, psImage structure input is unmodified
     
    251198
    252199        // Verify program execution doesn't stop if the input image type is something
    253         // other than F32, F64, C32, C64.
     200        // other than F32, F64.
    254201        img = psImageAlloc(c,r,PS_TYPE_S32);
    255202        // Following should be an error (incorrect type)
     
    260207        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    261208    }
    262 
    263 
    264     // testImageClipComplexRegion()
    265     {
    266         psMemId id = psMemGetId();
    267         psImage* img = NULL;
    268         psU32 c = 1024;
    269         psU32 r = 2048;
    270         psS32 numClipped = 0;
    271         psS32 retVal;
    272 
    273         // psImageClipNaN shall modified pixel values of NaN with a specified value
    274 
    275         // 1. Create a complex image with a wide range of complex values
    276         //
    277         // 2. call psImageClipComplexRegion with min and max where there is at least
    278         //    2 pixels in the image above) that is:
    279         //   a) real(p) < real(min) && complex(p) < complex(min),
    280         //   b) real(p) < real(min) && complex(min) < complex(p) < complex(max)
    281         //   c) real(min) < real(p) < real(max) && complex(p) < complex(min)
    282         //   d) real(min) < real(p) < real(max) && complex(min) < complex(p) < complex(max)
    283         //   e) real(p) > real(max) && complex(min) < complex(p) < complex(max)
    284         //   f) real(pmin) < real(p) < real(max) && complex(p) > complex(max)
    285         //   g) real(p) > real(max) && complex(p) > complex(max)
    286         //   h) real(p) < real(min) && complex(p) > complex(max)
    287         //   i) real(p) > real(max) && complex(p) < complex(min)
    288         //
    289         // 3. verify that All pixels in case (a), (b), and (c) have the value vmin
    290         //
    291         // 4. verify that all pixels in case (d) are unchanged from input
    292         //
    293         // 5. verify that all pixels in case (e), (f), (g), (h), and (i) have the
    294         //    value vmax
    295         #define testImageClipComplexByType(datatype,MIN,MAX) \
    296         { \
    297             psMemId id = psMemGetId(); \
    298             img = psImageAlloc(c,r,PS_TYPE_##datatype); \
    299             for (unsigned row=0;row<r;row++) { \
    300                 ps##datatype* imgRow = img->data.datatype[row]; \
    301                 for (unsigned col=0;col<c;col++) { \
    302                     imgRow[col] = row+I*col; \
    303                 } \
    304             } \
    305             \
    306             retVal = psImageClipComplexRegion(img,MIN,-1.0-1.0*I,MAX,-2.0-2.0*I); \
    307             \
    308             numClipped = 0; \
    309             bool errorFlag = false; \
    310             for (unsigned row=0;row<r;row++) { \
    311                 ps##datatype* imgRow = img->data.datatype[row]; \
    312                 for (unsigned col=0;col<c;col++) { \
    313                     ps##datatype value = (ps##datatype)(row+I*col); \
    314                     if ( (row > creal(MAX)) || (col > cimag(MAX)) ) { \
    315                         numClipped++; \
    316                         value = -2.0-2.0*I; \
    317                     } else if ((row < creal(MIN)) || (col < cimag(MIN)) ) { \
    318                         numClipped++; \
    319                         value = -1.0-1.0*I; \
    320                     } \
    321                     if (cabs(imgRow[col]-value) > FLT_EPSILON) { \
    322                         diag("Pixel value is not as expected (%g%+gi vs %g%+gi) at %d,%d", \
    323                              creal(imgRow[col]),cimag(imgRow[col]),creal(value),cimag(value),col,row); \
    324                         errorFlag = true; \
    325                     } \
    326                 } \
    327             } \
    328             ok(!errorFlag, "psImageClip() produced the correct data values"); \
    329             ok(retVal == numClipped, "Got the expected number of clips"); \
    330             psFree(img); \
    331             ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks"); \
    332         }
    333 
    334         complex double min = ((double)r)/5.0+I*((double)c)/4.0;
    335         complex double max = ((double)r)/3.0+I*((double)c)/2.0;
    336 
    337         // Testing clipping at %g%+gi to %g%+gi for psC32, creal(min),cimag(min),creal(max),cimag(max));
    338 
    339         testImageClipComplexByType(C32,min,max);
    340 
    341         // Testing clipping at %g%+gi to %g%+gi for psC64, creal(min),cimag(min),creal(max),cimag(max));
    342         testImageClipComplexByType(C64,min,max);
    343 
    344         //  6. Call psImageClipComplexRegion with NULL input parameter; should error
    345         //     but not stop execution.
    346         // Following should be an error
    347         // XXX: Verify error
    348         retVal = psImageClipComplexRegion(NULL,0,0,0,0);
    349         ok(retVal == 0, "Expected zero return for clips of a NULL image");
    350 
    351         img = psImageAlloc(c,r,PS_TYPE_C32);
    352         for (unsigned row=0;row<r;row++)
    353         {
    354             psC32* imgRow = img->data.C32[row];
    355             for (unsigned col=0;col<c;col++) {
    356                 imgRow[col] = row+I*col;
    357             }
    358         }
    359 
    360         //  7. Call psImageClipComplexRegion with min > max; should error and return 0,
    361         //     but not stop execution
    362         // Following should be an error
    363         // XXX: Verify error
    364         retVal = psImageClipComplexRegion(img,10.0+I*1.0,-1.0,5.0+5.0*I,-2.0);
    365         ok(retVal == 0, "Expected zero return for creal(min)>creal(max)");
    366 
    367         // Following should be an error
    368         // XXX: Verify error
    369         retVal = psImageClipComplexRegion(img,1.0+I*10.0,-1.0,5.0+5.0*I,-2.0);
    370         ok(retVal == 0, "Expected zero return for cimag(min)>cimag(max)");
    371 
    372         // Following should be an error
    373         // XXX: Verify error
    374         retVal = psImageClipComplexRegion(img,10.0+I*10.0,-1.0,5.0+5.0*I,-2.0);
    375         ok(retVal == 0, "Expected zero return for min>max");
    376 
    377         //  8. Call psImageClipComplexRegion with the follow vmin/vmax values; each
    378         //     should error and return 0, but not stop execution
    379         //      a) vmin < datatype region's minimum
    380         //      b) vmax < datatype region's minimum
    381         //      c) vmin > datatype region's maximum
    382         //      d) vmax > datatype region's maximum
    383         // Following should be an error
    384         // XXX: Verify error
    385         retVal = psImageClipComplexRegion(img,
    386                                           1.0+I*1.0,
    387                                           -2.0*(double)FLT_MAX,
    388                                           5.0+5.0*I,
    389                                           0.0);
    390         ok(retVal == 0, "Expected zero return for vmin not in datatype range");
    391 
    392         // Following should be an error
    393         // XXX: Verify error
    394         retVal = psImageClipComplexRegion(img,
    395                                           1.0+I*1.0,
    396                                           2.0*(double)FLT_MAX,
    397                                           5.0+5.0*I,
    398                                           0.0);
    399         ok(retVal == 0, "Expected zero return for vmin not in datatype range");
    400 
    401         // Following should be an error
    402         // XXX: Verify error
    403         retVal = psImageClipComplexRegion(img,
    404                                           1.0+I*1.0,
    405                                           FLT_EPSILON-2.0*(double)FLT_MAX*I,
    406                                           5.0+5.0*I,
    407                                           0.0);
    408         ok(retVal == 0, "Expected zero return for vmin not in datatype range");
    409 
    410         // Following should be an error
    411         // XXX: Verify error
    412         retVal = psImageClipComplexRegion(img,
    413                                           1.0+I*1.0,
    414                                           FLT_EPSILON+2.0*(double)FLT_MAX*I,
    415                                           5.0+5.0*I,
    416                                           0.0);
    417         ok(retVal == 0, "Expected zero return for vmin not in datatype range");
    418 
    419         // Following should be an error
    420         // XXX: Verify error
    421         retVal = psImageClipComplexRegion(img,
    422                                           1.0+I*1.0,
    423                                           0.0,
    424                                           5.0+5.0*I,
    425                                           -2.0*(double)FLT_MAX);
    426         ok(retVal == 0, "Expected zero return for vmax not in datatype range");
    427 
    428         // Following should be an error
    429         // XXX: Verify error
    430         retVal = psImageClipComplexRegion(img,
    431                                           1.0+I*1.0,
    432                                           0.0,
    433                                           5.0+5.0*I,
    434                                           2.0*(double)FLT_MAX);
    435         ok(retVal == 0, "Expected zero return for vmax not in datatype range");
    436 
    437         // Following should be an error
    438         // XXX: Verify error
    439         retVal = psImageClipComplexRegion(img,
    440                                           1.0+I*1.0,
    441                                           0.0,
    442                                           5.0+5.0*I,
    443                                           FLT_EPSILON-2.0*(double)FLT_MAX*I);
    444         ok(retVal == 0, "Expected zero return for vmax not in datatype range");
    445 
    446         // Following should be an error
    447         // XXX: Verify error
    448         retVal = psImageClipComplexRegion(img,
    449                                           1.0+I*1.0,
    450                                           0.0,
    451                                           5.0+5.0*I,
    452                                           FLT_EPSILON+2.0*(double)FLT_MAX*I);
    453         ok(retVal == 0, "Expected zero return for vmax not in datatype range");
    454 
    455         // now check if vmin > vmax is OK
    456         for (unsigned row=0;row<r;row++)
    457         {
    458             psC32* imgRow = img->data.C32[row];
    459             for (unsigned col=0;col<c;col++) {
    460                 imgRow[col] = row+I*col;
    461             }
    462         }
    463         retVal = psImageClipComplexRegion(img,
    464                                           1.0+I*1.0,
    465                                           10.0,
    466                                           5.0+5.0*I,
    467                                           0.0);
    468         ok(retVal != 0, "Didn't expect zero return for vmin > vmax");
    469         psFree(img);
    470         img = NULL;
    471 
    472         //  9. Call psImageClipComplexRegion with the max value out of datatype's
    473         //     range; should clip as expected (see step 1-5). Repeat with min value
    474         //     out of datatype's range.
    475 
    476         testImageClipComplexByType(C32,-(double)FLT_MAX*2.0-I*(double)FLT_MAX*2.0,10.0+I*10.0);
    477         testImageClipComplexByType(C32,10.0+I*10.0,(double)FLT_MAX*2.0+I*(double)FLT_MAX*2.0);
    478 
    479         // Verify program execution doesn't stop if the input image type is something
    480         // other than C32, C64.
    481         img = psImageAlloc(c,r,PS_TYPE_S32);
    482         // Following should be an error (incorrect type)
    483         // XXX: Verify error
    484         retVal = psImageClipComplexRegion(img,2.0,10.0,5.0,0.0);
    485         ok(retVal == 0, "Expected zero return for clip of incorrect image type");
    486         psFree(img);
    487         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    488     }
    489 
    490209
    491210    // testImageOverlay()
     
    568287
    569288
    570         //      testOverlayType(C64);
    571         //        testOverlayType(C32);
    572289        //        testOverlayType(F64);
    573290        //        testOverlayType(F32);
Note: See TracChangeset for help on using the changeset viewer.