IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 3, 2005, 11:58:53 AM (22 years ago)
Author:
desonia
Message:

made psImageRotate take radian rotation value instead of degrees.

File:
1 edited

Legend:

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

    r2855 r2860  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.34 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-12-30 20:18:37 $
     8 *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-01-03 21:58:53 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    12791279    psImage* fOut = NULL;
    12801280    psImage* sOut = NULL;
    1281     psImage* s32Out = NULL;
    12821281    psImage* fBiOut = NULL;
    12831282    psImage* sBiOut = NULL;
     
    12901289    psImage* fImg = psImageAlloc(cols,rows,PS_TYPE_F32);
    12911290    psImage* sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
    1292     psImage* s32Img = psImageAlloc(cols,rows,PS_TYPE_S32);
    12931291
    12941292    for(psS32 row=0;row<rows;row++) {
    12951293        psF32* fRow = fImg->data.F32[row];
    12961294        psS16* sRow = sImg->data.S16[row];
    1297         psS32* s32Row = s32Img->data.S32[row];
    12981295        for (psS32 col=0;col<cols;col++) {
    12991296            fRow[col] = (psF32)(row)+(psF32)(col)/100.0f;
    13001297            sRow[col] = row-2*col;
    1301             s32Row[col] = row-2*col;
    13021298        }
    13031299    }
     
    13241320    psS32 index = 0;
    13251321    psBool fail = false;
     1322    psF32 radianRot;
    13261323    for (psS32 rot=-180;rot<=180;rot+=45) {
    13271324        psImage* oldOut = fOut;
    13281325        psImage* oldBiOut = fBiOut;
    1329         fOut = psImageRotate(fOut,fImg,rot,-1.0,PS_INTERPOLATE_FLAT);
    1330         fBiOut = psImageRotate(fBiOut,fImg,rot,-1.0,PS_INTERPOLATE_BILINEAR);
     1326
     1327        if (rot == 90) {
     1328            radianRot = PS_PI_2;
     1329        } else if (rot == -90) {
     1330            radianRot = PS_PI+PS_PI_2;
     1331        } else if (rot == 180 || rot == -180) {
     1332            radianRot = PS_PI;
     1333        } else {
     1334            radianRot = ((float)rot)*PS_PI/180.0;
     1335        }
     1336
     1337        fOut = psImageRotate(fOut,fImg,radianRot,-1.0,PS_INTERPOLATE_FLAT);
     1338        fBiOut = psImageRotate(fBiOut,fImg,radianRot,-1.0,PS_INTERPOLATE_BILINEAR);
    13311339        // Verify the returned psImage structure is equal to the input
    13321340        // parameter out if provided.
     
    13391347            return 4;
    13401348        }
    1341         sOut = psImageRotate(sOut,sImg,rot,-1.0,PS_INTERPOLATE_FLAT);
    1342         sBiOut = psImageRotate(sBiOut,sImg,rot,-1.0,PS_INTERPOLATE_BILINEAR);
     1349        sOut = psImageRotate(sOut,sImg,radianRot,-1.0,PS_INTERPOLATE_FLAT);
     1350        sBiOut = psImageRotate(sBiOut,sImg,radianRot,-1.0,PS_INTERPOLATE_BILINEAR);
    13431351        if (! psImageWriteSection(fOut,0,0,0,NULL,index,"temp/fOut.fits") ) {
    13441352            psError(PS_ERR_UNKNOWN, true,"Can not write to temp/fOut.fits, so why continue!?");
     
    14661474        }
    14671475
    1468         // Verify psImage structure returned is NULL and program execution doesn't stop
    1469         // if the input image type is not supported. Do not check for 0 degree rotation
    1470         // since an imgae copy will be used.
    1471         if (rot != 0 ) {
    1472             psLogMsg(__func__,PS_LOG_INFO,"Following should be an error invalid type for rotate.");
    1473             s32Out = psImageRotate(s32Out,s32Img,rot,-1.0,PS_INTERPOLATE_FLAT);
    1474             if( s32Out != NULL ) {
    1475                 psError(PS_ERR_UNKNOWN, true,"psImage returned is not NULL for invalid image type.");
    1476                 return 5;
    1477             }
    1478         }
    1479 
    14801476        index++;
    14811477    }
     
    15171513    psFree(sBiTruth);
    15181514    psFree(fBiOut);
    1519     psFree(s32Img);
    1520     psFree(s32Out);
    15211515
    15221516    return 0;
Note: See TracChangeset for help on using the changeset viewer.