IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 649


Ignore:
Timestamp:
May 12, 2004, 9:46:52 AM (22 years ago)
Author:
harman
Message:

Initial cut at Eugene's psImage implementation

Location:
trunk/psLib/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImage.c

    r634 r649  
    77 *  @author Ross Harman, MHPCC
    88 *   
    9  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-05-10 22:37:04 $
     9 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-05-12 19:46:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5757psImage *psImageAlloc(int nCols, int nRows, psType type)
    5858{
    59     psImage *image = NULL;
    60 
    61     image = psAlloc(sizeof(psImage));
    62     image->type = type;
     59    int area = 0;
     60    psElemType imageType = 0;
     61    psDimen imageDim = 0;
     62
     63    imageType = type.type;
     64    imageDim =  type.dimen;
     65    area = nCols*nRows;
     66
     67    if(imageDim != PS_DIMEN_IMAGE) {
     68        psError(__func__, " : Line %d - Image dimensionality not PS_DIMEN_IMAGE=3 . Dimensionality: %d\n",
     69                __LINE__, imageDim);
     70        return NULL;
     71    } else if(area <= 0) {
     72        psError(__func__, " : Line %d - Invalid value for number of rows or columns. nRows: %d nCols: %d \n",
     73                __LINE__, nRows, nCols);
     74        return NULL;
     75    }
     76
     77    psImage *image = (psImage *)psAlloc(sizeof(psImage));
     78
     79    switch (type.type) {
     80    case PS_TYPE_CHAR:
     81        image->rows.rows_c = (char **)psAlloc(ny*sizeof(char *));
     82        image->rows.rows_c[0] = (char *)psAlloc(area*sizeof(char));
     83        for(int i = 1; i < ny; i++) {
     84            image->rows.rows_c[i] = &image->rows.rows_c[0][i*nx];
     85        }
     86        break;
     87    case PS_TYPE_SHORT:
     88        image->rows.rows_s = (short **)psAlloc(ny*sizeof(short *));
     89        image->rows.rows_s[0] = (short *)psAlloc(area*sizeof(short));
     90        for(int i = 1; i < ny; i++) {
     91            image->rows.rows_s[i] = &image->rows.rows_s[0][i*nx];
     92        }
     93        break;
     94    case PS_TYPE_INT:
     95        image->rows.rows_i = (int **)psAlloc(ny*sizeof(int *));
     96        image->rows.rows_i[0] = (int *)psAlloc(area*sizeof(int));
     97        for(int i = 1; i < ny; i++) {
     98            image->rows.rows_i[i] = &image->rows.rows_i[0][i*nx];
     99        }
     100        break;
     101    case PS_TYPE_LONG:
     102        image->rows.rows_l = (long **)psAlloc(ny*sizeof(long *));
     103        image->rows.rows_l[0] = (long *)psAlloc(area*sizeof(long));
     104        for(int i = 1; i < ny; i++) {
     105            image->rows.rows_l[i] = &image->rows.rows_l[0][i*nx];
     106        }
     107        break;
     108    case PS_TYPE_UCHAR:
     109        image->rows.rows_uc = (unsigned char **)psAlloc(ny*sizeof(unsigned char *));
     110        image->rows.rows_uc[0] = (unsigned char *)psAlloc(area*sizeof(unsigned char));
     111        for(int i = 1; i < ny; i++) {
     112            image->rows.rows_uc[i] = &image->rows.rows_uc[0][i*nx];
     113        }
     114        break;
     115    case PS_TYPE_USHORT:
     116        image->rows.rows_us = (unsigned short **)psAlloc(ny*sizeof(unsigned short *));
     117        image->rows.rows_us[0] = (unsigned short *)psAlloc(area*sizeof(unsigned short));
     118        for(int i = 1; i < ny; i++) {
     119            image->rows.rows_us[i] = &image->rows.rows_us[0][i*nx];
     120        }
     121        break;
     122    case PS_TYPE_UINT:
     123        image->rows.rows_ui = (unsigned int **)psAlloc(ny*sizeof(unsigned int *));
     124        image->rows.rows_ui[0] = (unsigned int *)psAlloc(area*sizeof(unsigned int));
     125        for(int i = 1; i < ny; i++) {
     126            image->rows.rows_ui[i] = &image->rows.rows_ui[0][i*nx];
     127        }
     128        break;
     129    case PS_TYPE_ULONG:
     130        image->rows.rows_ul = (unsigned long **)psAlloc(ny*sizeof(unsigned long *));
     131        image->rows.rows_ul[0] = (unsigned long *)psAlloc(area*sizeof(unsigned long));
     132        for(int i = 1; i < ny; i++) {
     133            image->rows.rows_ul[i] = &image->rows.rows_ul[0][i*nx];
     134        }
     135        break;
     136    }
     137
     138    image->cols0 = 0;
     139    image->rows0 = 0;
    63140    image->nCols = nCols;
    64141    image->nRows = nRows;
    65     image->col0 = 0;
    66     image->row0 = 0;
     142    image->type = type;
    67143    image->parent = NULL;
    68144    image->nChildren = 0;
    69145    image->children = NULL;
    70 
    71     switch(type.type) {
    72     case PS_TYPE_SHORT:
    73         image->rows.rows_s = psAlloc(nCols*nRows*sizeof(short));
    74         break;
    75     case PS_TYPE_INT:
    76         image->rows.rows_i = psAlloc(nCols*nRows*sizeof(int));
    77         break;
    78     case PS_TYPE_LONG:
    79         image->rows.rows_l = psAlloc(nCols*nRows*sizeof(long));
    80         break;
    81     case PS_TYPE_USHORT:
    82         image->rows.rows_us = psAlloc(nCols*nRows*sizeof(unsigned short));
    83         break;
    84     case PS_TYPE_UINT:
    85         image->rows.rows_ui = psAlloc(nCols*nRows*sizeof(unsigned int));
    86         break;
    87     case PS_TYPE_ULONG:
    88         image->rows.rows_ul = psAlloc(nCols*nRows*sizeof(unsigned long));
    89         break;
    90     case PS_TYPE_FLOAT:
    91         image->rows.rows_f = psAlloc(nCols*nRows*sizeof(float));
    92         break;
    93     case PS_TYPE_DOUBLE:
    94         image->rows.rows_d = psAlloc(nCols*nRows*sizeof(double));
    95         break;
    96     case PS_TYPE_COMPLEX:
    97         image->rows.rows_cf = psAlloc(nCols*nRows*sizeof(complex float));
    98         break;
    99     default:
    100         psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, type.type);
    101     }
    102146
    103147    return image;
  • trunk/psLib/src/image/psImage.h

    r633 r649  
    77 *  @author Ross Harman, MHPCC
    88 *   
    9  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-05-10 20:20:42 $
     9 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-05-12 19:46:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040    int col0;                       ///< Row position relative to parent.
    4141    int row0;                       ///< Column position relative to parent.
     42
    4243    union {
    43         short **rows_s;             ///< Pointers to short integer data.
    44         int **rows_i;               ///< Pointers to integer data.
    45         long **rows_l ;             ///< Pointers to long integer data.
    46         unsigned short **rows_us;   ///< Pointers to unsigned short integer data.
    47         unsigned int **rows_ui;     ///< Pointers to unsigned integer data.
    48         unsigned long **rows_ul;    ///< Pointers to unsigned long integer data.
    49         float **rows_f;             ///< Pointers to floating point data.
    50         double **rows_d;            ///< Pointers to double precision data.
    51         complex float **rows_cf;    ///< Pointers to complex floating point data.
     44        char **rowsC                ///< Pointers to char integer data.
     45        short **rowsS;              ///< Pointers to short integer data.
     46        int **rowsI;                ///< Pointers to integer data.
     47        long **rowsL ;              ///< Pointers to long integer data.
     48        unsigned char **rowsUC;    ///< Pointers to unsigned char integer data.
     49        unsigned short **rowsUS;    ///< Pointers to unsigned short integer data.
     50        unsigned int **rowsUI;      ///< Pointers to unsigned integer data.
     51        unsigned long **rowsUL;     ///< Pointers to unsigned long integer data.
     52        float **rowsF;              ///< Pointers to floating point data.
     53        double **rowsD;             ///< Pointers to double precision data.
     54        complex float **rowsCF;     ///< Pointers to complex floating point data.
    5255    } rows;                         ///< Union for data types.
    5356    struct psImage *parent;         ///< Parent, if a subimage.
  • trunk/psLib/src/mathtypes/psImage.c

    r634 r649  
    77 *  @author Ross Harman, MHPCC
    88 *   
    9  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-05-10 22:37:04 $
     9 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-05-12 19:46:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5757psImage *psImageAlloc(int nCols, int nRows, psType type)
    5858{
    59     psImage *image = NULL;
    60 
    61     image = psAlloc(sizeof(psImage));
    62     image->type = type;
     59    int area = 0;
     60    psElemType imageType = 0;
     61    psDimen imageDim = 0;
     62
     63    imageType = type.type;
     64    imageDim =  type.dimen;
     65    area = nCols*nRows;
     66
     67    if(imageDim != PS_DIMEN_IMAGE) {
     68        psError(__func__, " : Line %d - Image dimensionality not PS_DIMEN_IMAGE=3 . Dimensionality: %d\n",
     69                __LINE__, imageDim);
     70        return NULL;
     71    } else if(area <= 0) {
     72        psError(__func__, " : Line %d - Invalid value for number of rows or columns. nRows: %d nCols: %d \n",
     73                __LINE__, nRows, nCols);
     74        return NULL;
     75    }
     76
     77    psImage *image = (psImage *)psAlloc(sizeof(psImage));
     78
     79    switch (type.type) {
     80    case PS_TYPE_CHAR:
     81        image->rows.rows_c = (char **)psAlloc(ny*sizeof(char *));
     82        image->rows.rows_c[0] = (char *)psAlloc(area*sizeof(char));
     83        for(int i = 1; i < ny; i++) {
     84            image->rows.rows_c[i] = &image->rows.rows_c[0][i*nx];
     85        }
     86        break;
     87    case PS_TYPE_SHORT:
     88        image->rows.rows_s = (short **)psAlloc(ny*sizeof(short *));
     89        image->rows.rows_s[0] = (short *)psAlloc(area*sizeof(short));
     90        for(int i = 1; i < ny; i++) {
     91            image->rows.rows_s[i] = &image->rows.rows_s[0][i*nx];
     92        }
     93        break;
     94    case PS_TYPE_INT:
     95        image->rows.rows_i = (int **)psAlloc(ny*sizeof(int *));
     96        image->rows.rows_i[0] = (int *)psAlloc(area*sizeof(int));
     97        for(int i = 1; i < ny; i++) {
     98            image->rows.rows_i[i] = &image->rows.rows_i[0][i*nx];
     99        }
     100        break;
     101    case PS_TYPE_LONG:
     102        image->rows.rows_l = (long **)psAlloc(ny*sizeof(long *));
     103        image->rows.rows_l[0] = (long *)psAlloc(area*sizeof(long));
     104        for(int i = 1; i < ny; i++) {
     105            image->rows.rows_l[i] = &image->rows.rows_l[0][i*nx];
     106        }
     107        break;
     108    case PS_TYPE_UCHAR:
     109        image->rows.rows_uc = (unsigned char **)psAlloc(ny*sizeof(unsigned char *));
     110        image->rows.rows_uc[0] = (unsigned char *)psAlloc(area*sizeof(unsigned char));
     111        for(int i = 1; i < ny; i++) {
     112            image->rows.rows_uc[i] = &image->rows.rows_uc[0][i*nx];
     113        }
     114        break;
     115    case PS_TYPE_USHORT:
     116        image->rows.rows_us = (unsigned short **)psAlloc(ny*sizeof(unsigned short *));
     117        image->rows.rows_us[0] = (unsigned short *)psAlloc(area*sizeof(unsigned short));
     118        for(int i = 1; i < ny; i++) {
     119            image->rows.rows_us[i] = &image->rows.rows_us[0][i*nx];
     120        }
     121        break;
     122    case PS_TYPE_UINT:
     123        image->rows.rows_ui = (unsigned int **)psAlloc(ny*sizeof(unsigned int *));
     124        image->rows.rows_ui[0] = (unsigned int *)psAlloc(area*sizeof(unsigned int));
     125        for(int i = 1; i < ny; i++) {
     126            image->rows.rows_ui[i] = &image->rows.rows_ui[0][i*nx];
     127        }
     128        break;
     129    case PS_TYPE_ULONG:
     130        image->rows.rows_ul = (unsigned long **)psAlloc(ny*sizeof(unsigned long *));
     131        image->rows.rows_ul[0] = (unsigned long *)psAlloc(area*sizeof(unsigned long));
     132        for(int i = 1; i < ny; i++) {
     133            image->rows.rows_ul[i] = &image->rows.rows_ul[0][i*nx];
     134        }
     135        break;
     136    }
     137
     138    image->cols0 = 0;
     139    image->rows0 = 0;
    63140    image->nCols = nCols;
    64141    image->nRows = nRows;
    65     image->col0 = 0;
    66     image->row0 = 0;
     142    image->type = type;
    67143    image->parent = NULL;
    68144    image->nChildren = 0;
    69145    image->children = NULL;
    70 
    71     switch(type.type) {
    72     case PS_TYPE_SHORT:
    73         image->rows.rows_s = psAlloc(nCols*nRows*sizeof(short));
    74         break;
    75     case PS_TYPE_INT:
    76         image->rows.rows_i = psAlloc(nCols*nRows*sizeof(int));
    77         break;
    78     case PS_TYPE_LONG:
    79         image->rows.rows_l = psAlloc(nCols*nRows*sizeof(long));
    80         break;
    81     case PS_TYPE_USHORT:
    82         image->rows.rows_us = psAlloc(nCols*nRows*sizeof(unsigned short));
    83         break;
    84     case PS_TYPE_UINT:
    85         image->rows.rows_ui = psAlloc(nCols*nRows*sizeof(unsigned int));
    86         break;
    87     case PS_TYPE_ULONG:
    88         image->rows.rows_ul = psAlloc(nCols*nRows*sizeof(unsigned long));
    89         break;
    90     case PS_TYPE_FLOAT:
    91         image->rows.rows_f = psAlloc(nCols*nRows*sizeof(float));
    92         break;
    93     case PS_TYPE_DOUBLE:
    94         image->rows.rows_d = psAlloc(nCols*nRows*sizeof(double));
    95         break;
    96     case PS_TYPE_COMPLEX:
    97         image->rows.rows_cf = psAlloc(nCols*nRows*sizeof(complex float));
    98         break;
    99     default:
    100         psError(__func__, " : Line %d - Invalid psImage type: %d\n", __LINE__, type.type);
    101     }
    102146
    103147    return image;
  • trunk/psLib/src/mathtypes/psImage.h

    r633 r649  
    77 *  @author Ross Harman, MHPCC
    88 *   
    9  *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-05-10 20:20:42 $
     9 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-05-12 19:46:52 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4040    int col0;                       ///< Row position relative to parent.
    4141    int row0;                       ///< Column position relative to parent.
     42
    4243    union {
    43         short **rows_s;             ///< Pointers to short integer data.
    44         int **rows_i;               ///< Pointers to integer data.
    45         long **rows_l ;             ///< Pointers to long integer data.
    46         unsigned short **rows_us;   ///< Pointers to unsigned short integer data.
    47         unsigned int **rows_ui;     ///< Pointers to unsigned integer data.
    48         unsigned long **rows_ul;    ///< Pointers to unsigned long integer data.
    49         float **rows_f;             ///< Pointers to floating point data.
    50         double **rows_d;            ///< Pointers to double precision data.
    51         complex float **rows_cf;    ///< Pointers to complex floating point data.
     44        char **rowsC                ///< Pointers to char integer data.
     45        short **rowsS;              ///< Pointers to short integer data.
     46        int **rowsI;                ///< Pointers to integer data.
     47        long **rowsL ;              ///< Pointers to long integer data.
     48        unsigned char **rowsUC;    ///< Pointers to unsigned char integer data.
     49        unsigned short **rowsUS;    ///< Pointers to unsigned short integer data.
     50        unsigned int **rowsUI;      ///< Pointers to unsigned integer data.
     51        unsigned long **rowsUL;     ///< Pointers to unsigned long integer data.
     52        float **rowsF;              ///< Pointers to floating point data.
     53        double **rowsD;             ///< Pointers to double precision data.
     54        complex float **rowsCF;     ///< Pointers to complex floating point data.
    5255    } rows;                         ///< Union for data types.
    5356    struct psImage *parent;         ///< Parent, if a subimage.
Note: See TracChangeset for help on using the changeset viewer.