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_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,
Note: See TracChangeset for help on using the changeset viewer.