IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1931


Ignore:
Timestamp:
Sep 30, 2004, 8:47:23 AM (22 years ago)
Author:
evanalst
Message:

Update test cases for more code coverage psImageRotate.

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

Legend:

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

    r1930 r1931  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-09-29 21:23:30 $
     8 *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-09-30 18:47:23 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    12911291    psImage* fOut = NULL;
    12921292    psImage* sOut = NULL;
     1293    psImage* s32Out = NULL;
     1294    psImage* fBiOut = NULL;
     1295    psImage* sBiOut = NULL;
    12931296    psImage* fTruth = NULL;
    12941297    psImage* sTruth = NULL;
     1298    psImage* fBiTruth = NULL;
     1299    psImage* sBiTruth = NULL;
    12951300    int rows = 64;
    12961301    int cols = 64;
    12971302    psImage* fImg = psImageAlloc(cols,rows,PS_TYPE_F32);
    12981303    psImage* sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
     1304    psImage* s32Img = psImageAlloc(cols,rows,PS_TYPE_S32);
    12991305
    13001306    for(int row=0;row<rows;row++) {
    13011307        psF32* fRow = fImg->data.F32[row];
    13021308        psS16* sRow = sImg->data.S16[row];
     1309        psS32* s32Row = s32Img->data.S32[row];
    13031310        for (int col=0;col<cols;col++) {
    13041311            fRow[col] = (psF32)(row)+(psF32)(col)/100.0f;
    13051312            sRow[col] = row-2*col;
     1313            s32Row[col] = row-2*col;
    13061314        }
    13071315    }
     
    13201328        ("temp/sOut.fits")
    13211329        ;
     1330    remove
     1331        ("temp/fBiOut.fits")
     1332        ;
     1333    remove
     1334        ("temp/sBiOut.fits");
     1335    ;
    13221336    int index = 0;
    13231337    bool fail = false;
    13241338    for (int rot=-180;rot<=180;rot+=45) {
    13251339        psImage* oldOut = fOut;
     1340        psImage* oldBiOut = fBiOut;
    13261341        fOut = psImageRotate(fOut,fImg,rot,-1.0,PS_INTERPOLATE_FLAT);
     1342        fBiOut = psImageRotate(fBiOut,fImg,rot,-1.0,PS_INTERPOLATE_BILINEAR);
    13271343        // Verify the returned psImage structure is equal to the input
    13281344        // parameter out if provided.
     
    13311347            return 2;
    13321348        }
     1349        if (oldBiOut != NULL && oldBiOut != fBiOut) {
     1350            psError(__func__,"the output recycle functionality failed");
     1351            return 4;
     1352        }
    13331353        sOut = psImageRotate(sOut,sImg,rot,-1.0,PS_INTERPOLATE_FLAT);
     1354        sBiOut = psImageRotate(sBiOut,sImg,rot,-1.0,PS_INTERPOLATE_BILINEAR);
    13341355        if (! psImageWriteSection(fOut,0,0,0,NULL,index,"temp/fOut.fits") ) {
    13351356            psError(__func__,"Can not write to temp/fOut.fits, so why continue!?");
     
    13401361            return 21;
    13411362        }
     1363        if (! psImageWriteSection(fBiOut,0,0,0,NULL,index,"temp/fBiOut.fits") ) {
     1364            psError(__func__,"Can not write to temp/fBiOut.fits, so why continue!?");
     1365            return 40;
     1366        }
     1367        if (! psImageWriteSection(sBiOut,0,0,0,NULL,index,"temp/sBiOut.fits") ) {
     1368            psError(__func__,"Can not write to temp/sBiOut.fits, so why continue!?");
     1369            return 41;
     1370        }
    13421371
    13431372        // now, let's compare this with the verified file
    13441373        fTruth = psImageReadSection(fTruth,0,0,0,0,0,NULL,index,"verified/fOut.fits");
    13451374        sTruth = psImageReadSection(sTruth,0,0,0,0,0,NULL,index,"verified/sOut.fits");
    1346 
     1375        fBiTruth = psImageReadSection(fBiTruth,0,0,0,0,0,NULL,index,"verified/fBiOut.fits");
     1376        sBiTruth = psImageReadSection(sBiTruth,0,0,0,0,0,NULL,index,"verified/sBiOut.fits");
    13471377        if (fTruth == NULL) {
    13481378            psError(__func__,"verified psF32 image failed to be read (%d deg. rotation)",
     
    13971427
    13981428
     1429        if (fBiTruth == NULL) {
     1430            psError(__func__,"verified psF32 Bi image failed to be read (%d deg. rotation)",
     1431                    rot);
     1432            fail = true;
     1433        } else {
     1434            if (fBiTruth->numRows != fBiOut->numRows || fBiTruth->numCols != fBiOut->numCols) {
     1435                psError(__func__,"Rotated float image size did not match truth "
     1436                        "image for %d deg rotation (%dx%d vs %dx%d). BILINEAR",
     1437                        rot,fBiOut->numCols,fBiOut->numRows,fBiTruth->numCols,fBiTruth->numRows);
     1438                fail = true;
     1439            } else {
     1440                for (int row=0;row<fBiTruth->numRows;row++) {
     1441                    psF32* truthRow = fBiTruth->data.F32[row];
     1442                    psF32* outRow = fBiOut->data.F32[row];
     1443                    for (int col=0;col<fBiTruth->numCols;col++) {
     1444                        if (fabsf(truthRow[col]-outRow[col]) > 1) {
     1445                            psError(__func__,"Float Image mismatch (%f vs %f) at %d,%d. BILINEAR",
     1446                                    outRow[col], truthRow[col],col,row);
     1447                            fail = true;
     1448                        }
     1449                    }
     1450                }
     1451            }
     1452        }
     1453
     1454        if (sBiTruth == NULL) {
     1455            psError(__func__,"verified psS16 image failed to be read "
     1456                    "(%d deg. rotation) BILINEAR",rot);
     1457            fail = true;
     1458        } else {
     1459            if (sBiTruth->numRows != sBiOut->numRows ||
     1460                    sBiTruth->numCols != sBiOut->numCols) {
     1461                psError(__func__,"Rotated short image size did not match truth "
     1462                        "image for %d deg rotation. BILINEAR",rot);
     1463                fail = true;
     1464            } else {
     1465                for (int row=0;row<sBiTruth->numRows;row++) {
     1466                    psS16* truthRow = sBiTruth->data.S16[row];
     1467                    psS16* outRow = sBiOut->data.S16[row];
     1468                    for (int col=0;col<sBiTruth->numCols;col++) {
     1469                        if (fabsf(truthRow[col]-outRow[col]) > 1) {
     1470                            psError(__func__,"Short Image mismatch (%d vs %d) "
     1471                                    "at %d,%d. BILINEAR",
     1472                                    outRow[col], truthRow[col],col,row);
     1473                            fail = true;
     1474                        }
     1475                    }
     1476                }
     1477            }
     1478        }
     1479
     1480        // Verify psImage structure returned is NULL and program execution doesn't stop
     1481        // if the input image type is not supported. Do not check for 0 degree rotation
     1482        // since an imgae copy will be used.
     1483        if (rot != 0 ) {
     1484            psLogMsg(__func__,PS_LOG_INFO,"Following should be an error invalid type for rotate.");
     1485            s32Out = psImageRotate(s32Out,s32Img,rot,-1.0,PS_INTERPOLATE_FLAT);
     1486            if( s32Out != NULL ) {
     1487                psError(__func__,"psImage returned is not NULL for invalid image type.");
     1488                return 5;
     1489            }
     1490        }
     1491
    13991492        index++;
    14001493    }
     
    14161509    }
    14171510
     1511    // Verify the returned psImage structure pointer is null and program
     1512    // execution doesn't stop, if the specified interpolation mode is invalid
     1513    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error for invalid "
     1514             "interpolation type.");
     1515    fOut = psImageRotate(fOut, fImg, 33, 0, -1);
     1516    if (fOut != NULL) {
     1517        psError(__func__,"NULL wasn't returned though the interpolation mode "
     1518                "is invalid.");
     1519        return 4;
     1520    }
     1521
    14181522    psFree(sOut);
    14191523    psFree(fImg);
     
    14211525    psFree(fTruth);
    14221526    psFree(sTruth);
     1527    psFree(sBiOut);
     1528    psFree(fBiTruth);
     1529    psFree(sBiTruth);
     1530    psFree(fBiOut);
     1531    psFree(s32Img);
     1532    psFree(s32Out);
    14231533
    14241534    return 0;
  • trunk/psLib/test/image/verified/tst_psImageManip.stderr

    r1926 r1931  
    212212
    213213<DATE><TIME>|<HOST>|I|testImageRotate
     214    Following should be an error invalid type for rotate.
     215<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     216    Specified psImage type, psS32, is not supported.
     217<DATE><TIME>|<HOST>|I|testImageRotate
     218    Following should be an error invalid type for rotate.
     219<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     220    Specified psImage type, psS32, is not supported.
     221<DATE><TIME>|<HOST>|I|testImageRotate
     222    Following should be an error invalid type for rotate.
     223<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     224    Specified psImage type, psS32, is not supported.
     225<DATE><TIME>|<HOST>|I|testImageRotate
     226    Following should be an error invalid type for rotate.
     227<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     228    Specified psImage type, psS32, is not supported.
     229<DATE><TIME>|<HOST>|I|testImageRotate
     230    Following should be an error invalid type for rotate.
     231<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     232    Specified psImage type, psS32, is not supported.
     233<DATE><TIME>|<HOST>|I|testImageRotate
     234    Following should be an error invalid type for rotate.
     235<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     236    Specified psImage type, psS32, is not supported.
     237<DATE><TIME>|<HOST>|I|testImageRotate
     238    Following should be an error invalid type for rotate.
     239<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     240    Specified psImage type, psS32, is not supported.
     241<DATE><TIME>|<HOST>|I|testImageRotate
     242    Following should be an error invalid type for rotate.
     243<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     244    Specified psImage type, psS32, is not supported.
     245<DATE><TIME>|<HOST>|I|testImageRotate
    214246    Following should be an error
    215247<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
    216248    Can not operate on a NULL psImage.
     249<DATE><TIME>|<HOST>|I|testImageRotate
     250    Following should be an error for invalid interpolation type.
     251<DATE><TIME>|<HOST>|E|psLib.image.psImageRotate
     252    Specified interpolation mode, -1, is unsupported.
    217253
    218254---> TESTPOINT PASSED (psImage{psImageRotate} | tst_psImageManip.c)
Note: See TracChangeset for help on using the changeset viewer.