IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1984


Ignore:
Timestamp:
Oct 6, 2004, 11:40:13 AM (22 years ago)
Author:
desonia
Message:

misc. tweaks.

Location:
trunk/psLib
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/psLib.kdevelop.filelist

    r1866 r1984  
    447447CVS/Repository
    448448CVS/Root
     449test/image/tst_psImageConvolve.c
  • trunk/psLib/psLib.kdevses

    r1929 r1984  
    33<KDevPrjSession>
    44 <DocsAndViews NumberOfDocuments="6" >
    5   <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageExtraction.h" >
    6    <View0 line="0" Type="???" >
    7     <AdditionalSettings Top="1" Width="1138" Attach="1" Height="702" Left="1" MinMaxMode="0" />
     5  <Doc0 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageConvolve.c" >
     6   <View0 line="412" Type="???" >
     7    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" />
    88   </View0>
    99  </Doc0>
    10   <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageExtraction.c" >
    11    <View0 line="151" Type="???" >
    12     <AdditionalSettings Top="1" Width="1530" Attach="1" Height="998" Left="1" MinMaxMode="0" />
     10  <Doc1 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageFFT.c" >
     11   <View0 line="36" Type="???" >
     12    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" />
    1313   </View0>
    1414  </Doc1>
    15   <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/test/image/tst_psImageExtraction.c" >
    16    <View0 line="523" Type="???" >
    17     <AdditionalSettings Top="1" Width="1138" Attach="1" Height="675" Left="1" MinMaxMode="0" />
     15  <Doc2 NumberOfViews="1" URL="file:/home/desonia/psLib/src/dataManip/psVectorFFT.h" >
     16   <View0 line="31" Type="???" >
     17    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" />
    1818   </View0>
    1919  </Doc2>
    20   <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/test/image/tst_psImageManip.c" >
    21    <View0 line="45" Type="???" >
    22     <AdditionalSettings Top="1" Width="1138" Attach="1" Height="675" Left="1" MinMaxMode="0" />
     20  <Doc3 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageErrors.dat" >
     21   <View0 line="44" Type="???" >
     22    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" />
    2323   </View0>
    2424  </Doc3>
    25   <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/test/image/tst_psImage.c" >
    26    <View0 line="23" Type="???" >
    27     <AdditionalSettings Top="1" Width="1138" Attach="1" Height="675" Left="1" MinMaxMode="0" />
     25  <Doc4 NumberOfViews="1" URL="file:/home/desonia/psLib/test/image/tst_psImageConvolve.c" >
     26   <View0 line="386" Type="???" >
     27    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" />
    2828   </View0>
    2929  </Doc4>
    30   <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/image/psImageErrors.dat" >
    31    <View0 line="15" Type="???" >
    32     <AdditionalSettings Top="1" Width="1532" Attach="1" Height="991" Left="1" MinMaxMode="0" />
     30  <Doc5 NumberOfViews="1" URL="file:/home/desonia/psLib/src/collections/psVector.c" >
     31   <View0 line="86" Type="???" >
     32    <AdditionalSettings Top="2" Width="1181" Attach="1" Height="701" Left="2" MinMaxMode="0" />
    3333   </View0>
    3434  </Doc5>
  • trunk/psLib/src/dataManip/psVectorFFT.h

    r1625 r1984  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-08-25 21:10:08 $
     9 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-10-06 21:40:13 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2424typedef enum {
    2525    /// psImageFFT/psVectorFFT should perform a forward FFT.
    26     PS_FFT_FORWARD = (-1),
     26    PS_FFT_FORWARD = 1,
    2727
    2828    /// psImageFFT/psVectorFFT should perform a reverse FFT.
    29     PS_FFT_REVERSE = (+1)
     29    PS_FFT_REVERSE = 2,
     30
     31    /// psImageFFT/psVectorFFT should perform a reverse FFT with a real result.
     32    PS_FFT_REAL_RESULT = 4
    3033} psFftDirection;
    3134
  • trunk/psLib/src/fft/psVectorFFT.h

    r1625 r1984  
    77 *  @author Robert DeSonia, MHPCC
    88 *
    9  *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-08-25 21:10:08 $
     9 *  @version $Revision: 1.15 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-10-06 21:40:13 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2424typedef enum {
    2525    /// psImageFFT/psVectorFFT should perform a forward FFT.
    26     PS_FFT_FORWARD = (-1),
     26    PS_FFT_FORWARD = 1,
    2727
    2828    /// psImageFFT/psVectorFFT should perform a reverse FFT.
    29     PS_FFT_REVERSE = (+1)
     29    PS_FFT_REVERSE = 2,
     30
     31    /// psImageFFT/psVectorFFT should perform a reverse FFT with a real result.
     32    PS_FFT_REAL_RESULT = 4
    3033} psFftDirection;
    3134
  • trunk/psLib/src/sys/psType.h

    r1840 r1984  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-09-21 22:30:19 $
     13*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-10-06 21:40:13 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050typedef float psF32;                   ///< 32-bit floating point
    5151typedef double psF64;                  ///< 64-bit floating point
    52 typedef complex float psC32;           ///< complex with 32-bit floating point Real and Imagary numbers
    53 typedef complex double psC64;          ///< complex with 64-bit floating point Real and Imagary numbers
     52typedef float _Complex psC32;          ///< complex with 32-bit floating point Real and Imagary numbers
     53typedef double _Complex psC64;         ///< complex with 64-bit floating point Real and Imagary numbers
    5454typedef void *psPTR;                   ///< void pointer
    5555
  • trunk/psLib/src/sysUtils/psType.h

    r1840 r1984  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2004-09-21 22:30:19 $
     13*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2004-10-06 21:40:13 $
    1515*
    1616*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050typedef float psF32;                   ///< 32-bit floating point
    5151typedef double psF64;                  ///< 64-bit floating point
    52 typedef complex float psC32;           ///< complex with 32-bit floating point Real and Imagary numbers
    53 typedef complex double psC64;          ///< complex with 64-bit floating point Real and Imagary numbers
     52typedef float _Complex psC32;          ///< complex with 32-bit floating point Real and Imagary numbers
     53typedef double _Complex psC64;         ///< complex with 64-bit floating point Real and Imagary numbers
    5454typedef void *psPTR;                   ///< void pointer
    5555
  • trunk/psLib/test/dataManip/verified/tst_psMinimize04.stderr

    r1976 r1984  
    22    Following should generate an error for null input polynomial.
    33<DATE><TIME>|<HOST>|E|psVectorFitPolynomial1D
    4     Invalid operation: myPoly or its coeffs is NULL.
     4    Unallowable operation: myPoly or its coeffs is NULL.
  • trunk/psLib/test/image/tst_psImageConvolve.c

    r1940 r1984  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-01 20:58:32 $
     7 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-06 21:40:13 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222static int testKernelAlloc(void);
    2323static int testKernelGenerate(void);
     24static int testImageConvolve(void);
    2425
    2526testDescription tests[] = {
    2627                              {testKernelAlloc,731,"psKernelAlloc",0,false},
    2728                              {testKernelGenerate,732,"psKernelGenerate",0,false},
     29                              {testImageConvolve,733,"psImageConvolve",0,false},
    2830                              {NULL}
    2931                          };
     
    287289    return 0;
    288290}
     291
     292static int testImageConvolve(void)
     293{
     294    const int r = 200;
     295    const int c = 300;
     296    int sum;
     297
     298    // approximate a normalized gaussian kernel.
     299    psKernel* g = psKernelAlloc(-1,1,-1,1);
     300    g->kernel[-1][-1] =
     301        g->kernel[-1][1] =
     302            g->kernel[1][-1] =
     303                g->kernel[1][1] = 0.0113;
     304    g->kernel[1][0] =
     305        g->kernel[-1][0] =
     306            g->kernel[0][-1] =
     307                g->kernel[0][1] = 0.0838;
     308    g->kernel[0][0] = 0.6193;
     309
     310    // create a normalized non-symetric kernel.
     311    psKernel* nsk = psKernelAlloc(0,2,0,2);
     312    sum = 0.0;
     313    for (int i=0;i<2;i++) {
     314        for (int j=0;j<2;j++) {
     315            nsk->kernel[i][j] = i+j;
     316            sum = i+j;
     317        }
     318    }
     319    for (int i=0;i<2;i++) {
     320        for (int j=0;j<2;j++) {
     321            nsk->kernel[i][j] /= sum;
     322        }
     323    }
     324
     325
     326    psImage* img = psImageAlloc(c,r,PS_TYPE_F32);
     327    memset(img->data.F32[0],0,c*r*PSELEMTYPE_SIZEOF(PS_TYPE_F32));
     328    img->data.F32[0][0] = 1.0f;
     329    img->data.F32[r/2][c/2] = 1.0f;
     330    img->data.F32[r-1][c/2] = 1.0f;
     331
     332    // test spacial convolution of gaussian
     333    psLogMsg(__func__,PS_LOG_INFO,"Testing direct gaussian convolution");
     334    psImage* out = psImageConvolve(NULL, img, g, true);
     335
     336    if (out == NULL) {
     337        psError(__func__, "psImageConvolve returned a NULL for direct gaussian case.");
     338        return 1;
     339    }
     340
     341    if (out->numCols != c || out->numRows != r) {
     342        psError(__func__, "psImageConvolve result image is %dx%d, but expected %dx%d.",
     343                out->numCols, out->numRows,
     344                c,r);
     345        return 2;
     346    }
     347
     348    if (out->type.type != PS_TYPE_F32) {
     349        char* typeStr;
     350        PS_TYPE_NAME(typeStr,out->type.type);
     351        psError(__func__, "psImageConvolve result image is of type %s, not psF32.",
     352                typeStr);
     353        return 3;
     354    }
     355
     356    // test values
     357    for (int i=-1;i<1;i++) {
     358        for (int j=-1;j<1;j++) {
     359            if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
     360                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
     361                        c/2+j,r/2+i,
     362                        out->data.F32[r/2+i][c/2+j], g->kernel[i][j]);
     363                return 4;
     364            }
     365            if (i >= 0 && j >= 0 && fabsf(out->data.F32[i][j] - g->kernel[i][j]) > 0.0001) {
     366                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
     367                        j,i,
     368                        out->data.F32[i][j], g->kernel[i][j]);
     369                return 5;
     370            }
     371            if (i <= 0 && fabsf(out->data.F32[r-1+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
     372                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
     373                        c/2+j,r-1+i,
     374                        out->data.F32[r-1+i][c/2+j], g->kernel[i][j]);
     375                return 6;
     376            }
     377        }
     378    }
     379
     380    // test fourier convolution of gaussian
     381    psLogMsg(__func__,PS_LOG_INFO,"Testing fourier gaussian convolution");
     382    psKernel* gg = psKernelAlloc(1,3,1,3);
     383    gg->kernel[1][1] =
     384        gg->kernel[1][3] =
     385            gg->kernel[3][1] =
     386                gg->kernel[3][3] = 0.0113;
     387    gg->kernel[3][2] =
     388        gg->kernel[1][2] =
     389            gg->kernel[2][1] =
     390                gg->kernel[2][3] = 0.0838;
     391    gg->kernel[2][2] = 0.6193;
     392    img->data.F32[0][0] = 0.0f;
     393    img->data.F32[r/2][c/2] = 1.0f;
     394    img->data.F32[r-1][c/2] = 0.0f;
     395    psImage* out2 = psImageConvolve(out, img, gg, false);
     396
     397    if (out == NULL) {
     398        psError(__func__, "psImageConvolve returned a NULL for gaussian case.");
     399        return 10;
     400    }
     401
     402    if (out != out2) {
     403        psError(__func__, "psImageConvolve didn't recycle the supplied out image struct.");
     404        return 11;
     405    }
     406
     407    if (out->numCols != c || out->numRows != r) {
     408        psError(__func__, "psImageConvolve result image is %dx%d, but expected %dx%d.",
     409                out->numCols, out->numRows,
     410                c,r);
     411        return 12;
     412    }
     413
     414    if (out->type.type != PS_TYPE_F32) {
     415        char* typeStr;
     416        PS_TYPE_NAME(typeStr,out->type.type);
     417        psError(__func__, "psImageConvolve result image is of type %s, not psF32.",
     418                typeStr);
     419        return 13;
     420    }
     421
     422    psImageWriteSection(out2,0,0,0,NULL,0,"out2.fits");
     423    // test values
     424    for (int i=-1;i<1;i++) {
     425        for (int j=-1;j<1;j++) {
     426            if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
     427                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
     428                        c/2+j,r/2+i,
     429                        out->data.F32[r/2+i][c/2+j], g->kernel[i][j]);
     430                psImageWriteSection(out,0,0,0,NULL,0,"problem.fits");
     431                return 14;
     432            }
     433            if (i >= 0 && j >= 0 && fabsf(out->data.F32[i][j] - g->kernel[i][j]) > 0.0001) {
     434                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
     435                        j,i,
     436                        out->data.F32[i][j], g->kernel[i][j]);
     437                return 15;
     438            }
     439            if (i <= 0 && fabsf(out->data.F32[r-1+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
     440                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
     441                        c/2+j,r-1+i,
     442                        out->data.F32[r-1+i][c/2+j], g->kernel[i][j]);
     443                return 16;
     444            }
     445        }
     446    }
     447
     448    psFree(g);
     449    psFree(img);
     450    psFree(nsk);
     451    psFree(out);
     452    return 0;
     453}
  • trunk/psLib/test/image/tst_psImageFFT.c

    r1979 r1984  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-06 19:36:30 $
     8 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-10-06 21:40:13 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    8888        return 1;
    8989    }
     90    if (img2->numCols != m || img2->numRows != n) {
     91        psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
     92                img2->numCols,img2->numRows,m,n);
     93        return 2;
     94    }
    9095
    9196    // 3. verify that the only significant component cooresponds to the freqency of the input in step 1.
     
    99104                        && ! (row == 0 && (col==1 || col == n-1)) ) {
    100105                    psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag);
     106                    return 3;
    101107                }
    102108            } else
     
    104110                        || (row == 0 && (col==1 || col == n-1)) ) {
    105111                    psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag);
     112                    return 4;
    106113                }
    107114        }
     
    114121    if (img3->type.type != PS_TYPE_C32) {
    115122        psError(__func__,"FFT didn't produce complex values?");
    116         return 4;
     123        return 5;
     124    }
     125
     126    if (img3->numCols != m || img3->numRows != n) {
     127        psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
     128                img3->numCols,img3->numRows,m,n);
     129        return 6;
    117130    }
    118131
     
    125138                psError(__func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)",
    126139                        col,row,pixel,imgRow[col]);
    127                 return 5;
    128             }
    129         }
     140                return 7;
     141            }
     142        }
     143    }
     144
     145    // 4. perform a reverse transform to real result
     146    img3 = psImageFFT(img3,img2,PS_FFT_REVERSE|PS_FFT_REAL_RESULT);
     147
     148    if (img3->type.type != PS_TYPE_F32) {
     149        char* typeStr;
     150        PS_TYPE_NAME(typeStr,img3->type.type)
     151        psError(__func__,"FFT asked to make real result, but I got a %s type image?",typeStr);
     152        return 8;
     153    }
     154
     155    if (img3->numCols != m || img3->numRows != n) {
     156        psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).",
     157                img3->numCols,img3->numRows,m,n);
     158        return 9;
     159    }
     160
     161    for (unsigned int row=0;row<n;row++) {
     162        psF32* img3Row = img3->data.F32[row];
     163        psF32* imgRow = img->data.F32[row];
     164        for (unsigned int col=0;col<m;col++) {
     165            psF32 pixel = img3Row[col]/m/n;
     166            if (fabsf(pixel-imgRow[col]) > 0.1) {
     167                psError(__func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)",
     168                        col,row,pixel,imgRow[col]);
     169                return 10;
     170            }
     171        }
     172    }
     173
     174    // check if error occurs if FORWARD and REVERSE are both given.
     175    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     176    if (psImageFFT(NULL,img2,PS_FFT_REVERSE|PS_FFT_FORWARD) != NULL) {
     177        psError(__func__,"PS_FFT_REVERSE|PS_FFT_FORWARD option produced something?");
     178        return 11;
     179    }
     180
     181    psLogMsg(__func__,PS_LOG_INFO,"Following should be an error.");
     182    if (psImageFFT(NULL,img2,PS_FFT_FORWARD|PS_FFT_REAL_RESULT) != NULL) {
     183        psError(__func__,"PS_FFT_FORWARD|PS_FFT_REAL_RESULT option produced something?");
     184        return 12;
    130185    }
    131186
Note: See TracChangeset for help on using the changeset viewer.