IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3302


Ignore:
Timestamp:
Feb 22, 2005, 10:06:24 AM (21 years ago)
Author:
desonia
Message:

* empty log message *

Location:
trunk/psLib/src
Files:
2 edited

Legend:

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

    r3264 r3302  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-02-17 19:26:24 $
     11 *  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-02-22 20:06:24 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5757    }
    5858
    59     // stuff the image data into a psVector struct.
    60     junkData = (psVector *) psAlloc(sizeof(psVector));
    61     junkData->type = in->type;
    62     junkData->nalloc = in->numRows * in->numCols;
    63     junkData->n = junkData->nalloc;
    64     junkData->data.V = in->data.V[0];      // since psImage data is contiguous...
     59    if (in->parent == NULL) {
     60        // stuff the image data into a psVector struct.
     61        junkData = (psVector *) psAlloc(sizeof(psVector));
     62        junkData->type = in->type;
     63        junkData->nalloc = in->numRows * in->numCols;
     64        junkData->n = junkData->nalloc;
     65        junkData->data.V = in->data.V[0];      // since psImage data is contiguous...
     66    } else {
     67        // image not necessarily contiguous
     68        int numRows = in->numRows;
     69        int numCols = in->numCols;
     70        int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
     71
     72        junkData = psVectorAlloc(numRows*numCols, in->type.type);
     73        junkData->n = junkData->nalloc;
     74
     75        psU8* data = junkData->data.V;
     76        for (int row = 0; row < numRows; row++) {
     77            memcpy(data, in->data.V[row], rowSize);
     78            data += rowSize;
     79        }
     80    }
    6581
    6682    if (mask != NULL) {
    67         // stuff the mask data into a psVector struct.
    68         junkMask = psAlloc(sizeof(psVector));
    69         junkMask->type = mask->type;
    70         junkMask->nalloc = mask->numRows * mask->numCols;
    71         junkMask->n = junkMask->nalloc;
    72         junkMask->data.V = mask->data.V[0];
     83        if (mask->parent == NULL) {
     84            // stuff the mask data into a psVector struct.
     85            junkMask = psAlloc(sizeof(psVector));
     86            junkMask->type = mask->type;
     87            junkMask->nalloc = mask->numRows * mask->numCols;
     88            junkMask->n = junkMask->nalloc;
     89            junkMask->data.V = mask->data.V[0];
     90        } else {
     91            // image not necessarily contiguous
     92            int numRows = mask->numRows;
     93            int numCols = mask->numCols;
     94            int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
     95
     96            junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
     97            junkMask->n = junkMask->nalloc;
     98
     99            psU8* data = junkMask->data.V;
     100            for (int row = 0; row < numRows; row++) {
     101                memcpy(data, mask->data.V[row], rowSize);
     102                data += rowSize;
     103            }
     104        }
    73105    }
    74106
  • trunk/psLib/src/imageops/psImageStats.c

    r3264 r3302  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.66 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2005-02-17 19:26:24 $
     11 *  @version $Revision: 1.67 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2005-02-22 20:06:24 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5757    }
    5858
    59     // stuff the image data into a psVector struct.
    60     junkData = (psVector *) psAlloc(sizeof(psVector));
    61     junkData->type = in->type;
    62     junkData->nalloc = in->numRows * in->numCols;
    63     junkData->n = junkData->nalloc;
    64     junkData->data.V = in->data.V[0];      // since psImage data is contiguous...
     59    if (in->parent == NULL) {
     60        // stuff the image data into a psVector struct.
     61        junkData = (psVector *) psAlloc(sizeof(psVector));
     62        junkData->type = in->type;
     63        junkData->nalloc = in->numRows * in->numCols;
     64        junkData->n = junkData->nalloc;
     65        junkData->data.V = in->data.V[0];      // since psImage data is contiguous...
     66    } else {
     67        // image not necessarily contiguous
     68        int numRows = in->numRows;
     69        int numCols = in->numCols;
     70        int rowSize = numCols * (PSELEMTYPE_SIZEOF(in->type.type));
     71
     72        junkData = psVectorAlloc(numRows*numCols, in->type.type);
     73        junkData->n = junkData->nalloc;
     74
     75        psU8* data = junkData->data.V;
     76        for (int row = 0; row < numRows; row++) {
     77            memcpy(data, in->data.V[row], rowSize);
     78            data += rowSize;
     79        }
     80    }
    6581
    6682    if (mask != NULL) {
    67         // stuff the mask data into a psVector struct.
    68         junkMask = psAlloc(sizeof(psVector));
    69         junkMask->type = mask->type;
    70         junkMask->nalloc = mask->numRows * mask->numCols;
    71         junkMask->n = junkMask->nalloc;
    72         junkMask->data.V = mask->data.V[0];
     83        if (mask->parent == NULL) {
     84            // stuff the mask data into a psVector struct.
     85            junkMask = psAlloc(sizeof(psVector));
     86            junkMask->type = mask->type;
     87            junkMask->nalloc = mask->numRows * mask->numCols;
     88            junkMask->n = junkMask->nalloc;
     89            junkMask->data.V = mask->data.V[0];
     90        } else {
     91            // image not necessarily contiguous
     92            int numRows = mask->numRows;
     93            int numCols = mask->numCols;
     94            int rowSize = numCols * (PSELEMTYPE_SIZEOF(mask->type.type));
     95
     96            junkMask = psVectorAlloc(numRows*numCols, mask->type.type);
     97            junkMask->n = junkMask->nalloc;
     98
     99            psU8* data = junkMask->data.V;
     100            for (int row = 0; row < numRows; row++) {
     101                memcpy(data, mask->data.V[row], rowSize);
     102                data += rowSize;
     103            }
     104        }
    73105    }
    74106
Note: See TracChangeset for help on using the changeset viewer.