IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 2:57:34 PM (22 years ago)
Author:
desonia
Message:

converted native C types to ps Types, where practical.

File:
1 edited

Legend:

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

    r2105 r2204  
    99 *  @author Robert DeSonia, MHPCC
    1010 *
    11  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-10-14 01:22:59 $
     11 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-10-27 00:57:31 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2626psImage* imageSubset(psImage* out,
    2727                     psImage* image,
    28                      int col0,
    29                      int row0,
    30                      int col1,
    31                      int row1)
     28                     psS32 col0,
     29                     psS32 row0,
     30                     psS32 col1,
     31                     psS32 row1)
    3232{
    33     unsigned int elementSize;          // size of image element in bytes
    34     unsigned int inputColOffset;       // offset in bytes to first subset pixel in input row
     33    psU32 elementSize;          // size of image element in bytes
     34    psU32 inputColOffset;       // offset in bytes to first subset pixel in input row
    3535
    3636    if (image == NULL || image->data.V == NULL) {
     
    6868        return NULL;
    6969    }
    70     int numRows = row1-row0;
    71     int numCols = col1-col0;
     70    psS32 numRows = row1-row0;
     71    psS32 numCols = col1-col0;
    7272
    7373    elementSize = PSELEMTYPE_SIZEOF(image->type.type);
     
    8282
    8383    // increment the raw data buffer before freeing anything in the 'out'
    84     void* rawData = psMemIncrRefCounter(image->rawDataBuffer);
     84    psPtr rawData = psMemIncrRefCounter(image->rawDataBuffer);
    8585
    8686    if (out != NULL) {
     
    9797    }
    9898
    99     out->data.V = psRealloc(out->data.V,sizeof(void*)*numRows); // resize row pointer array
     99    out->data.V = psRealloc(out->data.V,sizeof(psPtr)*numRows); // resize row pointer array
    100100    *(psType*)&out->type = image->type;
    101     *(unsigned int*)&out->numCols = numCols;
    102     *(unsigned int*)&out->numRows = numRows;
    103     *(int*)&out->row0 = row0;
    104     *(int*)&out->col0 = col0;
     101    *(psU32*)&out->numCols = numCols;
     102    *(psU32*)&out->numRows = numRows;
     103    *(psS32*)&out->row0 = row0;
     104    *(psS32*)&out->col0 = col0;
    105105    out->parent = image;
    106106    out->children = NULL;
     
    111111
    112112    inputColOffset = elementSize * col0;
    113     for (int row = 0; row < numRows; row++) {
     113    for (psS32 row = 0; row < numRows; row++) {
    114114        out->data.V[row] = image->data.U8[row0 + row] + inputColOffset;
    115115    }
    116116
    117117    // add output image as a child of the input image.
    118     int n = 0;
     118    psS32 n = 0;
    119119    psArray* children = image->children;
    120120    if (children == NULL) {
     
    134134
    135135psImage* psImageSubset(psImage* image,
    136                        int col0,
    137                        int row0,
    138                        int col1,
    139                        int row1)
     136                       psS32 col0,
     137                       psS32 row0,
     138                       psS32 col1,
     139                       psS32 row1)
    140140{
    141141    return imageSubset(NULL,image,col0,row0,col1,row1);
     
    145145                           const char* section)
    146146{
    147     int col0;
    148     int col1;
    149     int row0;
    150     int row1;
     147    psS32 col0;
     148    psS32 col1;
     149    psS32 row0;
     150    psS32 row1;
    151151
    152152    // section should be of the form '[col0:col1,row0:row1]'
     
    177177}
    178178
    179 psImage* psImageTrim(psImage* image, int col0, int row0, int col1, int row1)
     179psImage* psImageTrim(psImage* image, psS32 col0, psS32 row0, psS32 col1, psS32 row1)
    180180{
    181181    if (image == NULL || image->data.V == NULL) {
     
    220220    psImageFreeChildren(image);
    221221
    222     unsigned int elementSize = PSELEMTYPE_SIZEOF(image->type.type);
    223     unsigned int numCols = col1-col0;
    224     unsigned int numRows = row1-row0;
    225     unsigned int rowSize = elementSize*numCols;
    226     unsigned int colOffset = elementSize * col0;
     222    psU32 elementSize = PSELEMTYPE_SIZEOF(image->type.type);
     223    psU32 numCols = col1-col0;
     224    psU32 numRows = row1-row0;
     225    psU32 rowSize = elementSize*numCols;
     226    psU32 colOffset = elementSize * col0;
    227227    psU8* imageData = image->rawDataBuffer;
    228     for (int row = row0; row < row1; row++) {
     228    for (psS32 row = row0; row < row1; row++) {
    229229        memmove(imageData,image->data.U8[row] + colOffset,rowSize);
    230230        imageData += rowSize;
    231231    }
    232232
    233     *(unsigned int*)&image->numRows = numRows;
    234     *(unsigned int*)&image->numCols = numCols;
     233    *(psU32*)&image->numRows = numRows;
     234    *(psU32*)&image->numCols = numCols;
    235235
    236236    // XXX: should I really resize the buffers?
    237     image->data.V = psRealloc(image->data.V,sizeof(void*)*numRows);
     237    image->data.V = psRealloc(image->data.V,sizeof(psPtr)*numRows);
    238238    image->rawDataBuffer = psRealloc(image->rawDataBuffer,rowSize*numRows);
    239239
    240240    image->data.V[0] = image->rawDataBuffer;
    241     for (int r = 1; r < numRows; r++) {
     241    for (psS32 r = 1; r < numRows; r++) {
    242242        image->data.U8[r] = image->data.U8[r-1] + rowSize;
    243243    }
     
    250250                       const psImage* restrict in,
    251251                       const psImage* restrict mask,
    252                        unsigned int maskVal,
    253                        int col0,
    254                        int row0,
    255                        int col1,
    256                        int row1,
     252                       psU32 maskVal,
     253                       psS32 col0,
     254                       psS32 row0,
     255                       psS32 col1,
     256                       psS32 row1,
    257257                       psImageCutDirection direction,
    258258                       const psStats* stats)
     
    261261    psStats* myStats;
    262262    psElemType type;
    263     int inRows;
    264     int inCols;
    265     int delta = 1;
     263    psS32 inRows;
     264    psS32 inCols;
     265    psS32 delta = 1;
    266266    psF64* outData;
    267267
     
    349349    *myStats = *stats;
    350350
    351     int numCols = col1-col0;
    352     int numRows = row1-row0;
     351    psS32 numCols = col1-col0;
     352    psS32 numRows = row1-row0;
    353353
    354354    if (direction == PS_CUT_X_POS || direction == PS_CUT_X_NEG) {
     
    380380    case PS_TYPE_##TYPE: { \
    381381            psMaskType* maskVecData = NULL; \
    382             for (int c=col0;c<col1;c++) { \
     382            for (psS32 c=col0;c<col1;c++) { \
    383383                ps##TYPE *imgData = in->data.TYPE[row0] + c; \
    384384                ps##TYPE *imgVecData = imgVec->data.TYPE; \
     
    387387                    maskData = (psMaskType* )(mask->data.V[row0]) + c; \
    388388                } \
    389                 for (int r=row0;r<row1;r++) { \
     389                for (psS32 r=row0;r<row1;r++) { \
    390390                    *(imgVecData++) = *imgData; \
    391391                    imgData += inCols; \
     
    437437        psVector* imgVec = NULL;
    438438        psVector* maskVec = NULL;
    439         int elementSize = PSELEMTYPE_SIZEOF(type);
     439        psS32 elementSize = PSELEMTYPE_SIZEOF(type);
    440440        psU32* outPosition = NULL;
    441441
     
    465465        }
    466466
    467         for (int r = row0; r < row1; r++) {
     467        for (psS32 r = row0; r < row1; r++) {
    468468            // point the vector struct to the
    469469            // data to calculate the stats
    470             imgVec->data.V = (void *)(in->data.U8[r] + col0 * elementSize);
     470            imgVec->data.V = (psPtr )(in->data.U8[r] + col0 * elementSize);
    471471            if (maskVec != NULL) {
    472                 maskVec->data.V = (void *)(mask->data.U8[r] + col0 * sizeof(psMaskType));
     472                maskVec->data.V = (psPtr )(mask->data.U8[r] + col0 * sizeof(psMaskType));
    473473            }
    474474            myStats = psVectorStats(myStats, imgVec, maskVec, maskVal);
     
    503503                     const psImage* in,
    504504                     const psImage* restrict mask,
    505                      unsigned int maskVal,
     505                     psU32 maskVal,
    506506                     float startCol,
    507507                     float startRow,
    508508                     float endCol,
    509509                     float endRow,
    510                      unsigned int nSamples,
     510                     psU32 nSamples,
    511511                     psImageInterpolateMode mode)
    512512{
     
    518518        return NULL;
    519519    }
    520     int numCols = in->numCols;
    521     int numRows = in->numRows;
     520    psS32 numCols = in->numCols;
     521    psS32 numRows = in->numRows;
    522522
    523523    if (nSamples < 2) {
     
    594594case PS_TYPE_##TYPE: { \
    595595        ps##TYPE* outData = out->data.TYPE; \
    596         for (int i = 0; i < nSamples; i++) { \
     596        for (psS32 i = 0; i < nSamples; i++) { \
    597597            float x = startCol + (float)i*dX; \
    598598            float y = startRow + (float)i*dY; \
     
    642642                           const psImage* in,
    643643                           const psImage* restrict mask,
    644                            unsigned int maskVal,
     644                           psU32 maskVal,
    645645                           float centerCol,
    646646                           float centerRow,
     
    659659        return NULL;
    660660    }
    661     int numCols = in->numCols;
    662     int numRows = in->numRows;
     661    psS32 numCols = in->numCols;
     662    psS32 numRows = in->numRows;
    663663
    664664    if (mask != NULL) {
     
    734734
    735735    // size the output vector to proper size.
    736     int numOut = radii->n - 1;
     736    psS32 numOut = radii->n - 1;
    737737    out = psVectorRecycle(out, numOut, PS_TYPE_F64);
    738738    psF64* outData = out->data.F64;
     
    741741    psF32* rSq = rSqVec->data.F32;
    742742
    743     int startRow = centerRow - rSq[numOut];
    744     int endRow = centerRow + rSq[numOut];
    745     int startCol = centerCol - rSq[numOut];
    746     int endCol = centerCol + rSq[numOut];
     743    psS32 startRow = centerRow - rSq[numOut];
     744    psS32 endRow = centerRow + rSq[numOut];
     745    psS32 startCol = centerCol - rSq[numOut];
     746    psS32 endCol = centerCol + rSq[numOut];
    747747
    748748    if (startRow < 0) {
     
    763763
    764764    // Square the radii data
    765     for (int d = 0; d <= numOut; d++) {
     765    for (psS32 d = 0; d <= numOut; d++) {
    766766        rSq[d] *= rSq[d];
    767767    }
     
    770770    psVector** buffer = psAlloc(sizeof(psVector*)*numOut);
    771771    psVector** bufferMask = psAlloc(sizeof(psVector*)*numOut);
    772     for (int lcv = 0; lcv < numOut; lcv++) {
     772    for (psS32 lcv = 0; lcv < numOut; lcv++) {
    773773        // n.b. alloc enough for the data by making the vectors slightly larger
    774774        // than the area of the region of interest.
     
    788788    float dY;
    789789    float dist;
    790     for (int row=startRow; row <= endRow; row++) {
     790    for (psS32 row=startRow; row <= endRow; row++) {
    791791        psF32* inRow = in->data.F32[row];
    792792        psMaskType* maskRow = NULL;
     
    794794            maskRow = mask->data.PS_TYPE_MASK_DATA[row];
    795795        }
    796         for (int col=startCol; col <= endCol; col++) {
     796        for (psS32 col=startCol; col <= endCol; col++) {
    797797            dX = centerCol - (float)col - 0.5f;
    798798            dY = centerRow - (float)row - 0.5f;
    799799            dist = dX*dX+dY*dY;
    800             for (int r = 0; r < numOut; r++) {
     800            for (psS32 r = 0; r < numOut; r++) {
    801801                if (rSq[r] < dist && dist < rSq[r+1]) {
    802                     int n = buffer[r]->n;
     802                    psS32 n = buffer[r]->n;
    803803                    if (n == buffer[r]->nalloc) { // in case buffers already full, expand
    804804                        buffer[r] = psVectorRealloc(buffer[r], n*2);
     
    825825    *myStats = *stats;
    826826
    827     for (int r = 0; r < numOut; r++) {
     827    for (psS32 r = 0; r < numOut; r++) {
    828828        myStats = psVectorStats(myStats,buffer[r], bufferMask[r],maskVal);
    829829        (void)p_psGetStatValue(myStats,&statVal);
     
    833833    psFree(myStats);
    834834
    835     for (int lcv = 0; lcv < numOut; lcv++) {
     835    for (psS32 lcv = 0; lcv < numOut; lcv++) {
    836836        psFree(buffer[lcv]);
    837837        psFree(bufferMask[lcv]);
Note: See TracChangeset for help on using the changeset viewer.