IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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.

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