IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5174


Ignore:
Timestamp:
Sep 28, 2005, 3:15:38 PM (21 years ago)
Author:
drobbin
Message:

Added fxns psImageRow/Col and tests. Updated psList struct to add void *lock.

Location:
trunk/psLib
Files:
11 edited

Legend:

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

    r4544 r5174  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-07-12 19:33:49 $
     10 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-09-29 01:15:38 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2222
    2323#include "psErrorText.h"
     24
     25
     26#define FUNC_MACRO_VECTOR_STORE_ROW(TYPE) \
     27static psVector *vectorStoreRow##TYPE(psVector *vec, const psImage *in, int row) \
     28{ \
     29    \
     30    for (int i = 0; i < in->numCols; i++) \
     31    { \
     32        vec->data.TYPE[i] = in->data.TYPE[i][row]; \
     33    } \
     34    return vec; \
     35} \
     36
     37FUNC_MACRO_VECTOR_STORE_ROW(S8)
     38FUNC_MACRO_VECTOR_STORE_ROW(S16)
     39FUNC_MACRO_VECTOR_STORE_ROW(S32)
     40FUNC_MACRO_VECTOR_STORE_ROW(S64)
     41FUNC_MACRO_VECTOR_STORE_ROW(U8)
     42FUNC_MACRO_VECTOR_STORE_ROW(U16)
     43FUNC_MACRO_VECTOR_STORE_ROW(U32)
     44FUNC_MACRO_VECTOR_STORE_ROW(U64)
     45FUNC_MACRO_VECTOR_STORE_ROW(F32)
     46FUNC_MACRO_VECTOR_STORE_ROW(F64)
     47FUNC_MACRO_VECTOR_STORE_ROW(C32)
     48FUNC_MACRO_VECTOR_STORE_ROW(C64)
     49
     50psVector *psImageRow(psVector *out,
     51                     const psImage *input,
     52                     psU32 row)
     53{
     54    if (input == NULL) {
     55        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
     56        return NULL;
     57    }
     58    if (row >= input->numRows) {
     59        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     60                "Specified row number is out of range for specified image.\n");
     61        return NULL;
     62    }
     63    psVectorRecycle(out, input->numCols, input->type.type);
     64
     65    switch (input->type.type) {
     66    case PS_TYPE_S8:
     67        out = vectorStoreRowS8(out, input, row);
     68        break;
     69    case PS_TYPE_S16:
     70        out = vectorStoreRowS16(out, input, row);
     71        break;
     72    case PS_TYPE_S32:
     73        out = vectorStoreRowS32(out, input, row);
     74        break;
     75    case PS_TYPE_S64:
     76        out = vectorStoreRowS64(out, input, row);
     77        break;
     78    case PS_TYPE_U8:
     79        out = vectorStoreRowU8(out, input, row);
     80        break;
     81    case PS_TYPE_U16:
     82        out = vectorStoreRowU16(out, input, row);
     83        break;
     84    case PS_TYPE_U32:
     85        out = vectorStoreRowU32(out, input, row);
     86        break;
     87    case PS_TYPE_U64:
     88        out = vectorStoreRowU64(out, input, row);
     89        break;
     90    case PS_TYPE_F32:
     91        out = vectorStoreRowF32(out, input, row);
     92        break;
     93    case PS_TYPE_F64:
     94        out = vectorStoreRowF64(out, input, row);
     95        break;
     96    case PS_TYPE_C32:
     97        out = vectorStoreRowC32(out, input, row);
     98        break;
     99    case PS_TYPE_C64:
     100        out = vectorStoreRowC64(out, input, row);
     101        break;
     102    default:
     103        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     104                "Specified psImage has invalid type for this function.\n");
     105        return NULL;
     106    }
     107
     108    return out;
     109}
     110
     111
     112#define FUNC_MACRO_VECTOR_STORE_COL(TYPE) \
     113static psVector *vectorStoreCol##TYPE(psVector *vec, const psImage *in, int col) \
     114{ \
     115    \
     116    for (int i = 0; i < in->numRows; i++) \
     117    { \
     118        vec->data.TYPE[i] = in->data.TYPE[col][i]; \
     119    } \
     120    return vec; \
     121} \
     122
     123FUNC_MACRO_VECTOR_STORE_COL(S8)
     124FUNC_MACRO_VECTOR_STORE_COL(S16)
     125FUNC_MACRO_VECTOR_STORE_COL(S32)
     126FUNC_MACRO_VECTOR_STORE_COL(S64)
     127FUNC_MACRO_VECTOR_STORE_COL(U8)
     128FUNC_MACRO_VECTOR_STORE_COL(U16)
     129FUNC_MACRO_VECTOR_STORE_COL(U32)
     130FUNC_MACRO_VECTOR_STORE_COL(U64)
     131FUNC_MACRO_VECTOR_STORE_COL(F32)
     132FUNC_MACRO_VECTOR_STORE_COL(F64)
     133FUNC_MACRO_VECTOR_STORE_COL(C32)
     134FUNC_MACRO_VECTOR_STORE_COL(C64)
     135
     136
     137psVector *psImageCol(psVector *out,
     138                     const psImage *input,
     139                     psU32 column)
     140{
     141    if (input == NULL) {
     142        psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psImage_IMAGE_NULL);
     143        return NULL;
     144    }
     145    if (column >= input->numRows) {
     146        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     147                "Specified column number is out of range for specified image.\n");
     148        return NULL;
     149    }
     150    psVectorRecycle(out, input->numCols, input->type.type);
     151
     152    switch (input->type.type) {
     153    case PS_TYPE_S8:
     154        out = vectorStoreColS8(out, input, column);
     155        break;
     156    case PS_TYPE_S16:
     157        out = vectorStoreColS16(out, input, column);
     158        break;
     159    case PS_TYPE_S32:
     160        out = vectorStoreColS32(out, input, column);
     161        break;
     162    case PS_TYPE_S64:
     163        out = vectorStoreColS64(out, input, column);
     164        break;
     165    case PS_TYPE_U8:
     166        out = vectorStoreColU8(out, input, column);
     167        break;
     168    case PS_TYPE_U16:
     169        out = vectorStoreColU16(out, input, column);
     170        break;
     171    case PS_TYPE_U32:
     172        out = vectorStoreColU32(out, input, column);
     173        break;
     174    case PS_TYPE_U64:
     175        out = vectorStoreColU64(out, input, column);
     176        break;
     177    case PS_TYPE_F32:
     178        out = vectorStoreColF32(out, input, column);
     179        break;
     180    case PS_TYPE_F64:
     181        out = vectorStoreColF64(out, input, column);
     182        break;
     183    case PS_TYPE_C32:
     184        out = vectorStoreColC32(out, input, column);
     185        break;
     186    case PS_TYPE_C64:
     187        out = vectorStoreColC64(out, input, column);
     188        break;
     189    default:
     190        psError(PS_ERR_BAD_PARAMETER_TYPE, true,
     191                "Specified psImage has invalid type for this function.\n");
     192        return NULL;
     193    }
     194
     195    return out;
     196
     197}
     198
    24199
    25200psVector* psImageSlice(psVector* out,
  • trunk/psLib/src/imageops/psImagePixelExtract.h

    r4590 r5174  
    88*  @author Robert DeSonia, MHPCC
    99*
    10 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-07-21 02:39:57 $
     10*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2005-09-29 01:15:38 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3232    PS_CUT_Y_NEG                       ///< Cut in the y dimension from top down.
    3333} psImageCutDirection;
     34
     35/** Extracts a single complete row from the image and returns it to the
     36 *  provided vector, allocating it if it is NULL.
     37 *
     38 *  @return psVector*:      The row data extracted from psImage input
     39 */
     40psVector *psImageRow(
     41    psVector *out,                     ///< specified vector to return
     42    const psImage *input,              ///< input image
     43    psU32 row                          ///< row number to extract
     44);
     45
     46/** Extracts a single complete column from the image and returns it to the
     47 *  provided vector, allocating it if it is NULL.
     48 *
     49 *  @return psVector*:      The column data extracted from psImage input
     50 */
     51psVector *psImageCol(
     52    psVector *out,                     ///< specified vector to return
     53    const psImage *input,              ///< input image
     54    psU32 column                       ///< column number to extract
     55);
    3456
    3557/** Extract pixels from rectlinear region to a vector (array of floats).
  • trunk/psLib/src/sys/psTrace.h

    r5070 r5174  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.41 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-09-19 22:50:29 $
     11 *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-09-29 01:15:38 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    143143 *  @return FILE*:      File Destination
    144144 */
    145 int psTraceGetDestination();
     145int psTraceGetDestination(void);
    146146
    147147/* \} */// End of SystemGroup Functions
  • trunk/psLib/src/types/psList.c

    r4898 r5174  
    66 *  @author Robert Daniel DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.42 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-08-30 01:14:13 $
     8 *  @version $Revision: 1.43 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-09-29 01:15:38 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3939    }
    4040
    41     pthread_mutex_lock(&list->lock)
    42     ;
     41    pthread_mutex_lock(&list->p_lock);
    4342
    4443    // remove the free function of iterators to avoid double removal from list
     
    5958    }
    6059
    61     pthread_mutex_unlock(&list->lock)
    62     ;
    63 
    64     pthread_mutex_destroy(&list->lock)
    65     ;
     60    pthread_mutex_unlock(&list->p_lock);
     61
     62    pthread_mutex_destroy(&list->p_lock);
    6663
    6764}
     
    8885    int index = iterator->index;
    8986
    90     pthread_mutex_lock(&list->lock)
    91     ;
     87    pthread_mutex_lock(&list->p_lock);
    9288
    9389    if (elem == list->head) {        // head of list?
     
    115111    list->n--;
    116112
    117     pthread_mutex_unlock(&list->lock)
     113    pthread_mutex_unlock(&list->p_lock)
    118114    ;
    119115
     
    139135    psListIteratorAlloc(list,PS_LIST_HEAD,true);
    140136
    141     pthread_mutex_init(&(list->lock), NULL)
    142     ;
     137    pthread_mutex_init(&(list->p_lock), NULL);
    143138
    144139    if (data != NULL) {
     
    322317    psListElem* elem = psAlloc(sizeof(psListElem));
    323318
    324     pthread_mutex_lock(&list->lock)
    325     ;
     319    pthread_mutex_lock(&list->p_lock);
    326320
    327321    // set the new list element's attributes
     
    359353    }
    360354
    361     pthread_mutex_unlock(&list->lock)
    362     ;
     355    pthread_mutex_unlock(&list->p_lock);
    363356
    364357    return true;
     
    397390    psListElem* elem = psAlloc(sizeof(psListElem));
    398391
    399     pthread_mutex_lock(&list->lock)
    400     ;
     392    pthread_mutex_lock(&list->p_lock);
    401393
    402394    // set the new list element's attributes
     
    434426    }
    435427
    436     pthread_mutex_unlock(&list->lock)
    437     ;
     428    pthread_mutex_unlock(&list->p_lock);
    438429
    439430    return true;
  • trunk/psLib/src/types/psList.h

    r4898 r5174  
    77 *  @ingroup LinkedList
    88 *
    9  *  @version $Revision: 1.31 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2005-08-30 01:14:13 $
     9 *  @version $Revision: 1.32 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2005-09-29 01:15:38 $
    1111 *
    1212 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6060    ///< others are user-level iterators created by psListIteratorAlloc.
    6161
    62     pthread_mutex_t lock;              ///< mutex to lock a node during changes
    63 //    void *lock;                        ///< Optional lock for thread safety
     62    pthread_mutex_t p_lock;            ///< mutex to lock a node during changes
     63    void *lock;                        ///< Optional lock for thread safety
    6464}
    6565psList;
     
    7575typedef struct
    7676{
    77 psList* list;                      ///< List iterator to works on
    78 psListElem* cursor;                ///< current cursor position
    79 bool offEnd;                       ///< Iterator off the end?
    80 long index;                         ///< the index number in the list
    81 bool mutable;                      ///< Is it permissible to modify the list?
     77    psList* list;                      ///< List iterator to works on
     78    psListElem* cursor;                ///< current cursor position
     79    bool offEnd;                       ///< Iterator off the end?
     80    long index;                         ///< the index number in the list
     81    bool mutable;                      ///< Is it permissible to modify the list?
    8282}
    8383psListIterator;
  • trunk/psLib/src/types/psMetadata.h

    r5136 r5174  
    1111*  @author Ross Harman, MHPCC
    1212*
    13 *  @version $Revision: 1.65 $ $Name: not supported by cvs2svn $
    14 *  @date $Date: 2005-09-26 21:13:26 $
     13*  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
     14*  @date $Date: 2005-09-29 01:15:38 $
    1515*
    1616*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    136136;
    137137
    138 
    139138/** Checks the type of a particular pointer.
    140139 *
  • trunk/psLib/src/types/psMetadataConfig.c

    r5136 r5174  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-09-26 21:13:26 $
     12*  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-09-29 01:15:38 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5757/** Maximum size of a string */
    5858#define MAX_STRING_LENGTH 256
    59 #define MAXSTR 256
     59#define MAXSTR 2256
    6060
    6161
     
    12281228    psString newString = NULL;
    12291229    psString newStr = NULL;
    1230     char mdString[2048];
     1230    char mdString[16000];
    12311231    psMetadataItem *item = NULL;
    12321232    psMetadataIterator *iter = psMetadataIteratorAlloc(md, PS_LIST_HEAD, NULL);
     
    12421242    while ( (item = psMetadataGetAndIncrement(iter)) ) {
    12431243        type = item->type;
    1244         if ( type == PS_DATA_STRING)
     1244        if ( type == PS_DATA_STRING) {
    12451245            type = PS_DATA_STRING;
    1246         if ( type == PS_DATA_VECTOR)
     1246        }
     1247        if ( type == PS_DATA_VECTOR) {
    12471248            type = PS_DATA_VECTOR;
    1248         if ( type == PS_DATA_TIME)
     1249        }
     1250        if ( type == PS_DATA_TIME) {
    12491251            type = PS_DATA_TIME;
    1250         if ( item->type == PS_DATA_METADATA)
     1252        }
     1253        if ( item->type == PS_DATA_METADATA) {
    12511254            type = PS_DATA_METADATA;
     1255        }
     1256        if (item == NULL) {
     1257            type = PS_DATA_UNKNOWN;
     1258        }
    12521259
    12531260        switch (type) {
     
    14551462        }
    14561463    }
    1457     newString = psStringNCopy(mdString, 2048);
     1464    newString = psStringNCopy(mdString, 16000);
    14581465    psFree(iter);
    14591466    return newString;
  • trunk/psLib/test/imageops/tst_psImagePixelExtract.c

    r4547 r5174  
    66*  @author Robert DeSonia, MHPCC
    77*
    8 *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-07-13 02:47:00 $
     8*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-09-29 01:15:38 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2121static psS32 testImageCut(void);
    2222static psS32 testImageRadialCut(void);
     23static psS32 testImageRowCol(void);
    2324
    2425
     
    2728                              {testImageCut, 555, "psImageCut", 0, false},
    2829                              {testImageRadialCut, 557, "psImageRadialCut", 0, false},
     30                              {testImageRowCol, 559, "psImageRowCol", 0, false},
    2931                              {NULL}
    3032                          };
     
    742744    return 0;
    743745}
     746
     747psS32 testImageRowCol(void)
     748{
     749    psVector *rowcol = NULL;
     750    psVector *empty = NULL;
     751    psImage *image = NULL;
     752    psImage *emptyImage = NULL;
     753
     754    image = psImageAlloc(3, 3, PS_TYPE_F64);
     755    rowcol = psVectorAlloc(3, PS_TYPE_F64);
     756
     757    image->data.F64[0][0] = 666.666;
     758    image->data.F64[1][0] = 66.6;
     759    image->data.F64[2][0] = 6.66;
     760    image->data.F64[0][1] = 6.6;
     761    image->data.F64[1][1] = 6.666;
     762    image->data.F64[2][1] = 66.666;
     763    image->data.F64[0][2] = 666.6;
     764    image->data.F64[1][2] = 666.66;
     765    image->data.F64[2][2] = 66.66;
     766
     767    //Test for error with NULL image
     768    empty = psImageCol(empty, emptyImage, 0);
     769    if (empty != NULL) {
     770        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     771                "psImageCol failed to return NULL for NULL image input.\n");
     772        return 1;
     773    }
     774    //Test for error with Out of Range Row
     775    empty = psImageRow(empty, image, 5);
     776    if (empty != NULL) {
     777        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     778                "psImageRow failed to return NULL for out of range row input.\n");
     779        return 2;
     780    }
     781    rowcol->data.F64[0] = 1.1;
     782    rowcol->data.F64[2] = 2.2;
     783    //Test recycling of non-NULL vector & correct output
     784    rowcol = psImageCol(rowcol, image, 1);
     785    if (rowcol->data.F64[0] != 66.6 && rowcol->data.F64[2] != 666.66) {
     786        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     787                "psImageCol failed to return correct values.\n");
     788        return 3;
     789    }
     790
     791    psFree(rowcol);
     792    psFree(image);
     793    return 0;
     794}
     795
  • trunk/psLib/test/imageops/verified/tst_psImagePixelExtract.stderr

    r4547 r5174  
    146146---> TESTPOINT PASSED (psImage{psImageRadialCut} | tst_psImagePixelExtract.c)
    147147
     148/***************************** TESTPOINT ******************************************\
     149*             TestFile: tst_psImagePixelExtract.c                                  *
     150*            TestPoint: psImage{psImageRowCol}                                     *
     151*             TestType: Positive                                                   *
     152\**********************************************************************************/
     153
     154<DATE><TIME>|<HOST>|E|psImageCol (FILE:LINENO)
     155    Can not operate on a NULL psImage.
     156<DATE><TIME>|<HOST>|E|psImageRow (FILE:LINENO)
     157    Specified row number is out of range for specified image.
     158
     159---> TESTPOINT PASSED (psImage{psImageRowCol} | tst_psImagePixelExtract.c)
     160
  • trunk/psLib/test/mathtypes/tst_psImage.c

    r5101 r5174  
    66 *  @author Robert DeSonia, MHPCC
    77 *
    8  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2005-09-23 00:04:36 $
     8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2005-09-29 01:15:38 $
    1010 *
    1111 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3636                              {testRegion3,793,"psRegionForSquare",0,false},
    3737                              {testImageInit,794,"psImageInit",0,false},
    38                               {testImageGetSet,795,"psImageInit",0,false},
     38                              {testImageGetSet,795,"psImageGetSet",0,false},
    3939                              {NULL}
    4040                          };
  • trunk/psLib/test/mathtypes/verified/tst_psImage.stderr

    r5114 r5174  
    134134/***************************** TESTPOINT ******************************************\
    135135*             TestFile: tst_psImage.c                                              *
    136 *            TestPoint: psImage{psImageInit}                                       *
     136*            TestPoint: psImage{psImageGetSet}                                     *
    137137*             TestType: Positive                                                   *
    138138\**********************************************************************************/
     
    141141    Invalid position.  Position too large
    142142
    143 ---> TESTPOINT PASSED (psImage{psImageInit} | tst_psImage.c)
     143---> TESTPOINT PASSED (psImage{psImageGetSet} | tst_psImage.c)
    144144
Note: See TracChangeset for help on using the changeset viewer.