IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 2:57:34 PM (22 years ago)
Author:
desonia
Message:

converted native C types to ps Types, where practical.

File:
1 edited

Legend:

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

    r2078 r2204  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-13 19:50:12 $
     8 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-10-27 00:57:33 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020#define GENIMAGE(img,c,r,TYP, valueFcn) \
    2121img = psImageAlloc(c,r,PS_TYPE_##TYP); \
    22 for (unsigned int row=0;row<r;row++) { \
     22for (psU32 row=0;row<r;row++) { \
    2323    ps##TYP* imgRow = img->data.TYP[row]; \
    24     for (unsigned int col=0;col<c;col++) { \
     24    for (psU32 col=0;col<c;col++) { \
    2525        imgRow[col] = (ps##TYP)(valueFcn); \
    2626    } \
    2727}
    2828
    29 static int testImageFFT(void);
    30 static int testImageRealImaginary(void);
    31 static int testImageComplex(void);
    32 static int testImageConjugate(void);
    33 static int testImagePowerSpectrum(void);
     29static psS32 testImageFFT(void);
     30static psS32 testImageRealImaginary(void);
     31static psS32 testImageComplex(void);
     32static psS32 testImageConjugate(void);
     33static psS32 testImagePowerSpectrum(void);
    3434
    3535testDescription tests[] = {
     
    5454                          };
    5555
    56 int main(int argc, char* argv[])
     56psS32 main(psS32 argc, char* argv[])
    5757{
    5858    psLogSetLevel(PS_LOG_INFO);
     
    6161}
    6262
    63 int testImageFFT(void)
     63psS32 testImageFFT(void)
    6464{
    6565    psImage* img = NULL;
    6666    psImage* img2 = NULL;
    6767    psImage* img3 = NULL;
    68     unsigned int m = 128;
    69     unsigned int n = 64;
     68    psU32 m = 128;
     69    psU32 n = 64;
    7070    psImage* img4 = NULL;
    7171    psImage* img5 = NULL;
     
    9595
    9696    // 3. verify that the only significant component cooresponds to the freqency of the input in step 1.
    97     for (unsigned int row=0;row<n;row++) {
     97    for (psU32 row=0;row<n;row++) {
    9898        psC32* img2Row = img2->data.C32[row];
    99         for (unsigned int col=0;col<m;col++) {
     99        for (psU32 col=0;col<m;col++) {
    100100            psF32 mag = cabsf(img2Row[col])/m/n;
    101101            if (mag > 0.1f) {
     
    130130    }
    131131
    132     for (unsigned int row=0;row<n;row++) {
     132    for (psU32 row=0;row<n;row++) {
    133133        psC32* img3Row = img3->data.C32[row];
    134134        psF32* imgRow = img->data.F32[row];
    135         for (unsigned int col=0;col<m;col++) {
     135        for (psU32 col=0;col<m;col++) {
    136136            psF32 pixel = creal(img3Row[col])/m/n;
    137137            if (fabsf(pixel-imgRow[col]) > 0.1) {
     
    159159    }
    160160
    161     for (unsigned int row=0;row<n;row++) {
     161    for (psU32 row=0;row<n;row++) {
    162162        psF32* img3Row = img3->data.F32[row];
    163163        psF32* imgRow = img->data.F32[row];
    164         for (unsigned int col=0;col<m;col++) {
     164        for (psU32 col=0;col<m;col++) {
    165165            psF32 pixel = img3Row[col]/m/n;
    166166            if (fabsf(pixel-imgRow[col]) > 0.1) {
     
    209209}
    210210
    211 int testImageRealImaginary(void)
     211psS32 testImageRealImaginary(void)
    212212{
    213213    psImage* img = NULL;
    214214    psImage* img2 = NULL;
    215215    psImage* img3 = NULL;
    216     unsigned int m = 128;
    217     unsigned int n = 64;
     216    psU32 m = 128;
     217    psU32 n = 64;
    218218
    219219    /*
     
    250250
    251251    // 3. compare results to the real/imaginary components of input
    252     for (unsigned int row=0;row<n;row++) {
     252    for (psU32 row=0;row<n;row++) {
    253253        psF32* img2Row = img2->data.F32[row];
    254254        psF32* img3Row = img3->data.F32[row];
    255         for (unsigned int col=0;col<m;col++) {
     255        for (psU32 col=0;col<m;col++) {
    256256            if (fabsf(img2Row[col] - row) > FLT_EPSILON) {
    257257                psError(__func__,"psImageReal didn't return the real portion at n=%d",
     
    274274}
    275275
    276 int testImageComplex(void)
     276psS32 testImageComplex(void)
    277277{
    278278    psImage* img = NULL;
    279279    psImage* img2 = NULL;
    280280    psImage* img3 = NULL;
    281     unsigned int m = 128;
    282     unsigned int n = 64;
     281    psU32 m = 128;
     282    psU32 n = 64;
    283283
    284284    /*
     
    314314    // 4. call psImageReal and psImageImaginary on step 2 results (not needed, just use crealf/cimagf)
    315315    // 5. compare step 4 results to input.
    316     for (unsigned int row=0;row<n;row++) {
     316    for (psU32 row=0;row<n;row++) {
    317317        psC32* img3Row = img3->data.C32[row];
    318         for (unsigned int col=0;col<m;col++) {
     318        for (psU32 col=0;col<m;col++) {
    319319            if (fabsf(crealf(img3Row[col]) - row) > FLT_EPSILON ||
    320320                    fabsf(cimagf(img3Row[col]) - col) > FLT_EPSILON) {
     
    358358}
    359359
    360 int testImageConjugate(void)
     360psS32 testImageConjugate(void)
    361361{
    362362    psImage* img = NULL;
    363363    psImage* img2 = NULL;
    364     unsigned int m = 128;
    365     unsigned int n = 64;
     364    psU32 m = 128;
     365    psU32 n = 64;
    366366
    367367    /*
     
    385385
    386386    // 4. verify each value is conjugate of input (a+bi -> a-bi)
    387     for (unsigned int row=0;row<n;row++) {
     387    for (psU32 row=0;row<n;row++) {
    388388        psC32* img2Row = img2->data.C32[row];
    389         for (unsigned int col=0;col<m;col++) {
     389        for (psU32 col=0;col<m;col++) {
    390390            if (fabsf(crealf(img2Row[col]) - row) > FLT_EPSILON ||
    391391                    fabsf(cimagf(img2Row[col]) + col) > FLT_EPSILON) {
     
    403403}
    404404
    405 int testImagePowerSpectrum(void)
     405psS32 testImagePowerSpectrum(void)
    406406{
    407407    psImage* img = NULL;
    408408    psImage* img2 = NULL;
    409     unsigned int m = 128;
    410     unsigned int n = 64;
     409    psU32 m = 128;
     410    psU32 n = 64;
    411411
    412412    /*
     
    430430
    431431    // 4. verify the values are the square of the absolute values of the original
    432     for (unsigned int row=0;row<n;row++) {
     432    for (psU32 row=0;row<n;row++) {
    433433        psC32* imgRow = img->data.C32[row];
    434434        psF32* img2Row = img2->data.F32[row];
    435         for (unsigned int col=0;col<m;col++) {
     435        for (psU32 col=0;col<m;col++) {
    436436            psF32 power = cabs(imgRow[col]);
    437437            power *= power/n/n/m/m;
Note: See TracChangeset for help on using the changeset viewer.