IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2860


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

made psImageRotate take radian rotation value instead of degrees.

Location:
trunk/psLib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/psLib.kdevses

    r2859 r2860  
    22<!DOCTYPE KDevPrjSession>
    33<KDevPrjSession>
    4  <DocsAndViews NumberOfDocuments="5" >
    5   <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psHash.c" >
    6    <View0 line="451" Type="Source" />
     4 <DocsAndViews NumberOfDocuments="3" >
     5  <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/test/image/tst_psImageManip.c" >
     6   <View0 line="1514" Type="Source" />
    77  </Doc0>
    8   <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psHash.h" >
    9    <View0 line="42" Type="Source" />
     8  <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageManip.c" >
     9   <View0 line="770" Type="Source" />
    1010  </Doc1>
    11   <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psArray.c" >
     11  <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/dataManip/psConstants.h" >
    1212   <View0 line="0" Type="Source" />
    1313  </Doc2>
    14   <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/test/collections/tst_psHash04.c" >
    15    <View0 line="0" Type="Source" />
    16   </Doc3>
    17   <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/test/collections/tst_psHash05.c" >
    18    <View0 line="31" Type="Source" />
    19   </Doc4>
    2014 </DocsAndViews>
    2115 <pluginList>
  • trunk/psLib/src/dataManip/psConstants.h

    r2847 r2860  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-12-29 22:15:51 $
     8 *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-01-03 21:58:52 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030 *****************************************************************************/
    3131#define PS_ONE 1.0
     32#define PS_PI   3.1415926535897932384626433832795029  /* pi */
     33#define PS_PI_2 1.5707963267948966192313216916397514  /* pi/2 */
     34#define PS_PI_4 0.7853981633974483096156608458198757  /* pi/4 */
     35#define PS_1_PI 0.3183098861837906715377675267450287  /* 1/pi */
     36#define PS_2_PI 0.6366197723675813430755350534900574  /* 2/pi */
    3237
    3338/*****************************************************************************
  • trunk/psLib/src/image/psImageManip.c

    r2835 r2860  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-12-28 01:42:28 $
     12 *  @version $Revision: 1.33 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2005-01-03 21:58:53 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2525#include "psMemory.h"
    2626#include "psImageExtraction.h"
    27 
     27#include "psConstants.h"
    2828#include "psImageErrors.h"
    2929
     
    675675        return NULL;
    676676    }
    677     // put the angle in the range of 0...360.
    678     angle = angle - 360.0f * floor(angle / 360.0f);
    679 
    680     if (fabsf(angle - 90.0f) < FLT_EPSILON) {
     677    // put the angle in the range of 0...2PI.
     678    angle = angle - (2.0*PS_PI) * floor(angle / (2.0*PS_PI));
     679
     680    if (fabsf(angle - PS_PI_2) < FLT_EPSILON) {
    681681        // perform 1/4 rotate counter-clockwise
    682682        psS32 numRows = in->numCols;
     
    702702            PSIMAGE_ROTATE_LEFT_90(U8);
    703703            PSIMAGE_ROTATE_LEFT_90(U16);
    704             //            PSIMAGE_ROTATE_LEFT_90(U32);      Not a requirement
    705             //            PSIMAGE_ROTATE_LEFT_90(U64);      Not a requirement
     704            PSIMAGE_ROTATE_LEFT_90(U32);    //  Not a requirement
     705            PSIMAGE_ROTATE_LEFT_90(U64);    //  Not a requirement
    706706            PSIMAGE_ROTATE_LEFT_90(S8);
    707707            PSIMAGE_ROTATE_LEFT_90(S16);
    708             //            PSIMAGE_ROTATE_LEFT_90(S32);      Not a requirement
    709             //            PSIMAGE_ROTATE_LEFT_90(S64);      Not a requirement
     708            PSIMAGE_ROTATE_LEFT_90(S32);    //  Not a requirement
     709            PSIMAGE_ROTATE_LEFT_90(S64);    //  Not a requirement
    710710            PSIMAGE_ROTATE_LEFT_90(F32);
    711711            PSIMAGE_ROTATE_LEFT_90(F64);
     
    723723            }
    724724        }
    725     } else if (fabsf(angle - 180.0f) < FLT_EPSILON) {
     725    } else if (fabsf(angle - PS_PI) < FLT_EPSILON) {
    726726        // perform 1/2 rotate
    727727        psS32 numRows = in->numRows;
     
    748748            PSIMAGE_ROTATE_180_CASE(U8);
    749749            PSIMAGE_ROTATE_180_CASE(U16);
    750             //            PSIMAGE_ROTATE_180_CASE(U32);    Not a requirement
    751             //            PSIMAGE_ROTATE_180_CASE(U64);    Not a requirement
     750            PSIMAGE_ROTATE_180_CASE(U32);    // Not a requirement
     751            PSIMAGE_ROTATE_180_CASE(U64);    // Not a requirement
    752752            PSIMAGE_ROTATE_180_CASE(S8);
    753753            PSIMAGE_ROTATE_180_CASE(S16);
    754             //            PSIMAGE_ROTATE_180_CASE(S32);    Not a requirement
    755             //            PSIMAGE_ROTATE_180_CASE(S64);    Not a requirement
     754            PSIMAGE_ROTATE_180_CASE(S32);    // Not a requirement
     755            PSIMAGE_ROTATE_180_CASE(S64);    // Not a requirement
    756756            PSIMAGE_ROTATE_180_CASE(F32);
    757757            PSIMAGE_ROTATE_180_CASE(F64);
     
    769769            }
    770770        }
    771     } else if (fabsf(angle - 270.0f) < FLT_EPSILON) {
     771    } else if (fabsf(angle - (PS_PI+PS_PI_2)) < FLT_EPSILON) {
    772772        // perform 1/4 rotate clockwise
    773773        psS32 numRows = in->numCols;
     
    793793            PSIMAGE_ROTATE_RIGHT_90(U8);
    794794            PSIMAGE_ROTATE_RIGHT_90(U16);
    795             //            PSIMAGE_ROTATE_RIGHT_90(U32);    Not a requirement
    796             //            PSIMAGE_ROTATE_RIGHT_90(U64);    Not a requirement
     795            PSIMAGE_ROTATE_RIGHT_90(U32);     // Not a requirement
     796            PSIMAGE_ROTATE_RIGHT_90(U64);     // Not a requirement
    797797            PSIMAGE_ROTATE_RIGHT_90(S8);
    798798            PSIMAGE_ROTATE_RIGHT_90(S16);
    799             //            PSIMAGE_ROTATE_RIGHT_90(S32);    Not a requirement
    800             //            PSIMAGE_ROTATE_RIGHT_90(S64);    Not a requirement
     799            PSIMAGE_ROTATE_RIGHT_90(S32);     // Not a requirement
     800            PSIMAGE_ROTATE_RIGHT_90(S64);     // Not a requirement
    801801            PSIMAGE_ROTATE_RIGHT_90(F32);
    802802            PSIMAGE_ROTATE_RIGHT_90(F64);
     
    822822        float centerX = (float)(numCols) / 2.0f;
    823823        float centerY = (float)(numRows) / 2.0f;
    824         float t = angle * (3.14159265358f / 180.0f);
    825         double cosT = cosf(t);
    826         double sinT = sinf(t);
     824        double cosT = cosf(angle);
     825        double sinT = sinf(angle);
    827826
    828827        // calculate the corners of the rotated image so we know the proper output image size.
     
    897896            PSIMAGE_ROTATE_ARBITRARY_LOOP(U16,MODE); \
    898897            break; \
    899             /*        case PS_TYPE_U32:    Not a requirement */ \
    900             /*            PSIMAGE_ROTATE_ARBITRARY_LOOP(U32,MODE); */ \
    901             /*            break; */ \
    902             /*        case PS_TYPE_U64:    Not a requirement */ \
    903             /*            PSIMAGE_ROTATE_ARBITRARY_LOOP(U64,MODE); */ \
    904             /*            break; */ \
     898        case PS_TYPE_U32:   /* Not a requirement */ \
     899            PSIMAGE_ROTATE_ARBITRARY_LOOP(U32,MODE); \
     900            break; \
     901        case PS_TYPE_U64:   /* Not a requirement */ \
     902            PSIMAGE_ROTATE_ARBITRARY_LOOP(U64,MODE); \
     903            break; \
    905904        case PS_TYPE_S8: \
    906905            PSIMAGE_ROTATE_ARBITRARY_LOOP(S8,MODE); \
     
    909908            PSIMAGE_ROTATE_ARBITRARY_LOOP(S16,MODE); \
    910909            break; \
    911             /*        case PS_TYPE_S32:    Not a requirement */ \
    912             /*            PSIMAGE_ROTATE_ARBITRARY_LOOP(S32,MODE); */ \
    913             /*            break; */ \
    914             /*        case PS_TYPE_S64:    Not a requirement */ \
    915             /*            PSIMAGE_ROTATE_ARBITRARY_LOOP(S64,MODE); */ \
    916             /*            break; */ \
     910        case PS_TYPE_S32:   /* Not a requirement */ \
     911            PSIMAGE_ROTATE_ARBITRARY_LOOP(S32,MODE); \
     912            break; \
     913        case PS_TYPE_S64:   /* Not a requirement */ \
     914            PSIMAGE_ROTATE_ARBITRARY_LOOP(S64,MODE); \
     915            break; \
    917916        case PS_TYPE_F32: \
    918917            PSIMAGE_ROTATE_ARBITRARY_LOOP(F32,MODE); \
  • trunk/psLib/src/image/psImageManip.h

    r2375 r2860  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2004-11-16 20:00:21 $
     13 *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-01-03 21:58:53 $
    1515 *
    1616 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4444 *  All pixels outside of the rectangular region in complex space formed by
    4545 *  the min and max input parameters are set to the value vmax (if either
    46  *  the real or imaginary portion exceeds the respective max values), or vmin. 
     46 *  the real or imaginary portion exceeds the respective max values), or vmin.
    4747 *  This function is defined for psC32, and psC64 imagery only.
    4848 *
     
    9393 *  1/scale.  The scale, always a positive number, is equal in each dimension and
    9494 *  specified the number of pixels used to define a new pixel in the output image.
    95  *  The output image is generated from all input image pixels. This function is 
     95 *  The output image is generated from all input image pixels. This function is
    9696 *  defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
    9797 *
     
    110110/** Resample image to new scale.
    111111 *
    112  *  A new image is constructed in which the dimensions are increased by a 
    113  *  factor of scale. The scale, always a positive number, is equal in each 
    114  *  dimension. The output image is generated from all input image pixels. 
    115  *  Each pixel in the output image is derived by interpolating between 
     112 *  A new image is constructed in which the dimensions are increased by a
     113 *  factor of scale. The scale, always a positive number, is equal in each
     114 *  dimension. The output image is generated from all input image pixels.
     115 *  Each pixel in the output image is derived by interpolating between
    116116 *  neighboring pixels using the specified interpolation method (mode).
    117117 *
     
    127127/** Rotate the input image by given angle, specified in degrees.
    128128 *
    129  *  The output image must contain all of the pixels from the input image in 
    130  *  their new frame. Pixels in the output image which do not map to input 
    131  *  pixels should be set to exposed. The center of rotation is always the 
    132  *  center pixel of the image. The rotation is specified in the sense that a 
    133  *  positive angle is an anti-clockwise rotation. This function must be 
    134  *  defined for the following types: psU8, psU16, psS8, psS16, psF32, psF64, 
     129 *  The output image must contain all of the pixels from the input image in
     130 *  their new frame. Pixels in the output image which do not map to input
     131 *  pixels should be set to exposed. The center of rotation is always the
     132 *  center pixel of the image. The rotation is specified in the sense that a
     133 *  positive angle is an anti-clockwise rotation. This function must be
     134 *  defined for the following types: psU8, psU16, psS8, psS16, psF32, psF64,
    135135 *  psC32, psC64.
    136136 *
     
    140140    psImage* out,                      ///< an psImage to recycle.  If NULL, a new image is created
    141141    const psImage* in,                 ///< input image
    142     float angle,                       ///< the rotation angle in degrees.
     142    float angle,                       ///< the rotation angle in radians.
    143143    psC64 unexposedValue,              ///< the output image pixel values for non-imagery areas
    144144    psImageInterpolateMode mode        ///< the interpolation mode used
     
    147147/** Shift image by an arbitrary number of pixels (dx,dy) in either direction.
    148148 *
    149  *  If the shift values are fractional, the output pixel values should 
    150  *  interpolate between the input pixel values. The output image has the same 
    151  *  dimensions as the input image. Pixels which fall off the edge of the 
    152  *  output image are lost. Newly exposed pixels are set to the value given by 
    153  *  exposed. This function must be defined for the following types: psU8, 
     149 *  If the shift values are fractional, the output pixel values should
     150 *  interpolate between the input pixel values. The output image has the same
     151 *  dimensions as the input image. Pixels which fall off the edge of the
     152 *  output image are lost. Newly exposed pixels are set to the value given by
     153 *  exposed. This function must be defined for the following types: psU8,
    154154 *  psU16, psS8, psS16, psF32, psF64, psC32, psC64.
    155155 *
     
    166166
    167167/** Roll image by an integer number of pixels in either direction.
    168  * 
     168 *
    169169 *  The output image is the same dimensions as the input image.  Edge pixels
    170  *  wrap to the other side (no values are lost).  This function is 
     170 *  wrap to the other side (no values are lost).  This function is
    171171 *  defined for psU8, psS8, psS16, psF32, psF64, psC32, and psC64.
    172172 *
  • trunk/psLib/src/math/psConstants.h

    r2847 r2860  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-12-29 22:15:51 $
     8 *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-01-03 21:58:52 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030 *****************************************************************************/
    3131#define PS_ONE 1.0
     32#define PS_PI   3.1415926535897932384626433832795029  /* pi */
     33#define PS_PI_2 1.5707963267948966192313216916397514  /* pi/2 */
     34#define PS_PI_4 0.7853981633974483096156608458198757  /* pi/4 */
     35#define PS_1_PI 0.3183098861837906715377675267450287  /* 1/pi */
     36#define PS_2_PI 0.6366197723675813430755350534900574  /* 2/pi */
    3237
    3338/*****************************************************************************
  • 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.