IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5089


Ignore:
Timestamp:
Sep 21, 2005, 4:32:00 PM (21 years ago)
Author:
drobbin
Message:

Added psVectorGet/Set and tests. Added prototype for psImageCountPixelMask.

Location:
trunk/psLib
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageStats.c

    r4970 r5089  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.77 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-09-08 00:07:59 $
     11 *  @version $Revision: 1.78 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-09-22 02:32:00 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    250250  Output:
    251251  Internal Data Structures:
    252     chebPolys[i][j] 
    253     sums[i][j]: This will contain the sum of 
     252    chebPolys[i][j]
     253    sums[i][j]: This will contain the sum of
    254254                input->data.F32[x][y] *
    255255                psPolynomial1DEval(
     
    258258                psPolynomial1DEval(
    259259chebPolys[j],
    260 (float) y, 
     260(float) y,
    261261);
    262262        over all pixels (x,y) in the image.
     
    373373  Output:
    374374  Internal Data Structures:
    375     chebPolys[i][j] 
    376     sums[i][j]: This will contain the sum of 
     375    chebPolys[i][j]
     376    sums[i][j]: This will contain the sum of
    377377                input->data.F32[x][y] *
    378378                psPolynomial1DEval(
     
    381381                psPolynomial1DEval(
    382382chebPolys[j],
    383 (float) y, 
     383(float) y,
    384384);
    385385        over all pixels (x,y) in the image.
     
    514514
    515515/*****************************************************************************
    516 XXX: Use static variables for Chebyshev polynomials and scaling factors. 
     516XXX: Use static variables for Chebyshev polynomials and scaling factors.
    517517 *****************************************************************************/
    518518psImage* p_psImageEvalPolynomialCheb(psImage* input,
     
    634634}
    635635
     636// count number of pixels with given mask value
     637long psImageCountPixelMask (psImage *mask,
     638                            psMaskType value)
     639{
     640    long Npixels = 0;
     641
     642    for (long i = 0; i < mask->numRows; i++) {
     643        for (long j = 0; j < mask->numCols; j++) {
     644            if (mask->data.U8[i][j] & value) {
     645                Npixels ++;
     646            }
     647        }
     648    }
     649    return (Npixels);
     650}
     651
  • trunk/psLib/src/imageops/psImageStats.h

    r4970 r5089  
    99*  @author GLG, MHPCC
    1010*
    11 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-09-08 00:07:59 $
     11*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-09-22 02:32:00 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    8585);
    8686
     87long psImageCountPixelMask(
     88    psImage *mask,
     89    psMaskType value
     90);
     91
    8792/// @}
    8893
  • trunk/psLib/src/mathtypes/psVector.c

    r5087 r5089  
    99*  @author Robert DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-09-21 21:37:21 $
     11*  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-09-22 02:32:00 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    746746
    747747#define FUNC_MACRO_VECTOR_CREATE(TYPE) \
    748 static psVector *vectorCreate##TYPE(double lower, double upper, double delta) \
     748static psVector *vectorCreate##TYPE(psVector *input, double lower, double upper, double delta) \
    749749{ \
    750750    \
    751751    int nBin = (upper - lower) / delta; \
    752     psVector *vec = psVectorAlloc(nBin, PS_TYPE_##TYPE); \
     752    psVector *vec = psVectorRecycle(input, nBin, PS_TYPE_##TYPE); \
    753753    for (int i = 0; i < nBin; i++) \
    754754    { \
     
    769769FUNC_MACRO_VECTOR_CREATE(F64)
    770770
    771 psVector *psVectorCreate (double lower,
     771psVector *psVectorCreate (psVector *input,
     772                          double lower,
    772773                          double upper,
    773774                          double delta,
     
    777778    switch (type) {
    778779    case PS_TYPE_S8:
    779         out = vectorCreateS8( lower,  upper, delta);
     780        out = vectorCreateS8(input, lower,  upper, delta);
    780781        break;
    781782    case PS_TYPE_S16:
    782         out = vectorCreateS16(lower, upper, delta);
     783        out = vectorCreateS16(input, lower, upper, delta);
    783784        break;
    784785    case PS_TYPE_S32:
    785         out = vectorCreateS32(lower, upper, delta);
     786        out = vectorCreateS32(input, lower, upper, delta);
    786787        break;
    787788    case PS_TYPE_S64:
    788         out = vectorCreateS64(lower, upper, delta);
     789        out = vectorCreateS64(input, lower, upper, delta);
    789790        break;
    790791    case PS_TYPE_U8:
    791         out = vectorCreateU8(lower, upper, delta);
     792        out = vectorCreateU8(input, lower, upper, delta);
    792793        break;
    793794    case PS_TYPE_U16:
    794         out = vectorCreateU16(lower, upper, delta);
     795        out = vectorCreateU16(input, lower, upper, delta);
    795796        break;
    796797    case PS_TYPE_U32:
    797         out = vectorCreateU32(lower, upper, delta);
     798        out = vectorCreateU32(input, lower, upper, delta);
    798799        break;
    799800    case PS_TYPE_U64:
    800         out = vectorCreateU64(lower, upper, delta);
     801        out = vectorCreateU64(input, lower, upper, delta);
    801802        break;
    802803    case PS_TYPE_F32:
    803         out = vectorCreateF32(lower, upper, delta);
     804        out = vectorCreateF32(input, lower, upper, delta);
    804805        break;
    805806    case PS_TYPE_F64:
    806         out = vectorCreateF64(lower, upper, delta);
     807        out = vectorCreateF64(input, lower, upper, delta);
    807808        break;
    808809    default:
    809810        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psType for Vector Create\n");
    810811    }
    811     /*
    812       for (int i = 0; i < nBin; i++) {
    813         out->data.F64[i] = lower + i * delta;
    814       }
    815     */
    816812    return (out);
    817813}
    818814
     815bool psVectorSet(const psVector *input,
     816                 long position,
     817                 complex value)
     818{
     819    if (input == NULL)
     820        return false;
     821    if (position >= input->n)
     822        return false;
     823    if(position < 0)
     824        position += input->n;
     825
     826    switch (input->type.type) {
     827    case PS_TYPE_U8:
     828        *(psU8*)&input->data.U8[position] = value;
     829        break;
     830    case PS_TYPE_U16:
     831        *(psU16*)&input->data.U16[position] = value;
     832        break;
     833    case PS_TYPE_U32:
     834        *(psU32*)&input->data.U32[position] = value;
     835        break;
     836    case PS_TYPE_U64:
     837        *(psU64*)&input->data.U64[position] = value;
     838        break;
     839    case PS_TYPE_S8:
     840        *(psS8*)&input->data.S8[position] = value;
     841        break;
     842    case PS_TYPE_S16:
     843        *(psS16*)&input->data.S16[position] = value;
     844        break;
     845    case PS_TYPE_S32:
     846        *(psS32*)&input->data.S32[position] = value;
     847        break;
     848    case PS_TYPE_S64:
     849        *(psS64*)&input->data.S64[position] = value;
     850        break;
     851    case PS_TYPE_F32:
     852        *(psF32*)&input->data.F32[position] = value;
     853        break;
     854    case PS_TYPE_F64:
     855        *(psF64*)&input->data.F64[position] = value;
     856        break;
     857    case PS_TYPE_C32:
     858        *(psC32*)&input->data.C32[position] = value;
     859        break;
     860    case PS_TYPE_C64:
     861        *(psC64*)&input->data.C64[position] = value;
     862        break;
     863    default:
     864        psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Invalid psVector Data Type\n");
     865    }
     866
     867    return true;
     868}
     869
     870complex psVectorGet(const psVector *input,
     871                    long position)
     872{
     873    if (input == NULL)
     874        return NAN;
     875    if (position >= input->n) {
     876        return NAN;
     877    }
     878    if(position < 0)
     879        position += input->n;
     880
     881    switch (input->type.type) {
     882    case PS_TYPE_U8:
     883        return input->data.U8[position];
     884        break;
     885    case PS_TYPE_U16:
     886        return input->data.U16[position];
     887        break;
     888    case PS_TYPE_U32:
     889        return input->data.U32[position];
     890        break;
     891    case PS_TYPE_U64:
     892        return input->data.U64[position];
     893        break;
     894    case PS_TYPE_S8:
     895        return input->data.S8[position];
     896        break;
     897    case PS_TYPE_S16:
     898        return input->data.S16[position];
     899        break;
     900    case PS_TYPE_S32:
     901        return input->data.S32[position];
     902        break;
     903    case PS_TYPE_S64:
     904        return input->data.S64[position];
     905        break;
     906    case PS_TYPE_F32:
     907        return input->data.F32[position];
     908        break;
     909    case PS_TYPE_F64:
     910        return input->data.F64[position];
     911        break;
     912    case PS_TYPE_C32:
     913        return input->data.C32[position];
     914        break;
     915    case PS_TYPE_C64:
     916        return input->data.C64[position];
     917        break;
     918    default:
     919        return NAN;
     920    }
     921
     922}
     923
  • trunk/psLib/src/mathtypes/psVector.h

    r5087 r5089  
    1111 *  @author Ross Harman, MHPCC
    1212 *
    13  *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    14  *  @date $Date: 2005-09-21 21:37:21 $
     13 *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
     14 *  @date $Date: 2005-09-22 02:32:00 $
    1515 *
    1616 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    217217 */
    218218psVector *psVectorCreate (
     219    psVector *input,                   ///< Input vector
    219220    double lower,                      ///< lower bound
    220221    double upper,                      ///< upper bound
     
    223224);
    224225
     226/** Sets the value of the input vector at the specified position to value.
     227 *
     228 *  A negative position means index from the end.
     229 *
     230 *  @return bool:       True if successful, otherwise false.
     231 */
     232bool psVectorSet(
     233    const psVector *input,             ///< Input vector to set
     234    long position,                     ///< vector position
     235    complex value                      ///< value to set
     236);
     237
     238/** Returns the value of the input vector at the specified position.
     239 *
     240 *  A negative position means index from the end.
     241 *
     242 *  @return complex:        Value of the input vector at the specified position.
     243 */
     244complex psVectorGet(
     245    const psVector *input,             ///< Input vector from which to get value
     246    long position                      ///< vector position
     247);
     248
    225249/// @}
    226250
  • trunk/psLib/src/types/psMetadata.c

    r5057 r5089  
    1212 *  @author Ross Harman, MHPCC
    1313 *
    14  *  @version $Revision: 1.83 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-09-15 21:22:22 $
     14 *  @version $Revision: 1.84 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-09-22 02:32:00 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    12691269}
    12701270
     1271// we have log levels 1 (Error), 2 (Warning), 3 (Info), 4 (Details), 5 (Minutiae)
     1272// 2 = default, -v = 3, -vv = 4, -vvv = 5
     1273psS32 psLogArguments (int *argc, char **argv)
     1274{
     1275
     1276    int N, level;
     1277
     1278    // default log level is 2
     1279    level = 2;
     1280
     1281    // set in order, so that -vvv overrides -vv overrides -v
     1282    if ((N = psArgumentGet (*argc, argv, "-v"))) {
     1283        psArgumentRemove (N, argc, argv);
     1284        level = 3;
     1285    }
     1286    if ((N = psArgumentGet (*argc, argv, "-vv"))) {
     1287        psArgumentRemove (N, argc, argv);
     1288        level = 4;
     1289    }
     1290    if ((N = psArgumentGet (*argc, argv, "-vvv"))) {
     1291        psArgumentRemove (N, argc, argv);
     1292        level = 5;
     1293    }
     1294
     1295    if ((N = psArgumentGet (*argc, argv, "-logfmt"))) {
     1296        if (*argc < N + 2) {
     1297            psAbort ("psLogArguments", "USAGE: -logfmt (format)");
     1298        }
     1299        psArgumentRemove (N, argc, argv);
     1300        psLogSetFormat (argv[N]); // XXX EAM : this function should return an error if the log format is invalid
     1301        psArgumentRemove (N, argc, argv);
     1302    }
     1303
     1304    // set the level, return the level
     1305    psLogSetLevel (level);
     1306    return (level);
     1307}
     1308
     1309// set trace levels by facility
     1310psS32 psTraceArguments (int *argc, char **argv)
     1311{
     1312
     1313    int N;
     1314
     1315    // argument format is: -trace (facil) (level)
     1316    while ((N = psArgumentGet (*argc, argv, "-trace"))) {
     1317        if (*argc < N + 3) {
     1318            psAbort ("psTraceArguments", "USAGE: -trace (facility) (level)");
     1319        }
     1320        psArgumentRemove (N, argc, argv);
     1321        psTraceSetLevel (argv[N], atoi(argv[N+1]));
     1322        psArgumentRemove (N, argc, argv);
     1323        psArgumentRemove (N, argc, argv);
     1324    }
     1325    if ((N = psArgumentGet (*argc, argv, "-trace-levels"))) {
     1326        psTracePrintLevels ();
     1327        exit (2);
     1328    }
     1329    return (TRUE);
     1330}
     1331
  • trunk/psLib/test/mathtypes/tst_psVector.c

    r5087 r5089  
    1414 *  @author  Ross Harman, MHPCC
    1515 *
    16  *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
    17  *  @date  $Date: 2005-09-21 21:37:21 $
     16 *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
     17 *  @date  $Date: 2005-09-22 02:32:00 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2929static psS32 testVectorInit(void);
    3030static psS32 testVectorCreate(void);
     31static psS32 testVectorGetSet(void);
    3132
    3233testDescription tests[] = {
     
    3637                              {testVectorInit,-4,"psVectorInit",0,false},
    3738                              {testVectorCreate,-5,"psVectorCreate",0,false},
     39                              {testVectorGetSet,-6,"psVectorGet/Set",0,false},
    3840                              {NULL}
    3941                          };
     
    364366    psVector *test = NULL;
    365367    psVector *test2 = NULL;
    366 
    367     test = psVectorCreate(0.0, 10.0, 1.0, PS_TYPE_S32);
    368     test2 = psVectorCreate(0.0, 5.0, 0.5, PS_TYPE_F32);
     368    psVector *input = NULL;
     369    psVector *input2 = psVectorAlloc(5, PS_TYPE_F64);
     370
     371    test = psVectorCreate(input, 0.0, 10.0, 1.0, PS_TYPE_S32);
     372    test2 = psVectorCreate(input2, 0.0, 5.0, 0.5, PS_TYPE_F32);
    369373
    370374    for (int i = 0; i < 10; i++) {
     
    383387}
    384388
     389psS32 testVectorGetSet(void)
     390{
     391    psVector *vec = NULL;
     392    vec = psVectorAlloc(5, PS_TYPE_S32);
     393
     394    if ( !psVectorSet(vec, 0, 10) )
     395        fprintf(stderr, "VectorSet failed to set S32 at position 0\n");
     396    if ( psVectorSet(vec, 10, 10) )
     397        fprintf(stderr, "VectorSet Improperly set S32 at out of range position\n");
     398    if ( !psVectorSet(vec, -1, 4) )
     399        fprintf(stderr, "VectorSet Failed to set S32 at position 4\n");
     400    if ( (psS32)psVectorGet(vec, 0) != 10 )
     401        fprintf(stderr, "VectorGet Failed to return the correct S32 from position 0\n");
     402    if ( (psS32)psVectorGet(vec, -1) != 4 )
     403        fprintf(stderr, "VectorGet Failed to return the correct S32 from tail using -1\n");
     404
     405    psFree(vec);
     406    return 0;
     407}
     408
     409
     410
  • trunk/psLib/test/mathtypes/verified/tst_psVector.stderr

    r5087 r5089  
    5858---> TESTPOINT PASSED (psVector{psVectorCreate} | tst_psVector.c)
    5959
     60/***************************** TESTPOINT ******************************************\
     61*             TestFile: tst_psVector.c                                             *
     62*            TestPoint: psVector{psVectorGet/Set}                                  *
     63*             TestType: Positive                                                   *
     64\**********************************************************************************/
     65
     66
     67---> TESTPOINT PASSED (psVector{psVectorGet/Set} | tst_psVector.c)
     68
Note: See TracChangeset for help on using the changeset viewer.