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/psImageManip.c

    r2105 r2204  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-10-14 01:22:59 $
     12 *  @version $Revision: 1.29 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-10-27 00:57:31 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818#include <math.h>                          // for isfinite(), etc.
    1919#include <stdlib.h>
    20 #include <stdbool.h>
    2120#include <string.h>                        // for memcpy, etc.
    2221
     
    2928#include "psImageErrors.h"
    3029
    31 int psImageClip(psImage* input,
    32                 psF64 min,
    33                 psF64 vmin,
    34                 psF64 max,
    35                 psF64 vmax)
     30psS32 psImageClip(psImage* input,
     31                  psF64 min,
     32                  psF64 vmin,
     33                  psF64 max,
     34                  psF64 vmax)
    3635{
    37     int numClipped = 0;
    38     unsigned int numRows;
    39     unsigned int numCols;
     36    psS32 numClipped = 0;
     37    psU32 numRows;
     38    psU32 numCols;
    4039
    4140    if (input == NULL) {
     
    7271                           (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
    7372            } \
    74             for (unsigned int row = 0;row<numRows;row++) { \
     73            for (psU32 row = 0;row<numRows;row++) { \
    7574                ps##type* inputRow = input->data.type[row]; \
    76                 for (unsigned int col = 0; col < numCols; col++) { \
     75                for (psU32 col = 0; col < numCols; col++) { \
    7776                    if ((psF64)inputRow[col] < min) { \
    7877                        inputRow[col] = (ps##type)vmin; \
     
    103102                           (psF64)PS_MIN_##type,(psF64)PS_MAX_##type); \
    104103            } \
    105             for (unsigned int row = 0;row<numRows;row++) { \
     104            for (psU32 row = 0;row<numRows;row++) { \
    106105                ps##type* inputRow = input->data.type[row]; \
    107                 for (unsigned int col = 0; col < numCols; col++) { \
     106                for (psU32 col = 0; col < numCols; col++) { \
    108107                    if (absfcn(inputRow[col]) < min) { \
    109108                        inputRow[col] = (ps##type)vmin; \
     
    144143}
    145144
    146 int psImageClipNaN(psImage* input,
    147                    psF64 value)
     145psS32 psImageClipNaN(psImage* input,
     146                     psF64 value)
    148147{
    149     int numClipped = 0;
    150     unsigned int numRows;
    151     unsigned int numCols;
     148    psS32 numClipped = 0;
     149    psU32 numRows;
     150    psU32 numCols;
    152151
    153152    if (input == NULL) {
     
    161160        #define psImageClipNaNCase(type) \
    162161    case PS_TYPE_##type: \
    163         for (unsigned int row = 0;row<numRows;row++) { \
     162        for (psU32 row = 0;row<numRows;row++) { \
    164163            ps##type* inputRow = input->data.type[row]; \
    165             for (unsigned int col = 0; col < numCols; col++) { \
     164            for (psU32 col = 0; col < numCols; col++) { \
    166165                if (! isfinite(inputRow[col])) { \
    167166                    inputRow[col] = (ps##type)value; \
     
    190189}
    191190
    192 int psImageOverlaySection(psImage* image,
    193                           const psImage* overlay,
    194                           int col0,
    195                           int row0,
    196                           const char *op)
     191psS32 psImageOverlaySection(psImage* image,
     192                            const psImage* overlay,
     193                            psS32 col0,
     194                            psS32 row0,
     195                            const char *op)
    197196{
    198     unsigned int imageNumRows;
    199     unsigned int imageNumCols;
    200     unsigned int overlayNumRows;
    201     unsigned int overlayNumCols;
    202     unsigned int imageRowLimit;
    203     unsigned int imageColLimit;
     197    psU32 imageNumRows;
     198    psU32 imageNumCols;
     199    psU32 overlayNumRows;
     200    psU32 overlayNumCols;
     201    psU32 imageRowLimit;
     202    psU32 imageColLimit;
    204203    psElemType type;
    205204
     
    257256        #define psImageOverlayCase(DATATYPE) \
    258257    case PS_TYPE_##DATATYPE: \
    259         for (unsigned int row=row0;row<imageRowLimit;row++) { \
     258        for (psU32 row=row0;row<imageRowLimit;row++) { \
    260259            ps##DATATYPE* imageRow = image->data.DATATYPE[row]; \
    261260            ps##DATATYPE* overlayRow = overlay->data.DATATYPE[row-row0]; \
    262             for (unsigned int col=col0;col<imageColLimit;col++) { \
     261            for (psU32 col=col0;col<imageColLimit;col++) { \
    263262                switch (*op) { \
    264263                case '+': \
     
    315314}
    316315
    317 int psImageClipComplexRegion(psImage* input,
    318                              psC64 min,
    319                              psC64 vmin,
    320                              psC64 max,
    321                              psC64 vmax)
     316psS32 psImageClipComplexRegion(psImage* input,
     317                               psC64 min,
     318                               psC64 vmin,
     319                               psC64 max,
     320                               psC64 vmax)
    322321{
    323     int numClipped = 0;
    324     unsigned int numRows;
    325     unsigned int numCols;
     322    psS32 numClipped = 0;
     323    psU32 numRows;
     324    psU32 numCols;
    326325    psF64 realMin = creal(min);
    327326    psF64 imagMin = cimag(min);
     
    374373            break; \
    375374        } \
    376         for (unsigned int row = 0;row<numRows;row++) { \
     375        for (psU32 row = 0;row<numRows;row++) { \
    377376            ps##type* inputRow = input->data.type[row]; \
    378             for (unsigned int col = 0; col < numCols; col++) { \
     377            for (psU32 col = 0; col < numCols; col++) { \
    379378                if ( (realfcn(inputRow[col]) > realMax) || (imagfcn(inputRow[col]) > imagMax) ) { \
    380379                    inputRow[col] = (ps##type)vmax; \
     
    411410                      const psImage* restrict mask,
    412411                      psMaskType maskVal,
    413                       unsigned int scale,
     412                      psU32 scale,
    414413                      const psStats* stats)
    415414{
    416     int inRows;
    417     int inCols;
    418     int outRows;
    419     int outCols;
     415    psS32 inRows;
     416    psS32 inCols;
     417    psS32 outRows;
     418    psS32 outCols;
    420419    psVector* vec;                     // vector to hold the values of a single bin.
    421420    psVector* maskVec = NULL;          // vector to hold the mask of a single bin.
     
    491490        ps##type* vecData = vec->data.type; \
    492491        psMaskType* inRowMask = NULL; \
    493         for (int row = 0; row < outRows; row++) { \
     492        for (psS32 row = 0; row < outRows; row++) { \
    494493            outRowData = out->data.type[row]; \
    495             int inCurrentRow = row*scale; \
    496             int inNextRow = (row+1)*scale; \
    497             for (int col = 0; col < outCols; col++) { \
    498                 int inCurrentCol = col*scale; \
    499                 int inNextCol = (col+1)*scale; \
    500                 int n = 0; \
    501                 for (int inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \
     494            psS32 inCurrentRow = row*scale; \
     495            psS32 inNextRow = (row+1)*scale; \
     496            for (psS32 col = 0; col < outCols; col++) { \
     497                psS32 inCurrentCol = col*scale; \
     498                psS32 inNextCol = (col+1)*scale; \
     499                psS32 n = 0; \
     500                for (psS32 inRow = inCurrentRow; inRow < inNextRow && inRow < inRows; inRow++) { \
    502501                    ps##type* inRowData = in->data.type[inRow]; \
    503502                    if (mask != NULL) { \
    504503                        inRowMask = mask->data.PS_TYPE_MASK_DATA[inRow]; \
    505504                    } \
    506                     for (int inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \
     505                    for (psS32 inCol = inCurrentCol; inCol < inNextCol && inCol < inCols; inCol++) { \
    507506                        if (maskData != NULL) { \
    508507                            maskData[n] = inRowMask[inCol]; \
     
    555554psImage* psImageResample(psImage* out,
    556555                         const psImage* in,
    557                          int scale,
     556                         psS32 scale,
    558557                         psImageInterpolateMode mode)
    559558{
    560     int outRows;
    561     int outCols;
     559    psS32 outRows;
     560    psS32 outCols;
    562561    float invScale;
    563562
     
    597596case PS_TYPE_##TYPE: { \
    598597        out = psImageRecycle(out,outCols, outRows, PS_TYPE_##TYPE); \
    599         for (int row=0;row<outRows;row++) { \
     598        for (psS32 row=0;row<outRows;row++) { \
    600599            ps##TYPE* rowData = out->data.TYPE[row]; \
    601600            float inRow = (float)row * invScale; \
    602             for (int col=0;col<outCols;col++) { \
     601            for (psS32 col=0;col<outCols;col++) { \
    603602                rowData[col] = psImagePixelInterpolate(in,(float)col*invScale,inRow,NULL,0,0,mode); \
    604603            } \
     
    637636psImage* psImageRoll(psImage* out,
    638637                     const psImage* in,
    639                      int dx,
    640                      int dy)
     638                     psS32 dx,
     639                     psS32 dy)
    641640{
    642     int outRows;
    643     int outCols;
    644     int elementSize;
     641    psS32 outRows;
     642    psS32 outCols;
     643    psS32 elementSize;
    645644
    646645    if (in == NULL) {
     
    669668    }
    670669
    671     int segment1Size = elementSize * (outCols - dx);
    672     int segment2Size = elementSize * dx;
    673 
    674     for (int row = 0; row < outRows; row++) {
    675         int inRowNumber = row + dy;
     670    psS32 segment1Size = elementSize * (outCols - dx);
     671    psS32 segment2Size = elementSize * dx;
     672
     673    for (psS32 row = 0; row < outRows; row++) {
     674        psS32 inRowNumber = row + dy;
    676675
    677676        if (inRowNumber >= outRows) {
     
    706705    if (fabsf(angle - 90.0f) < FLT_EPSILON) {
    707706        // perform 1/4 rotate counter-clockwise
    708         int numRows = in->numCols;
    709         int numCols = in->numRows;
    710         int lastCol = numCols - 1;
     707        psS32 numRows = in->numCols;
     708        psS32 numCols = in->numRows;
     709        psS32 lastCol = numCols - 1;
    711710        psElemType type = in->type.type;
    712711
     
    716715    case PS_TYPE_##TYPE: { \
    717716            ps##TYPE** inData = in->data.TYPE; \
    718             for (int row=0;row<numRows;row++) { \
     717            for (psS32 row=0;row<numRows;row++) { \
    719718                ps##TYPE* outRow = out->data.TYPE[row]; \
    720                 for (int col=0;col<numCols;col++) { \
     719                for (psS32 col=0;col<numCols;col++) { \
    721720                    outRow[col] = inData[lastCol-col][row]; \
    722721                } \
     
    752751    } else if (fabsf(angle - 180.0f) < FLT_EPSILON) {
    753752        // perform 1/2 rotate
    754         int numRows = in->numRows;
    755         int lastRow = numRows - 1;
    756         int numCols = in->numCols;
    757         int lastCol = numCols - 1;
     753        psS32 numRows = in->numRows;
     754        psS32 lastRow = numRows - 1;
     755        psS32 numCols = in->numCols;
     756        psS32 lastCol = numCols - 1;
    758757        psElemType type = in->type.type;
    759758
     
    762761        #define PSIMAGE_ROTATE_180_CASE(TYPE) \
    763762    case PS_TYPE_##TYPE: { \
    764             for (int row=0;row<numRows;row++) { \
     763            for (psS32 row=0;row<numRows;row++) { \
    765764                ps##TYPE* outRow = out->data.TYPE[row]; \
    766765                ps##TYPE* inRow = in->data.TYPE[lastRow-row]; \
    767                 for (int col=0;col<numCols;col++) { \
     766                for (psS32 col=0;col<numCols;col++) { \
    768767                    outRow[col] = inRow[lastCol - col]; \
    769768                } \
     
    799798    } else if (fabsf(angle - 270.0f) < FLT_EPSILON) {
    800799        // perform 1/4 rotate clockwise
    801         int numRows = in->numCols;
    802         int lastRow = numRows - 1;
    803         int numCols = in->numRows;
     800        psS32 numRows = in->numCols;
     801        psS32 lastRow = numRows - 1;
     802        psS32 numCols = in->numRows;
    804803        psElemType type = in->type.type;
    805804
     
    809808    case PS_TYPE_##TYPE: { \
    810809            ps##TYPE** inData = in->data.TYPE; \
    811             for (int row=0;row<numRows;row++) { \
     810            for (psS32 row=0;row<numRows;row++) { \
    812811                ps##TYPE* outRow = out->data.TYPE[row]; \
    813                 for (int col=0;col<numCols;col++) { \
     812                for (psS32 col=0;col<numCols;col++) { \
    814813                    outRow[col] = inData[col][lastRow-row]; \
    815814                } \
     
    847846    } else {
    848847        psElemType type = in->type.type;
    849         int numRows = in->numRows;
    850         int numCols = in->numCols;
     848        psS32 numRows = in->numRows;
     849        psS32 numCols = in->numCols;
    851850        float centerX = (float)(numCols) / 2.0f;
    852851        float centerY = (float)(numRows) / 2.0f;
     
    859858        // y' = y cos(t) - x sin(t); i.e. y' = (y-centerY)*cosT - (x-centerX)*sinT;
    860859
    861         int outCols = ceil(abs(numCols * cosT) + abs(numRows * sinT)) + 1;
    862         int outRows = ceil(abs(numCols * sinT) + abs(numRows * cosT)) + 1;
     860        psS32 outCols = ceil(abs(numCols * cosT) + abs(numRows * sinT)) + 1;
     861        psS32 outRows = ceil(abs(numCols * sinT) + abs(numRows * cosT)) + 1;
    863862        float minX = (float)outCols / -2.0f;
    864         int intMinY = outRows / -2;
     863        psS32 intMinY = outRows / -2;
    865864
    866865        out = psImageRecycle(out, outCols, outRows, type);
     
    906905            float inY; \
    907906            ps##TYPE* outRow; \
    908             for (int y = 0; y < outRows; y++) { \
     907            for (psS32 y = 0; y < outRows; y++) { \
    909908                inX = minXTimesCosTPlusCenterX + (y+intMinY) * sinT; \
    910909                inY = CenterYMinusminXTimesSinT + (y+intMinY) * cosT; \
    911910                outRow = out->data.TYPE[y]; \
    912                 for (int x = 0; x < outCols; x++) { \
     911                for (psS32 x = 0; x < outCols; x++) { \
    913912                    outRow[x] = p_psImagePixelInterpolate##MODE##_##TYPE(in,inX,inY,NULL,0,unexposedValue); \
    914913                    inX += cosT; \
     
    993992                      psImageInterpolateMode mode)
    994993{
    995     int outRows;
    996     int outCols;
    997     int elementSize;
     994    psS32 outRows;
     995    psS32 outCols;
     996    psS32 elementSize;
    998997    psElemType type;
    999998
     
    10301029        break; \
    10311030    } \
    1032     for (int row=0;row<outRows;row++) { \
     1031    for (psS32 row=0;row<outRows;row++) { \
    10331032        ps##TYPE* outRow = out->data.TYPE[row]; \
    10341033        float y = dy+(float)row; \
    1035         for (int col=0;col<outCols;col++) { \
     1034        for (psS32 col=0;col<outCols;col++) { \
    10361035            outRow[col] = p_psImagePixelInterpolate##MODE##_##TYPE( \
    10371036                          in,dx+(float)col,y,NULL,0,unexposedValue); \
Note: See TracChangeset for help on using the changeset viewer.