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.

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

Legend:

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

    r1929 r2204  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-09-29 20:17:58 $
     8 *  @version $Revision: 1.28 $ $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
     
    2121#include "psType.h"
    2222
    23 static int testImageAlloc(void);
    24 static int testImageCopy(void);
     23static psS32 testImageAlloc(void);
     24static psS32 testImageCopy(void);
    2525
    2626testDescription tests[] = {
     
    3131                          };
    3232
    33 int main(int argc, char* argv[])
     33psS32 main(psS32 argc, char* argv[])
    3434{
    3535    psLogSetLevel(PS_LOG_INFO);
     
    3838}
    3939
    40 int testImageAlloc(void)
     40psS32 testImageAlloc(void)
    4141{
    4242    psImage* image = NULL;
    43     unsigned int sizes = 6;
    44     unsigned int numCols[] = {
    45                                  0,1,1,100,100,150
    46                              };
    47     unsigned int numRows[] = {
    48                                  0,1,100,1,150,100
    49                              };
    50     unsigned int types = 13;
     43    psU32 sizes = 6;
     44    psU32 numCols[] = {
     45                          0,1,1,100,100,150
     46                      };
     47    psU32 numRows[] = {
     48                          0,1,100,1,150,100
     49                      };
     50    psU32 types = 13;
    5151    psElemType type[] = { PS_TYPE_S8, PS_TYPE_S16, PS_TYPE_S32, PS_TYPE_S64,
    5252                          PS_TYPE_U8, PS_TYPE_U16, PS_TYPE_U32, PS_TYPE_U64,
     
    5656    psLogMsg(__func__,PS_LOG_INFO,"#546 - psImageAlloc shall allocate memory for a psImage structure");
    5757
    58     for (unsigned int t=0;t<types;t++) {
     58    for (psU32 t=0;t<types;t++) {
    5959        psLogMsg(__func__,PS_LOG_INFO,"Testing psImage with type %xh",type[t]);
    6060
    61         for (unsigned int i=0;i<sizes;i++) {
     61        for (psU32 i=0;i<sizes;i++) {
    6262
    6363            if (numRows[i] == 0 || numCols[i] == 0) {
     
    112112            switch (type[t]) {
    113113            case PS_TYPE_U16: {
    114                     unsigned int rows = numRows[i];
    115                     unsigned int cols = numCols[i];
    116 
    117                     for (int r=0;r<rows;r++) {
    118                         for (int c=0;c<cols;c++) {
     114                    psU32 rows = numRows[i];
     115                    psU32 cols = numCols[i];
     116
     117                    for (psS32 r=0;r<rows;r++) {
     118                        for (psS32 c=0;c<cols;c++) {
    119119                            image->data.U16[r][c] = 2*c+r;
    120120                        }
    121121                    }
    122                     for (int r=0;r<rows;r++) {
    123                         for (int c=0;c<cols;c++) {
     122                    for (psS32 r=0;r<rows;r++) {
     123                        for (psS32 c=0;c<cols;c++) {
    124124                            if (image->data.U16[r][c] != 2*c+r) {
    125125                                psError(__func__,"Could not set all pixels in uint16 image at (%d,%d)",c,r);
     
    132132                break;
    133133            case PS_TYPE_F32: {
    134                     unsigned int rows = numRows[i];
    135                     unsigned int cols = numCols[i];
    136 
    137                     for (int r=0;r<rows;r++) {
    138                         for (int c=0;c<cols;c++) {
     134                    psU32 rows = numRows[i];
     135                    psU32 cols = numCols[i];
     136
     137                    for (psS32 r=0;r<rows;r++) {
     138                        for (psS32 c=0;c<cols;c++) {
    139139                            image->data.F32[r][c] = 2.0f*c+r;
    140140                        }
    141141                    }
    142                     for (int r=0;r<rows;r++) {
    143                         for (int c=0;c<cols;c++) {
     142                    for (psS32 r=0;r<rows;r++) {
     143                        for (psS32 c=0;c<cols;c++) {
    144144                            if (fabsf(image->data.F32[r][c] - (2.0f*c+r)) > FLT_EPSILON) {
    145145                                psError(__func__,"Could not set all pixels in float image at (%d,%d)",c,r);
     
    152152                break;
    153153            case PS_TYPE_F64: {
    154                     unsigned int rows = numRows[i];
    155                     unsigned int cols = numCols[i];
    156 
    157                     for (int r=0;r<rows;r++) {
    158                         for (int c=0;c<cols;c++) {
     154                    psU32 rows = numRows[i];
     155                    psU32 cols = numCols[i];
     156
     157                    for (psS32 r=0;r<rows;r++) {
     158                        for (psS32 c=0;c<cols;c++) {
    159159                            image->data.F64[r][c] = 2.0f*c+r;
    160160                        }
    161161                    }
    162                     for (int r=0;r<rows;r++) {
    163                         for (int c=0;c<cols;c++) {
     162                    for (psS32 r=0;r<rows;r++) {
     163                        for (psS32 c=0;c<cols;c++) {
    164164                            if (fabs(image->data.F64[r][c] - (2.0f*c+r)) > DBL_EPSILON) {
    165165                                psError(__func__,"Could not set all pixels in double image at (%d,%d)",c,r);
     
    172172                break;
    173173            case PS_TYPE_C32: {
    174                     unsigned int rows = numRows[i];
    175                     unsigned int cols = numCols[i];
    176 
    177                     for (int r=0;r<rows;r++) {
    178                         for (int c=0;c<cols;c++) {
     174                    psU32 rows = numRows[i];
     175                    psU32 cols = numCols[i];
     176
     177                    for (psS32 r=0;r<rows;r++) {
     178                        for (psS32 c=0;c<cols;c++) {
    179179                            image->data.C32[r][c] = r + I * c;
    180180                        }
    181181                    }
    182                     for (int r=0;r<rows;r++) {
    183                         for (int c=0;c<cols;c++) {
     182                    for (psS32 r=0;r<rows;r++) {
     183                        for (psS32 c=0;c<cols;c++) {
    184184                            if (fabsf(crealf(image->data.C32[r][c]) - r) > FLT_EPSILON ||
    185185                                    fabsf(cimagf(image->data.C32[r][c]) - c) > FLT_EPSILON ) {
     
    193193                break;
    194194            case PS_TYPE_PTR: {
    195                     unsigned int rows = numRows[i];
    196                     unsigned int cols = numCols[i];
     195                    psU32 rows = numRows[i];
     196                    psU32 cols = numCols[i];
    197197                    psImage* temp = psImageAlloc(1,1,PS_TYPE_F32);
    198198
    199                     for (int r=0;r<rows;r++) {
    200                         for (int c=0;c<cols;c++) {
     199                    for (psS32 r=0;r<rows;r++) {
     200                        for (psS32 c=0;c<cols;c++) {
    201201                            image->data.PTR[r][c] = psMemIncrRefCounter(temp);
    202202                        }
    203203                    }
    204                     for (int r=0;r<rows;r++) {
    205                         for (int c=0;c<cols;c++) {
     204                    for (psS32 r=0;r<rows;r++) {
     205                        for (psS32 c=0;c<cols;c++) {
    206206                            if (image->data.PTR[r][c] != temp) {
    207207                                psError(__func__, "Could not set pixel in pointer image at (%d,%d): %x %x",
     
    218218            default: {
    219219                    // ignore type and just use as byte bucket.
    220                     unsigned int rows = numRows[i];
    221                     unsigned int cols = numCols[i]*PSELEMTYPE_SIZEOF(type[t]);
    222 
    223                     for (int r=0;r<rows;r++) {
    224                         for (int c=0;c<cols;c++) {
     220                    psU32 rows = numRows[i];
     221                    psU32 cols = numCols[i]*PSELEMTYPE_SIZEOF(type[t]);
     222
     223                    for (psS32 r=0;r<rows;r++) {
     224                        for (psS32 c=0;c<cols;c++) {
    225225                            image->data.U8[r][c] = (uint8_t)(r + c);
    226226                        }
    227227                    }
    228                     for (int r=0;r<rows;r++) {
    229                         for (int c=0;c<cols;c++) {
     228                    for (psS32 r=0;r<rows;r++) {
     229                        for (psS32 c=0;c<cols;c++) {
    230230                            if (image->data.U8[r][c] != (uint8_t)(r + c)) {
    231231                                psError(__func__,"Could not set all pixels in image (type=%d) at (%d,%d)",
     
    253253}
    254254
    255 int testImageCopy(void)
     255psS32 testImageCopy(void)
    256256{
    257257    psImage* img = NULL;
     
    259259    psImage* img3 = NULL;
    260260    psImage* img4 = NULL;
    261     unsigned int c = 128;
    262     unsigned int r = 256;
     261    psU32 c = 128;
     262    psU32 r = 256;
    263263
    264264    img = psImageAlloc(c,r,PS_TYPE_F32);
     
    296296        return 4;
    297297    }
    298     for (unsigned int row=0;row<r;row++) {
     298    for (psU32 row=0;row<r;row++) {
    299299        psF32* imgInRow = img->data.F32[row];
    300300        psF32* imgOutRow = img4->data.F32[row];
     
    324324        return 2; \
    325325    } \
    326     for (unsigned int row=0;row<r;row++) { \
     326    for (psU32 row=0;row<r;row++) { \
    327327        ps##IN* imgRow = img->data.IN[row]; \
    328328        ps##OUT* img2Row = img2->data.OUT[row]; \
    329         for (unsigned int col=0;col<c;col++) { \
     329        for (psU32 col=0;col<c;col++) { \
    330330            if (abs(imgRow[col] - (ps##IN)(row+col)) > 0.5) { \
    331331                psError(__func__,"Input image was changed at %d,%d!", \
  • trunk/psLib/test/image/tst_psImageConvolve.c

    r2068 r2204  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-13 01:22:38 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-27 00:57:33 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2020#include "psType.h"
    2121
    22 static int testKernelAlloc(void);
    23 static int testKernelGenerate(void);
    24 //static int testImageConvolve(void);
     22static psS32 testKernelAlloc(void);
     23static psS32 testKernelGenerate(void);
     24//static psS32 testImageConvolve(void);
    2525
    2626testDescription tests[] = {
     
    3131                          };
    3232
    33 int main(int argc, char* argv[])
     33psS32 main(psS32 argc, char* argv[])
    3434{
    3535    psLogSetLevel(PS_LOG_INFO);
     
    3838}
    3939
    40 static int testKernelAlloc(void)
     40static psS32 testKernelAlloc(void)
    4141{
    42     int numCases = 4;
    43     int xMin[] = { -5,  0,-10,  5};
    44     int xMax[] = {  0,  5, -5, 10};
    45     int yMin[] = { -4,  0, -8,  4};
    46     int yMax[] = {  0,  4, -4,  8};
    47     int i;
     42    psS32 numCases = 4;
     43    psS32 xMin[] = { -5,  0,-10,  5};
     44    psS32 xMax[] = {  0,  5, -5, 10};
     45    psS32 yMin[] = { -4,  0, -8,  4};
     46    psS32 yMax[] = {  0,  4, -4,  8};
     47    psS32 i;
    4848    psKernel* k;
    4949
     
    7373        }
    7474
    75         for (int j=yMin[i]; j<yMax[i]; j++) {
     75        for (psS32 j=yMin[i]; j<yMax[i]; j++) {
    7676            if (k->kernel[j]+xMin[i] != k->image->data.PS_TYPE_KERNEL_DATA[j-yMin[i]]) {
    7777                psError(__func__,"The kernel pointer was set wrong for row %d.",
     
    115115}
    116116
    117 static int testKernelGenerate(void)
     117static psS32 testKernelGenerate(void)
    118118{
    119     int size = 4;
    120     int t[] = { 1, 2, 8, 10 };
    121     int x[] = { 0, 1, 0, -1 };
    122     int y[] = { 2, 1, -1, -2 };
     119    psS32 size = 4;
     120    psS32 t[] = { 1, 2, 8, 10 };
     121    psS32 x[] = { 0, 1, 0, -1 };
     122    psS32 y[] = { 2, 1, -1, -2 };
    123123    psKernelType sum;
    124124
     
    127127    psVector* tVec = psVectorAlloc(size,PS_TYPE_U32);
    128128
    129     for (int i = 0; i < size; i++) {
     129    for (psS32 i = 0; i < size; i++) {
    130130        xVec->data.U32[i] = x[i];
    131131        yVec->data.U32[i] = y[i];
     
    148148
    149149    sum = 0.0;
    150     for (int y = result->yMin; y <= result->yMax; y++) {
    151         for (int x = result->xMin; x <= result->xMax; x++) {
     150    for (psS32 y = result->yMin; y <= result->yMax; y++) {
     151        for (psS32 x = result->xMin; x <= result->xMax; x++) {
    152152            sum += result->kernel[y][x];
    153153        }
     
    182182    tVec = psVectorAlloc(size,PS_TYPE_S16);
    183183
    184     for (int i = 0; i < size; i++) {
     184    for (psS32 i = 0; i < size; i++) {
    185185        xVec->data.S16[i] = x[i];
    186186        yVec->data.S16[i] = y[i];
     
    203203
    204204    sum = 0.0;
    205     for (int y = result->yMin; y <= result->yMax; y++) {
    206         for (int x = result->xMin; x <= result->xMax; x++) {
     205    for (psS32 y = result->yMin; y <= result->yMax; y++) {
     206        for (psS32 x = result->xMin; x <= result->xMax; x++) {
    207207            sum += result->kernel[y][x];
    208208        }
     
    236236    tVec = psVectorAlloc(size,PS_TYPE_F32);
    237237
    238     for (int i = 0; i < size; i++) {
     238    for (psS32 i = 0; i < size; i++) {
    239239        xVec->data.F32[i] = x[i]+0.1;
    240240        yVec->data.F32[i] = y[i]+0.2;
     
    291291
    292292/*
    293 static int testImageConvolve(void)
     293static psS32 testImageConvolve(void)
    294294{
    295     const int r = 200;
    296     const int c = 300;
    297     int sum;
     295    const psS32 r = 200;
     296    const psS32 c = 300;
     297    psS32 sum;
    298298 
    299299    // approximate a normalized gaussian kernel.
     
    312312    psKernel* nsk = psKernelAlloc(0,2,0,2);
    313313    sum = 0.0;
    314     for (int i=0;i<2;i++) {
    315         for (int j=0;j<2;j++) {
     314    for (psS32 i=0;i<2;i++) {
     315        for (psS32 j=0;j<2;j++) {
    316316            nsk->kernel[i][j] = i+j;
    317317            sum = i+j;
    318318        }
    319319    }
    320     for (int i=0;i<2;i++) {
    321         for (int j=0;j<2;j++) {
     320    for (psS32 i=0;i<2;i++) {
     321        for (psS32 j=0;j<2;j++) {
    322322            nsk->kernel[i][j] /= sum;
    323323        }
     
    356356 
    357357    // test values
    358     for (int i=-1;i<1;i++) {
    359         for (int j=-1;j<1;j++) {
     358    for (psS32 i=-1;i<1;i++) {
     359        for (psS32 j=-1;j<1;j++) {
    360360            if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
    361361                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
     
    423423    psImageWriteSection(out2,0,0,0,NULL,0,"out2.fits");
    424424    // test values
    425     for (int i=-1;i<1;i++) {
    426         for (int j=-1;j<1;j++) {
     425    for (psS32 i=-1;i<1;i++) {
     426        for (psS32 j=-1;j<1;j++) {
    427427            if (fabsf(out->data.F32[r/2+i][c/2+j] - g->kernel[i][j]) > 0.0001) {
    428428                psError(__func__,"Convolved image wrong at %d,%d.  Value is %g, expected %g.",
  • trunk/psLib/test/image/tst_psImageExtraction.c

    r2156 r2204  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2004-10-15 20:00:56 $
     8*  @version $Revision: 1.18 $ $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
     
    1818#include "psType.h"
    1919
    20 static int testImageSlice(void);
    21 static int testImageSubset(void);
    22 static int testImageSubsection(void);
    23 static int testImageTrim(void);
    24 static int testImageCut(void);
    25 static int testImageRadialCut(void);
     20static psS32 testImageSlice(void);
     21static psS32 testImageSubset(void);
     22static psS32 testImageSubsection(void);
     23static psS32 testImageTrim(void);
     24static psS32 testImageCut(void);
     25static psS32 testImageRadialCut(void);
    2626
    2727
     
    3737                          };
    3838
    39 int main( int argc, char* argv[] )
     39psS32 main( psS32 argc, char* argv[] )
    4040{
    4141    return ! runTestSuite( stderr, "psImage", tests, argc, argv );
    4242}
    4343
    44 int testImageSlice(void)
     44psS32 testImageSlice(void)
    4545{
    46     const int r = 200;
    47     const int c = 300;
    48     const int m = r / 2 -1;
    49     const int n = r / 4 -1;
     46    const psS32 r = 200;
     47    const psS32 c = 300;
     48    const psS32 m = r / 2 -1;
     49    const psS32 n = r / 4 -1;
    5050    psVector* out = NULL;
    5151    psImage* image;
     
    6868     */
    6969
    70     for ( int row = 0;row < r;row++ ) {
     70    for ( psS32 row = 0;row < r;row++ ) {
    7171        psMaskType* maskRow = mask->data.PS_TYPE_MASK_DATA[row];
    72         for ( int col = 0;col < c;col++ ) {
     72        for ( psS32 col = 0;col < c;col++ ) {
    7373            maskRow[ col ] = 0;
    7474        }
     
    7777    #define PSIMAGESLICE_TEST1(TYPE,M,N,DIRECTION,TRUTH_SIZE,TRUTHPIX_X,TRUTHPIX_Y,TESTNUM) \
    7878    image = psImageAlloc( c, r, PS_TYPE_##TYPE ); \
    79     for ( int row = 0;row < r;row++ ) { \
     79    for ( psS32 row = 0;row < r;row++ ) { \
    8080        ps##TYPE *imageRow = image->data.TYPE[ row ]; \
    8181        ps##TYPE rowOffset = row * 2; \
    82         for ( int col = 0;col < c;col++ ) { \
     82        for ( psS32 col = 0;col < c;col++ ) { \
    8383            imageRow[ col ] = col + rowOffset; \
    8484        } \
     
    9898    } \
    9999    \
    100     for (int i=0;i<out->n;i++) { \
     100    for (psS32 i=0;i<out->n;i++) { \
    101101        if (fabs(out->data.F64[i]-image->data.TYPE[r/10+TRUTHPIX_Y][c/10+TRUTHPIX_X]) > 1.0/(psF64)r) { \
    102102            psError(__func__,"Improper result at position %d.  Got %g, expected %g",i, \
     
    363363
    364364// #547: psImageSubset shall create child image of a specified size from a parent psImage structure
    365 int testImageSubset(void)
     365psS32 testImageSubset(void)
    366366{
    367367    psImage preSubsetStruct;
     
    370370    psImage* subset2 = NULL;
    371371    psImage* subset3 = NULL;
    372     int c = 128;
    373     int r = 256;
     372    psS32 c = 128;
     373    psS32 r = 256;
    374374
    375375    original = psImageAlloc(c,r,PS_TYPE_U32);
    376     for (int row=0;row<r;row++) {
    377         for (int col=0;col<c;col++) {
     376    for (psS32 row=0;row<r;row++) {
     377        for (psS32 col=0;col<c;col++) {
    378378            original->data.F32[row][col] = row*1000+col;
    379379        }
     
    404404             "row member, if the input psImage structure image contains known values.");
    405405
    406     for (int row=0;row<r/2;row++) {
    407         for (int col=0;col<c/2;col++) {
     406    for (psS32 row=0;row<r/2;row++) {
     407        for (psS32 col=0;col<c/2;col++) {
    408408            if (subset2->data.U32[row][col] != original->data.U32[row+r/4][col+c/4]) {
    409409                psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
     
    596596
    597597// #730: psImageSubsection shall create child image of a specified size from a parent psImage structure
    598 int testImageSubsection(void)
     598psS32 testImageSubsection(void)
    599599{
    600600    psImage* original;
    601601    psImage* subset;
    602     int c = 128;
    603     int r = 256;
    604     int i;
    605     int numRegions = 4;
    606     int x1[] = {  0, 32, 64, 32};
    607     int x2[] = { 32, 64,127, 64};
    608     int y1[] = {  0, 32, 32,128};
    609     int y2[] = { 32, 64, 64,255};
     602    psS32 c = 128;
     603    psS32 r = 256;
     604    psS32 i;
     605    psS32 numRegions = 4;
     606    psS32 x1[] = {  0, 32, 64, 32};
     607    psS32 x2[] = { 32, 64,127, 64};
     608    psS32 y1[] = {  0, 32, 32,128};
     609    psS32 y2[] = { 32, 64, 64,255};
    610610
    611611    original = psImageAlloc(c,r,PS_TYPE_U32);
    612     for (int row=0;row<r;row++) {
    613         for (int col=0;col<c;col++) {
     612    for (psS32 row=0;row<r;row++) {
     613        for (psS32 col=0;col<c;col++) {
    614614            original->data.F32[row][col] = row*1000+col;
    615615        }
     
    664664        }
    665665
    666         int numCols = x2[i]-x1[i]+1;
    667         int numRows = y2[i]-y1[i]+1;
     666        psS32 numCols = x2[i]-x1[i]+1;
     667        psS32 numRows = y2[i]-y1[i]+1;
    668668        if (subset->numCols != numCols || subset->numRows != numRows) {
    669669            psError(__func__,"psImageSubsection output size was not proper(%dx%d, should be %dx%d).",
     
    672672        }
    673673
    674         for (int row=0;row<numRows;row++) {
    675             for (int col=0;col<numCols;col++) {
     674        for (psS32 row=0;row<numRows;row++) {
     675            for (psS32 col=0;col<numCols;col++) {
    676676                if (subset->data.U32[row][col] != original->data.U32[row+y1[i]][col+x1[i]]) {
    677677                    psError(__func__,"psImageSubset output #1 was wrong at %dx%d (%d vs %d).",
     
    751751}
    752752
    753 static int testImageTrim(void)
     753static psS32 testImageTrim(void)
    754754{
    755     int r = 200;
    756     int c = 300;
    757     int qtrR = r/4;
    758     int qtrC = c/4;
    759     int halfR = r/2;
    760     int halfC = c/2;
     755    psS32 r = 200;
     756    psS32 c = 300;
     757    psS32 qtrR = r/4;
     758    psS32 qtrC = c/4;
     759    psS32 halfR = r/2;
     760    psS32 halfC = c/2;
    761761
    762762    psImage* image = psImageAlloc(c,r,PS_TYPE_F32);
    763     for (int row = 0; row < image->numRows; row++) {
    764         for (int col = 0; col < image->numCols; col++) {
     763    for (psS32 row = 0; row < image->numRows; row++) {
     764        for (psS32 col = 0; col < image->numCols; col++) {
    765765            image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f;
    766766        }
     
    792792    }
    793793
    794     for (int row = 0; row < image2->numRows; row++) {
    795         for (int col = 0; col < image2->numCols; col++) {
     794    for (psS32 row = 0; row < image2->numRows; row++) {
     795        for (psS32 col = 0; col < image2->numCols; col++) {
    796796            if (fabsf(image2->data.F32[row][col] - image->data.F32[row+qtrR][col+qtrC]) > FLT_EPSILON) {
    797797                psLogMsg(__func__,PS_LOG_ERROR,
     
    830830    }
    831831
    832     for (int row = 0; row < image2->numRows; row++) {
    833         for (int col = 0; col < image2->numCols; col++) {
     832    for (psS32 row = 0; row < image2->numRows; row++) {
     833        for (psS32 col = 0; col < image2->numCols; col++) {
    834834            if (fabsf(image2->data.F32[row][col] -
    835835                      image->data.F32[row+qtrR][col+qtrC]) > FLT_EPSILON) {
     
    869869    }
    870870
    871     for (int row = 0; row < image2->numRows; row++) {
    872         for (int col = 0; col < image2->numCols; col++) {
     871    for (psS32 row = 0; row < image2->numRows; row++) {
     872        for (psS32 col = 0; col < image2->numCols; col++) {
    873873            if (fabsf(image2->data.F32[row][col] -
    874874                      image->data.F32[row+qtrR][col+qtrC]) > FLT_EPSILON) {
     
    10141014}
    10151015
    1016 static int testImageCut(void)
     1016static psS32 testImageCut(void)
    10171017{
    1018     int c = 300;
    1019     int r = 200;
    1020     int numPoints = 15;
     1018    psS32 c = 300;
     1019    psS32 r = 200;
     1020    psS32 numPoints = 15;
    10211021    float startCol[] = { 40,150, 40,  0,280, 40,280, -1,300, 20, 20, 20, 20, 20, 20};
    10221022    float endCol[] =   {240,150,240,299, 40,240, 40,240,240, -1,300,240,240,240,240};
    10231023    float startRow[] = { 20, 10,100,  0, 20,180,180, 10, 10, 10, 10, -1,200, 10, 10};
    10241024    float endRow[] =   {160,180,100,199,160, 10, 10,180,180,180,180,180,180, -1,200};
    1025     bool success[] = {true,true,true,true,true,true,true,false,false,false,false,false,false,false,false};
    1026     unsigned int length = 100;
     1025    psBool success[] = {true,true,true,true,true,true,true,false,false,false,false,false,false,false,false};
     1026    psU32 length = 100;
    10271027
    10281028    psImage* image = psImageAlloc(c,r,PS_TYPE_F32);
    10291029    psImage* mask = psImageAlloc(c,r,PS_TYPE_MASK);
    1030     for (int row = 0; row < image->numRows; row++) {
    1031         for (int col = 0; col < image->numCols; col++) {
     1030    for (psS32 row = 0; row < image->numRows; row++) {
     1031        for (psS32 col = 0; col < image->numCols; col++) {
    10321032            image->data.F32[row][col] = (psF32)col + (psF32)row/1000.0f;
    10331033            if ((row & 0x0F) == 0) {
     
    10421042
    10431043    psVector* result = NULL;
    1044     for (int n = 0; n < numPoints; n++) {
     1044    for (psS32 n = 0; n < numPoints; n++) {
    10451045        psVector* orig = result;
    10461046        if (! success[n]) {
     
    10831083            float deltaCol = (endCol[n]-startCol[n])/(length-1);
    10841084            psF32 truth;
    1085             for (int i = 0; i < length; i++) {
     1085            for (psS32 i = 0; i < length; i++) {
    10861086                float x = (float)startCol[n]+(float)i*deltaCol;
    10871087                float y = (float)startRow[n]+(float)i*deltaRow;
     
    11771177}
    11781178
    1179 static int testImageRadialCut(void)
     1179static psS32 testImageRadialCut(void)
    11801180{
    1181     int c = 300;
    1182     int r = 200;
    1183     int centerX = c/2;
    1184     int centerY = r/2;
     1181    psS32 c = 300;
     1182    psS32 r = 200;
     1183    psS32 centerX = c/2;
     1184    psS32 centerY = r/2;
    11851185    psErr* err = NULL;
    11861186
    11871187    psImage* image = psImageAlloc(c,r,PS_TYPE_F32);
    11881188    psImage* mask = psImageAlloc(c,r,PS_TYPE_MASK);
    1189     for (int row = 0; row < image->numRows; row++) {
    1190         for (int col = 0; col < image->numCols; col++) {
     1189    for (psS32 row = 0; row < image->numRows; row++) {
     1190        for (psS32 col = 0; col < image->numCols; col++) {
    11911191            image->data.F32[row][col] = sqrtf((col-centerX)*(col-centerX)+(row-centerY)*(row-centerY));
    11921192            if ((row & 0x0F) == 0) {
     
    12001200    psStats* stat = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    12011201    psVector* radii = psVectorAlloc(10,PS_TYPE_F32);
    1202     for (int i=0; i < 10; i++) {
     1202    for (psS32 i=0; i < 10; i++) {
    12031203        radii->data.F32[i] = 10+i*10;
    12041204    }
     
    12201220    }
    12211221
    1222     for (int i=0; i < 9; i++) {
     1222    for (psS32 i=0; i < 9; i++) {
    12231223        if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) {
    12241224            psLogMsg(__func__,PS_LOG_ERROR,
     
    12451245    }
    12461246
    1247     for (int i=0; i < 9; i++) {
     1247    for (psS32 i=0; i < 9; i++) {
    12481248        if (fabs(result->data.F64[i] - (15.0+i*10)) > 1) {
    12491249            psLogMsg(__func__,PS_LOG_ERROR,
  • 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;
  • trunk/psLib/test/image/tst_psImageIO.c

    r1942 r2204  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-02 02:09:21 $
     8 *  @version $Revision: 1.10 $ $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
     
    2525#define GENIMAGE(img,c,r,TYP, valueFcn) \
    2626img = psImageAlloc(c,r,PS_TYPE_##TYP); \
    27 for (unsigned int row=0;row<r;row++) { \
     27for (psU32 row=0;row<r;row++) { \
    2828    ps##TYP* imgRow = img->data.TYP[row]; \
    29     for (unsigned int col=0;col<c;col++) { \
     29    for (psU32 col=0;col<c;col++) { \
    3030        imgRow[col] = (ps##TYP)(valueFcn); \
    3131    } \
    3232}
    3333
    34 static int testImageRead(void);
    35 static int testImageWrite(void);
     34static psS32 testImageRead(void);
     35static psS32 testImageWrite(void);
    3636
    3737testDescription tests[] = {
     
    4747                          };
    4848
    49 int main(int argc, char* argv[])
     49psS32 main(psS32 argc, char* argv[])
    5050{
    5151    psLogSetLevel(PS_LOG_INFO);
     
    5757}
    5858
    59 int testImageRead(void)
     59psS32 testImageRead(void)
    6060{
    61     int N = 256;
    62     int M = 128;
     61    psS32 N = 256;
     62    psS32 M = 128;
    6363    psImage* image = NULL;
    6464
     
    127127            return 6; \
    128128        } \
    129         for (unsigned int row = readN0; row < readN; row++) { \
     129        for (psU32 row = readN0; row < readN; row++) { \
    130130            ps##TYP* imgRow = img->data.TYP[row-readN0]; \
    131131            ps##TYP* img2Row = img2->data.TYP[row]; \
    132132            ps##TYP* img3Row = img3->data.TYP[row-readN0]; \
    133133            ps##TYP* img4Row = img4->data.TYP[row]; \
    134             for (unsigned int col = readM0; col < readM; col++) { \
     134            for (psU32 col = readM0; col < readM; col++) { \
    135135                if (fabsf(imgRow[col-readM0]-img2Row[col]) > FLT_EPSILON) { \
    136136                    psError(__func__,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \
     
    155155            return 9; \
    156156        } \
    157         for (unsigned int row = readN0; row < readN; row++) { \
     157        for (psU32 row = readN0; row < readN; row++) { \
    158158            ps##TYP* imgRow = img->data.TYP[row-readN0]; \
    159159            ps##TYP* img2Row = img2->data.TYP[row]; \
    160160            ps##TYP* img3Row = img3->data.TYP[row-readN0]; \
    161161            ps##TYP* img4Row = img4->data.TYP[row]; \
    162             for (unsigned int col = readM0; col < readM; col++) { \
     162            for (psU32 col = readM0; col < readM; col++) { \
    163163                if (fabsf(imgRow[col-readM0]-img2Row[col]) > FLT_EPSILON) { \
    164164                    psError(__func__,"Image changed in I/O operation at %d,%d,0 (%.2f vs %.2f) for %s", \
     
    258258}
    259259
    260 int testImageWrite(void)
     260psS32 testImageWrite(void)
    261261{
    262262    psImage* img = NULL;
    263263    psImage* img2 = NULL;
    264     int m = 64;
    265     int n = 96;
     264    psS32 m = 64;
     265    psS32 n = 96;
    266266
    267267    /*
     
    318318        return 16;
    319319    }
    320     for (unsigned int row=0;row<n;row++) {
     320    for (psU32 row=0;row<n;row++) {
    321321        psF32* imgRow = img->data.F32[row];
    322         for (unsigned int col=0;col<m;col++) {
     322        for (psU32 col=0;col<m;col++) {
    323323            if (fabsf(imgRow[col] - (row+2*col)) > FLT_EPSILON) {
    324324                psError(__func__,"The image values were not overwritten at %d,%d (%.2f vs %.2f)",
  • trunk/psLib/test/image/tst_psImageManip.c

    r2105 r2204  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-10-14 01:22:59 $
     8 *  @version $Revision: 1.30 $ $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
     
    2525#include "psType.h"
    2626
    27 static int testImageClip(void);
    28 static int testImageClipNAN(void);
    29 static int testImageClipComplexRegion(void);
    30 static int testImageOverlay(void);
    31 static int testImageRebin(void);
    32 static int testImageRoll(void);
    33 static int testImageRotate(void);
    34 static int testImageShift(void);
    35 static int testImageShiftCase(int cols, int rows, float colShift,float rowShift);
    36 static int testImageResample(void);
     27static psS32 testImageClip(void);
     28static psS32 testImageClipNAN(void);
     29static psS32 testImageClipComplexRegion(void);
     30static psS32 testImageOverlay(void);
     31static psS32 testImageRebin(void);
     32static psS32 testImageRoll(void);
     33static psS32 testImageRotate(void);
     34static psS32 testImageShift(void);
     35static psS32 testImageShiftCase(psS32 cols, psS32 rows, float colShift,float rowShift);
     36static psS32 testImageResample(void);
    3737
    3838testDescription tests[] = {
     
    4949                          };
    5050
    51 int main(int argc, char* argv[])
     51psS32 main(psS32 argc, char* argv[])
    5252{
    5353    psLogSetLevel(PS_LOG_INFO);
     
    5757
    5858
    59 int testImageClip(void)
     59psS32 testImageClip(void)
    6060{
    6161    psImage* img = NULL;
    62     unsigned int c = 128;
    63     unsigned int r = 256;
     62    psU32 c = 128;
     63    psU32 r = 256;
    6464    psF64 min;
    6565    psF64 max;
    66     int numClipped = 0;
    67     int retVal;
     66    psS32 numClipped = 0;
     67    psS32 retVal;
    6868
    6969    psLogMsg(__func__,PS_LOG_INFO,
     
    9595    #define testImageClipByType(datatype) \
    9696    img = psImageAlloc(c,r,PS_TYPE_##datatype); \
    97     for (unsigned int row=0;row<r;row++) { \
     97    for (psU32 row=0;row<r;row++) { \
    9898        ps##datatype* imgRow = img->data.datatype[row]; \
    99         for (unsigned int col=0;col<c;col++) { \
     99        for (psU32 col=0;col<c;col++) { \
    100100            imgRow[col] = (ps##datatype)(row+col); \
    101101        } \
     
    107107    \
    108108    numClipped = 0; \
    109     for (unsigned int row=0;row<r;row++) { \
     109    for (psU32 row=0;row<r;row++) { \
    110110        ps##datatype* imgRow = img->data.datatype[row]; \
    111         for (unsigned int col=0;col<c;col++) { \
     111        for (psU32 col=0;col<c;col++) { \
    112112            ps##datatype value = (ps##datatype)(row+col); \
    113113            if (value < min) { \
     
    134134    #define testImageClipByComplexType(datatype) \
    135135    img = psImageAlloc(c,r,PS_TYPE_##datatype); \
    136     for (unsigned int row=0;row<r;row++) { \
     136    for (psU32 row=0;row<r;row++) { \
    137137        ps##datatype* imgRow = img->data.datatype[row]; \
    138         for (unsigned int col=0;col<c;col++) { \
     138        for (psU32 col=0;col<c;col++) { \
    139139            imgRow[col] = (ps##datatype)(row+I*col); \
    140140        } \
     
    146146    \
    147147    numClipped = 0; \
    148     for (unsigned int row=0;row<r;row++) { \
     148    for (psU32 row=0;row<r;row++) { \
    149149        ps##datatype* imgRow = img->data.datatype[row]; \
    150         for (unsigned int col=0;col<c;col++) { \
     150        for (psU32 col=0;col<c;col++) { \
    151151            ps##datatype value = row+I*col; \
    152152            if (cabs(value) < min) { \
     
    225225}
    226226
    227 int testImageClipNAN(void)
     227psS32 testImageClipNAN(void)
    228228{
    229229    psImage* img = NULL;
    230     unsigned int c = 128;
    231     unsigned int r = 256;
    232     int numClipped = 0;
    233     int retVal;
     230    psU32 c = 128;
     231    psU32 r = 256;
     232    psS32 numClipped = 0;
     233    psS32 retVal;
    234234
    235235    psLogMsg(__func__,PS_LOG_INFO,
     
    317317}
    318318
    319 int testImageClipComplexRegion(void)
     319psS32 testImageClipComplexRegion(void)
    320320{
    321321    psImage* img = NULL;
    322     unsigned int c = 1024;
    323     unsigned int r = 2048;
    324     int numClipped = 0;
    325     int retVal;
     322    psU32 c = 1024;
     323    psU32 r = 2048;
     324    psS32 numClipped = 0;
     325    psS32 retVal;
    326326
    327327    psLogMsg(__func__,PS_LOG_INFO,
     
    581581}
    582582
    583 int testImageOverlay(void)
     583psS32 testImageOverlay(void)
    584584{
    585585
     
    588588    psImage* img3 = NULL;
    589589    psImage* img4 = NULL;
    590     unsigned int c = 128;
    591     unsigned int r = 256;
    592     int retVal;
     590    psU32 c = 128;
     591    psU32 r = 256;
     592    psS32 retVal;
    593593
    594594    /*
     
    833833}
    834834
    835 static int testImageRebin(void)
     835static psS32 testImageRebin(void)
    836836{
    837837
     
    869869    memset(meanTruthWMask->data.F32[0],0,sizeof(psF32)*4*4); \
    870870    memset(maxTruth->data.F32[0],0,sizeof(psF32)*6*6); \
    871     for (int row = 0; row<16; row++) { \
     871    for (psS32 row = 0; row<16; row++) { \
    872872        ps##DATATYPE* inRow = in->data.DATATYPE[row]; \
    873873        psF32* meanTruthRow = meanTruth->data.F32[row/4]; \
     
    875875        psF32* maxTruthRow = maxTruth->data.F32[row/3]; \
    876876        psU8* maskRow = mask->data.U8[row]; \
    877         for (int col = 0; col<16; col++) { \
     877        for (psS32 col = 0; col<16; col++) { \
    878878            if(col != 15) { \
    879879                maskRow[col] = 0; \
     
    891891        } \
    892892    } \
    893     for (int row = 0; row<4; row++) { \
     893    for (psS32 row = 0; row<4; row++) { \
    894894        psF32* meanTruthRow = meanTruth->data.F32[row]; \
    895895        psF32* meanTruthWMaskRow = meanTruthWMask->data.F32[row]; \
    896         for (int col = 0; col<4; col++) { \
     896        for (psS32 col = 0; col<4; col++) { \
    897897            meanTruthRow[col] /= 16; \
    898898            if ( col == 3 ) { \
     
    915915        return 2; \
    916916    } \
    917     for (int row = 0; row<4; row++) { \
     917    for (psS32 row = 0; row<4; row++) { \
    918918        ps##DATATYPE* outRow = out->data.DATATYPE[row]; \
    919919        psF32* truthRow = meanTruth->data.F32[row]; \
    920         for (int col = 0; col<4; col++) { \
     920        for (psS32 col = 0; col<4; col++) { \
    921921            if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \
    922922                psError(__func__,"psImageRebin didn't produce the proper mean " \
     
    929929    stats.options = PS_STAT_SAMPLE_MEAN; \
    930930    out3 = psImageRebin(NULL,in,mask,1,4,&stats); \
    931     for (int row = 0; row<4; row++) { \
     931    for (psS32 row = 0; row<4; row++) { \
    932932        ps##DATATYPE* outRow = out3->data.DATATYPE[row]; \
    933933        psF32* truthRow = meanTruthWMask->data.F32[row]; \
    934         for ( int col = 0; col<4; col++) { \
    935             if(abs((int)outRow[col]-(int)truthRow[col]) > FLT_EPSILON) { \
     934        for ( psS32 col = 0; col<4; col++) { \
     935            if(abs((psS32)outRow[col]-(psS32)truthRow[col]) > FLT_EPSILON) { \
    936936                psError(__func__,"psImageRebin with mask didn't produce the proper mean " \
    937937                        "result at (%d,%d) [%f vs %f].", \
     
    957957        return 5; \
    958958    } \
    959     for (int row = 0; row<6; row++) { \
     959    for (psS32 row = 0; row<6; row++) { \
    960960        ps##DATATYPE* outRow = out->data.DATATYPE[row]; \
    961961        psF32* truthRow = maxTruth->data.F32[row]; \
    962         for (int col = 0; col<6; col++) { \
     962        for (psS32 col = 0; col<6; col++) { \
    963963            if (fabsf((float)outRow[col]-(float)truthRow[col]) > FLT_EPSILON) { \
    964964                psError(__func__,"psImageRebin didn't produce the proper " \
     
    10821082}
    10831083
    1084 static int testImageRoll(void)
     1084static psS32 testImageRoll(void)
    10851085{
    10861086
     
    10881088    psImage* out;
    10891089    psImage* out2;
    1090     int rows = 64;
    1091     int cols = 64;
    1092     int rows1 = 8;
    1093     int cols1 = 8;
     1090    psS32 rows = 64;
     1091    psS32 cols = 64;
     1092    psS32 rows1 = 8;
     1093    psS32 cols1 = 8;
    10941094
    10951095    /*
     
    11081108
    11091109    in = psImageAlloc(cols,rows,PS_TYPE_F32);
    1110     for (int row=0;row<rows;row++) {
     1110    for (psS32 row=0;row<rows;row++) {
    11111111        psF32* inRow = in->data.F32[row];
    1112         for (int col=0;col<cols;col++) {
     1112        for (psS32 col=0;col<cols;col++) {
    11131113            inRow[col] = (psF32)row+(psF32)col/1000.0f;
    11141114        }
     
    11161116
    11171117    out = psImageRoll(NULL,in,0,0);
    1118     for (int row=0;row<rows;row++) {
     1118    for (psS32 row=0;row<rows;row++) {
    11191119        psF32* inRow = in->data.F32[row];
    11201120        psF32* outRow = out->data.F32[row];
    1121         for (int col=0;col<cols;col++) {
     1121        for (psS32 col=0;col<cols;col++) {
    11221122            if (inRow[col] != outRow[col]) {
    11231123                psError(__func__,"psImageRoll didn't produce expected result "
     
    11301130
    11311131    out2 = psImageRoll(out,in,cols/4,0);
    1132     for (int row=0;row<rows;row++) {
     1132    for (psS32 row=0;row<rows;row++) {
    11331133        psF32* inRow = in->data.F32[row];
    11341134        psF32* outRow = out->data.F32[row];
    1135         for (int col=0;col<cols;col++) {
     1135        for (psS32 col=0;col<cols;col++) {
    11361136            if (inRow[(col+cols/4) % cols] != outRow[col]) {
    11371137                psError(__func__,"psImageRoll didn't produce expected result "
     
    11511151
    11521152    out = psImageRoll(out,in,0,rows/4);
    1153     for (int row=0;row<rows;row++) {
     1153    for (psS32 row=0;row<rows;row++) {
    11541154        psF32* inRow = in->data.F32[(row+rows/4)%rows];
    11551155        psF32* outRow = out->data.F32[row];
    1156         for (int col=0;col<cols;col++) {
     1156        for (psS32 col=0;col<cols;col++) {
    11571157            if (inRow[col] != outRow[col]) {
    11581158                psError(__func__,"psImageRoll didn't produce expected result "
     
    11651165
    11661166    out = psImageRoll(out,in,cols/4,rows/4);
    1167     for (int row=0;row<rows;row++) {
     1167    for (psS32 row=0;row<rows;row++) {
    11681168        psF32* inRow = in->data.F32[(row+rows/4)%rows];
    11691169        psF32* outRow = out->data.F32[row];
    1170         for (int col=0;col<cols;col++) {
     1170        for (psS32 col=0;col<cols;col++) {
    11711171            if (inRow[(col+cols/4) % cols] != outRow[col]) {
    11721172                psError(__func__,"psImageRoll didn't produce expected result "
     
    11791179
    11801180    out = psImageRoll(out,in,-cols/4,0);
    1181     for (int row=0;row<rows;row++) {
     1181    for (psS32 row=0;row<rows;row++) {
    11821182        psF32* inRow = in->data.F32[row];
    11831183        psF32* outRow = out->data.F32[row];
    1184         for (int col=0;col<cols;col++) {
     1184        for (psS32 col=0;col<cols;col++) {
    11851185            if (inRow[(col+(cols-cols/4)) % cols] != outRow[col]) {
    11861186                psError(__func__,"psImageRoll didn't produce expected result "
     
    11931193
    11941194    out = psImageRoll(out,in,0,-rows/4);
    1195     for (int row=0;row<rows;row++) {
     1195    for (psS32 row=0;row<rows;row++) {
    11961196        psF32* inRow = in->data.F32[(row+rows-rows/4)%rows];
    11971197        psF32* outRow = out->data.F32[row];
    1198         for (int col=0;col<cols;col++) {
     1198        for (psS32 col=0;col<cols;col++) {
    11991199            if (inRow[col] != outRow[col]) {
    12001200                psError(__func__,"psImageRoll didn't produce expected result "
     
    12071207
    12081208    out = psImageRoll(out,in,-cols/4,-rows/4);
    1209     for (int row=0;row<rows;row++) {
     1209    for (psS32 row=0;row<rows;row++) {
    12101210        psF32* inRow = in->data.F32[(row+rows-rows/4)%rows];
    12111211        psF32* outRow = out->data.F32[row];
    1212         for (int col=0;col<cols;col++) {
     1212        for (psS32 col=0;col<cols;col++) {
    12131213            if (inRow[(col+cols-cols/4) % cols] != outRow[col]) {
    12141214                psError(__func__,"psImageRoll didn't produce expected result "
     
    12361236    in = psImageAlloc(rows1,cols1,PS_TYPE_##DATATYPE); \
    12371237    \
    1238     for (int row=0;row<rows1;row++) { \
     1238    for (psS32 row=0;row<rows1;row++) { \
    12391239        ps##DATATYPE* inRow = in->data.DATATYPE[row]; \
    1240         for (int col=0;col<cols1;col++) { \
     1240        for (psS32 col=0;col<cols1;col++) { \
    12411241            inRow[col] = (ps##DATATYPE)row+(ps##DATATYPE)col; \
    12421242        } \
     
    12441244    \
    12451245    out = psImageRoll(NULL,in,rows1/4,cols1/4); \
    1246     for (int row=0;row<rows1;row++) { \
     1246    for (psS32 row=0;row<rows1;row++) { \
    12471247        ps##DATATYPE* inRow = in->data.DATATYPE[(row+rows1/4)%rows1]; \
    12481248        ps##DATATYPE* outRow = out->data.DATATYPE[row]; \
    1249         for (int col=0;col<cols1;col++) { \
     1249        for (psS32 col=0;col<cols1;col++) { \
    12501250            if (inRow[(col+cols1/4)%cols1] != outRow[col]) { \
    12511251                psError(__func__,"psImageRoll didn't produce expected result " \
     
    12701270}
    12711271
    1272 int testImageRotate(void)
     1272psS32 testImageRotate(void)
    12731273{
    12741274    /*
     
    13001300    psImage* fBiTruth = NULL;
    13011301    psImage* sBiTruth = NULL;
    1302     int rows = 64;
    1303     int cols = 64;
     1302    psS32 rows = 64;
     1303    psS32 cols = 64;
    13041304    psImage* fImg = psImageAlloc(cols,rows,PS_TYPE_F32);
    13051305    psImage* sImg = psImageAlloc(cols,rows,PS_TYPE_S16);
    13061306    psImage* s32Img = psImageAlloc(cols,rows,PS_TYPE_S32);
    13071307
    1308     for(int row=0;row<rows;row++) {
     1308    for(psS32 row=0;row<rows;row++) {
    13091309        psF32* fRow = fImg->data.F32[row];
    13101310        psS16* sRow = sImg->data.S16[row];
    13111311        psS32* s32Row = s32Img->data.S32[row];
    1312         for (int col=0;col<cols;col++) {
     1312        for (psS32 col=0;col<cols;col++) {
    13131313            fRow[col] = (psF32)(row)+(psF32)(col)/100.0f;
    13141314            sRow[col] = row-2*col;
     
    13361336        ("temp/sBiOut.fits");
    13371337    ;
    1338     int index = 0;
    1339     bool fail = false;
    1340     for (int rot=-180;rot<=180;rot+=45) {
     1338    psS32 index = 0;
     1339    psBool fail = false;
     1340    for (psS32 rot=-180;rot<=180;rot+=45) {
    13411341        psImage* oldOut = fOut;
    13421342        psImage* oldBiOut = fBiOut;
     
    13881388                fail = true;
    13891389            } else {
    1390                 for (int row=0;row<fTruth->numRows;row++) {
     1390                for (psS32 row=0;row<fTruth->numRows;row++) {
    13911391                    psF32* truthRow = fTruth->data.F32[row];
    13921392                    psF32* outRow = fOut->data.F32[row];
    1393                     for (int col=0;col<fTruth->numCols;col++) {
     1393                    for (psS32 col=0;col<fTruth->numCols;col++) {
    13941394                        if (fabsf(truthRow[col]-outRow[col]) > 1) {
    13951395                            psError(__func__,"Float Image mismatch (%f vs %f) at %d,%d.",
     
    14091409            if (sTruth->numRows != sOut->numRows ||
    14101410                    sTruth->numCols != sOut->numCols) {
    1411                 psError(__func__,"Rotated short image size did not match truth "
     1411                psError(__func__,"Rotated psS16 image size did not match truth "
    14121412                        "image for %d deg rotation.",rot);
    14131413                fail = true;
    14141414            } else {
    1415                 for (int row=0;row<sTruth->numRows;row++) {
     1415                for (psS32 row=0;row<sTruth->numRows;row++) {
    14161416                    psS16* truthRow = sTruth->data.S16[row];
    14171417                    psS16* outRow = sOut->data.S16[row];
    1418                     for (int col=0;col<sTruth->numCols;col++) {
     1418                    for (psS32 col=0;col<sTruth->numCols;col++) {
    14191419                        if (fabsf(truthRow[col]-outRow[col]) > 1) {
    14201420                            psError(__func__,"Short Image mismatch (%d vs %d) "
     
    14401440                fail = true;
    14411441            } else {
    1442                 for (int row=0;row<fBiTruth->numRows;row++) {
     1442                for (psS32 row=0;row<fBiTruth->numRows;row++) {
    14431443                    psF32* truthRow = fBiTruth->data.F32[row];
    14441444                    psF32* outRow = fBiOut->data.F32[row];
    1445                     for (int col=0;col<fBiTruth->numCols;col++) {
     1445                    for (psS32 col=0;col<fBiTruth->numCols;col++) {
    14461446                        if (fabsf(truthRow[col]-outRow[col]) > 1) {
    14471447                            psError(__func__,"Float Image mismatch (%f vs %f) at %d,%d. BILINEAR",
     
    14611461            if (sBiTruth->numRows != sBiOut->numRows ||
    14621462                    sBiTruth->numCols != sBiOut->numCols) {
    1463                 psError(__func__,"Rotated short image size did not match truth "
     1463                psError(__func__,"Rotated psS16 image size did not match truth "
    14641464                        "image for %d deg rotation. BILINEAR",rot);
    14651465                fail = true;
    14661466            } else {
    1467                 for (int row=0;row<sBiTruth->numRows;row++) {
     1467                for (psS32 row=0;row<sBiTruth->numRows;row++) {
    14681468                    psS16* truthRow = sBiTruth->data.S16[row];
    14691469                    psS16* outRow = sBiOut->data.S16[row];
    1470                     for (int col=0;col<sBiTruth->numCols;col++) {
     1470                    for (psS32 col=0;col<sBiTruth->numCols;col++) {
    14711471                        if (fabsf(truthRow[col]-outRow[col]) > 1) {
    14721472                            psError(__func__,"Short Image mismatch (%d vs %d) "
     
    15371537}
    15381538
    1539 static int testImageShift(void)
     1539static psS32 testImageShift(void)
    15401540{
    15411541    /* psImageShift:
     
    15581558    */
    15591559
    1560     int retVal=0;
     1560    psS32 retVal=0;
    15611561
    15621562    // integer shift
     
    16271627}
    16281628
    1629 static int testImageShiftCase(int cols,
    1630                               int rows,
    1631                               float colShift,
    1632                               float rowShift)
     1629static psS32 testImageShiftCase(psS32 cols,
     1630                                psS32 rows,
     1631                                float colShift,
     1632                                float rowShift)
    16331633{
    16341634    psImage* fOut = NULL;
     
    16431643    psImage* sBiOut = psImageAlloc(cols,rows,PS_TYPE_S16);
    16441644
    1645     for(int row=0;row<rows;row++) {
     1645    for(psS32 row=0;row<rows;row++) {
    16461646        psF32* fRow = fImg->data.F32[row];
    16471647        psS16* sRow = sImg->data.S16[row];
    1648         for (int col=0;col<cols;col++) {
     1648        for (psS32 col=0;col<cols;col++) {
    16491649            fRow[col] = (psF32)(row)+(psF32)(col)/100.0f;
    16501650            sRow[col] = row-2*col;
     
    16571657    sBiOut = psImageShift(sBiOut, sImg, colShift, rowShift, -1, PS_INTERPOLATE_BILINEAR);
    16581658
    1659     for(int row=0;row<rows;row++) {
     1659    for(psS32 row=0;row<rows;row++) {
    16601660        psF32* fRow = fOut->data.F32[row];
    16611661        psS16* sRow = sOut->data.S16[row];
     
    16631663        psS16* sBiRow = sBiOut->data.S16[row];
    16641664
    1665         for (int col=0;col<cols;col++) {
     1665        for (psS32 col=0;col<cols;col++) {
    16661666            psF32 fValue = psImagePixelInterpolate(fImg,col+colShift,
    16671667                                                   row+rowShift,NULL,0,NAN,PS_INTERPOLATE_FLAT);
     
    17071707}
    17081708
    1709 static int testImageResample(void)
     1709static psS32 testImageResample(void)
    17101710{
    17111711
    1712     int rows = 60;
    1713     int cols = 80;
     1712    psS32 rows = 60;
     1713    psS32 cols = 80;
    17141714    psImage* result = NULL;
    1715     int scale = 4;
     1715    psS32 scale = 4;
    17161716    psErr* err;
    17171717
    17181718    psImage* image = psImageAlloc(cols,rows,PS_TYPE_F32);
    1719     for(int row=0;row<rows;row++) {
     1719    for(psS32 row=0;row<rows;row++) {
    17201720        psF32* imageRow = image->data.F32[row];
    1721         for (int col=0;col<cols;col++) {
     1721        for (psS32 col=0;col<cols;col++) {
    17221722            imageRow[col] = row+2*col;
    17231723        }
     
    17531753
    17541754    psF32 truthValue;
    1755     for(int row=0;row<result->numRows;row++) {
    1756         for (int col=0;col<result->numCols;col++) {
     1755    for(psS32 row=0;row<result->numRows;row++) {
     1756        for (psS32 col=0;col<result->numCols;col++) {
    17571757            truthValue = psImagePixelInterpolate(image,
    17581758                                                 (float)col/(float)scale,(float)row/(float)scale,
  • trunk/psLib/test/image/tst_psImageStats00.c

    r1956 r2204  
    1414#define M 64
    1515
    16 int main()
     16psS32 main()
    1717{
    1818    psHistogram * myHist = NULL;
     
    2020    psImage *tmpImage = NULL;
    2121    psImage *tmpMask = NULL;
    22     int testStatus = true;
    23     int memLeaks = 0;
    24     int nb = 0;
    25     int i = 0;
    26     int j = 0;
    27     int IMAGE_X_SIZE = 0;
    28     int IMAGE_Y_SIZE = 0;
    29     int currentId = 0;
     22    psS32 testStatus = true;
     23    psS32 memLeaks = 0;
     24    psS32 nb = 0;
     25    psS32 i = 0;
     26    psS32 j = 0;
     27    psS32 IMAGE_X_SIZE = 0;
     28    psS32 IMAGE_Y_SIZE = 0;
     29    psS32 currentId = 0;
    3030
    3131    currentId = psMemGetId();
  • trunk/psLib/test/image/tst_psImageStats01.c

    r1944 r2204  
    1515#define M 64
    1616
    17 int main()
     17psS32 main()
    1818{
    1919    psStats * myStats = NULL;
     
    2121    psImage *tmpImage = NULL;
    2222    psImage *tmpMask = NULL;
    23     int testStatus = true;
    24     int memLeaks = 0;
    25     int nb = 0;
    26     int i = 0;
    27     int j = 0;
    28     int IMAGE_X_SIZE = 0;
    29     int IMAGE_Y_SIZE = 0;
    30     int currentId = 0;
     23    psS32 testStatus = true;
     24    psS32 memLeaks = 0;
     25    psS32 nb = 0;
     26    psS32 i = 0;
     27    psS32 j = 0;
     28    psS32 IMAGE_X_SIZE = 0;
     29    psS32 IMAGE_Y_SIZE = 0;
     30    psS32 currentId = 0;
    3131
    3232    currentId = psMemGetId();
  • trunk/psLib/test/image/tst_psImageStats02.c

    r2099 r2204  
    1818#define CHEBY_Y_DIM 8
    1919#define THRESHOLD 10
    20 int main()
     20psS32 main()
    2121{
    2222    psStats * myStats = NULL;
     
    2626    psPolynomial2D *my2DPoly = NULL;
    2727    psPolynomial2D *null2DPoly = NULL;
    28     int testStatus = true;
    29     int memLeaks = 0;
    30     int i = 0;
    31     int j = 0;
    32     int currentId = 0;
     28    psS32 testStatus = true;
     29    psS32 memLeaks = 0;
     30    psS32 i = 0;
     31    psS32 j = 0;
     32    psS32 currentId = 0;
    3333
    3434    currentId = psMemGetId();
  • trunk/psLib/test/image/tst_psImageStats03.c

    r1909 r2204  
    1313#define IMAGE_SIZE 10
    1414
    15 int main()
     15psS32 main()
    1616{
    1717    psImage *tmpImage   = NULL;
    18     int testStatus      = true;
    19     int memLeaks        = 0;
    20     int i               = 0;
    21     int j               = 0;
     18    psS32 testStatus      = true;
     19    psS32 memLeaks        = 0;
     20    psS32 i               = 0;
     21    psS32 j               = 0;
    2222    float pixel         = 0.0;
    2323    float x             = 0.0;
    2424    float y             = 0.0;
    25     int currentId       = psMemGetId();
     25    psS32 currentId       = psMemGetId();
    2626
    2727    /*************************************************************************/
Note: See TracChangeset for help on using the changeset viewer.