IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1654


Ignore:
Timestamp:
Aug 27, 2004, 3:19:26 PM (22 years ago)
Author:
desonia
Message:

added testpoint #561 - psImageShift.

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

Legend:

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

    r1605 r1654  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-08-20 02:55:42 $
     8 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-08-28 01:19:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3131static int testImageRoll(void);
    3232static int testImageRotate(void);
     33static int testImageShift(void);
     34static int testImageShiftCase(int cols, int rows, float colShift,float rowShift);
    3335
    3436testDescription tests[] = {
     
    5355                              {
    5456                                  testImageRotate,560,"psImageRotate",0,false
     57                              },
     58                              {
     59                                  testImageShift,561,"psImageShift",0,false
    5560                              },
    5661                              {
     
    12381243    return 0;
    12391244}
     1245
     1246static int testImageShift(void)
     1247{
     1248    /* psImageShift:
     1249
     1250       This functions shall generate a new psImage structure by shifting the
     1251       input psImage structure a specified number of pixels in the horizontal
     1252       and/or vertical directions.
     1253
     1254       Verify the returned psImage structure contains expected values, if the
     1255       input psImage structure contains known values and a know shift in the
     1256       vertical and/or horizontal directions. Cases should include no shift,
     1257       vertical only(up,down), horizontal only(right, left), and combination
     1258       shift. Cases should include fractional shifts. Comparison of expected
     1259       values should include a delta to allow for testing on different
     1260       platforms.
     1261
     1262       Verify the returned psImage structure contains values for pixels not in
     1263       the original image set to the input parameter exposed.
     1264
     1265    */
     1266
     1267    int retVal;
     1268
     1269    // integer shift
     1270    retVal |= testImageShiftCase(64,128,0.0f,0.0f);
     1271    retVal |= testImageShiftCase(64,128,0.0f,16.0f);
     1272    retVal |= testImageShiftCase(64,128,0.0f,-16.0f);
     1273    retVal |= testImageShiftCase(64,128,32.0f,0.0f);
     1274    retVal |= testImageShiftCase(64,128,-32.0f,0.0f);
     1275    retVal |= testImageShiftCase(64,128,32.0f,16.0f);
     1276    retVal |= testImageShiftCase(64,128,32.0f,-16.0f);
     1277    retVal |= testImageShiftCase(64,128,-32.0f,16.0f);
     1278    retVal |= testImageShiftCase(64,128,-32.0f,-16.0f);
     1279
     1280    if (retVal != 0) {
     1281        return retVal;
     1282    }
     1283
     1284    // fractional shift
     1285    retVal |= testImageShiftCase(64,128,0.0f,16.4f);
     1286    retVal |= testImageShiftCase(64,128,0.0f,-16.4f);
     1287    retVal |= testImageShiftCase(64,128,32.7f,0.0f);
     1288    retVal |= testImageShiftCase(64,128,-32.7f,0.0f);
     1289    retVal |= testImageShiftCase(64,128,32.6f,16.2f);
     1290    retVal |= testImageShiftCase(64,128,32.6f,-16.2f);
     1291    retVal |= testImageShiftCase(64,128,-32.6f,16.2f);
     1292    retVal |= testImageShiftCase(64,128,-32.6f,-16.2f);
     1293
     1294    if (retVal != 0) {
     1295        return retVal;
     1296    }
     1297
     1298    /*
     1299       Verify the returned psImage structure pointer is equal to the input
     1300       parameter out if provided.
     1301    */
     1302    psImage* fImg = psImageAlloc(32,32,PS_TYPE_F32);
     1303    psImage* fRecycle = psImageAlloc(32,32,PS_TYPE_F32);
     1304    psImage* fOut = psImageShift(fRecycle, fImg, 8,8, NAN, PS_INTERPOLATE_FLAT);
     1305
     1306    if (fRecycle != fOut) {
     1307        psError(__func__,"psImageShift didn't recycle my image?");
     1308        return 10;
     1309    }
     1310
     1311    /*
     1312       Verify the returned psImage structure pointer is null and program
     1313       execution doesn't stop, if the input psImage structure pointer is null.
     1314    */
     1315    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error...");
     1316    fOut = psImageShift(fOut,NULL,8,8,NAN,PS_INTERPOLATE_FLAT);
     1317    if (fOut != NULL) {
     1318        psError(__func__,"psImageShift didn't return NULL given a NULL input image.");
     1319        return 11;
     1320    }
     1321
     1322    psFree(fImg);
     1323
     1324    return 0;
     1325}
     1326
     1327static int testImageShiftCase(int cols,
     1328                              int rows,
     1329                              float colShift,
     1330                              float rowShift)
     1331{
     1332    psImage* fOut = NULL;
     1333    psImage* sOut = NULL;
     1334
     1335    psLogMsg(__func__,PS_LOG_INFO,"Testing psImageShift with a %dx%d image for "
     1336             "a shift of %g,%g.",cols,rows,colShift,rowShift);
     1337
     1338    psImage* fImg = psImageAlloc(cols,rows,PS_TYPE_F32);
     1339    psImage* sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
     1340
     1341    for(int row=0;row<rows;row++) {
     1342        psF32* fRow = fImg->data.F32[row];
     1343        psS16* sRow = sImg->data.S16[row];
     1344        for (int col=0;col<cols;col++) {
     1345            fRow[col] = (psF32)(row)+(psF32)(col)/100.0f;
     1346            sRow[col] = row-2*col;
     1347        }
     1348    }
     1349
     1350    fOut = psImageShift(fOut, fImg, colShift, rowShift, NAN, PS_INTERPOLATE_FLAT);
     1351    sOut = psImageShift(sOut, sImg, colShift, rowShift, -1, PS_INTERPOLATE_FLAT);
     1352
     1353    for(int row=0;row<rows;row++) {
     1354        psF32* fRow = fOut->data.F32[row];
     1355        psS16* sRow = sOut->data.S16[row];
     1356        for (int col=0;col<cols;col++) {
     1357            psF32 fValue = psImagePixelInterpolate(fImg,col+colShift,
     1358                                                   row+rowShift,NAN,PS_INTERPOLATE_FLAT);
     1359            psS16 sValue = (psS16)psImagePixelInterpolate(sImg,col+colShift,
     1360                           row+rowShift,-1,PS_INTERPOLATE_FLAT);
     1361
     1362            if (fabsf(fRow[col] - fValue) > FLT_EPSILON) {
     1363                psError(__func__,"Float image not shifted correctly at %d,%d (%g vs %g)",
     1364                        col,row,fRow[col],fValue);
     1365                return 1;
     1366            }
     1367            if (sRow[col] != sValue) {
     1368                psError(__func__,"Short image not shifted correctly at %d,%d (%d vs %d)",
     1369                        col,row,sRow[col],sValue);
     1370                return 2;
     1371            }
     1372        }
     1373    }
     1374
     1375    psFree(fImg);
     1376    psFree(sImg);
     1377    psFree(fOut);
     1378    psFree(sOut);
     1379
     1380    return 0;
     1381}
  • trunk/psLib/test/image/verified/tst_psImageManip.stderr

    r1404 r1654  
    124124---> TESTPOINT PASSED (psImage{psImageRotate} | tst_psImageManip.c)
    125125
     126/***************************** TESTPOINT ******************************************\
     127*             TestFile: tst_psImageManip.c                                         *
     128*            TestPoint: psImage{psImageShift}                                      *
     129*             TestType: Positive                                                   *
     130\**********************************************************************************/
     131
     132<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,0.
     133<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,16.
     134<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,-16.
     135<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32,0.
     136<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32,0.
     137<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32,16.
     138<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32,-16.
     139<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32,16.
     140<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32,-16.
     141<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,16.4.
     142<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 0,-16.4.
     143<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32.7,0.
     144<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32.7,0.
     145<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32.6,16.2.
     146<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of 32.6,-16.2.
     147<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32.6,16.2.
     148<DATE><TIME>|<HOST>|I|testImageShiftC|Testing psImageShift with a 64x128 image for a shift of -32.6,-16.2.
     149<DATE><TIME>|<HOST>|I| testImageShift|Following should be an error...
     150<DATE><TIME>|<HOST>|E|   psImageShift|Input image can not be NULL.
     151
     152---> TESTPOINT PASSED (psImage{psImageShift} | tst_psImageManip.c)
     153
Note: See TracChangeset for help on using the changeset viewer.