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

    r1983 r2204  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-10-06 21:31:30 $
     7 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-10-27 00:57:31 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828static void freeKernel(psKernel* ptr);
    2929
    30 psKernel* psKernelAlloc(int xMin, int xMax, int yMin, int yMax)
     30psKernel* psKernelAlloc(psS32 xMin, psS32 xMax, psS32 yMin, psS32 yMax)
    3131{
    3232    psKernel* result;
    33     int numRows;
    34     int numCols;
     33    psS32 numRows;
     34    psS32 numCols;
    3535
    3636    // following is explicitly spelled out in the SDRS as a requirement
     
    4040                 yMin, yMax);
    4141
    42         int temp = yMin;
     42        psS32 temp = yMin;
    4343        yMin = yMax;
    4444        yMax = temp;
     
    5151                 xMin, xMax);
    5252
    53         int temp = xMin;
     53        psS32 temp = xMin;
    5454        xMin = xMax;
    5555        xMax = temp;
     
    7070    psKernelType** kernelRows = result->p_kernelRows;
    7171    psKernelType** imageRows = result->image->data.PS_TYPE_KERNEL_DATA;
    72     for (int i = 0; i < numRows; i++) {
     72    for (psS32 i = 0; i < numRows; i++) {
    7373        kernelRows[i] = imageRows[i] - xMin;
    7474    }
     
    9191                           const psVector* xShifts,
    9292                           const psVector* yShifts,
    93                            bool relative)
     93                           psBool relative)
    9494{
    95     int x = 0;
    96     int y = 0;
    97     int t = 0;
    98     int deltaT;
    99     int oldX;
    100     int oldY;
    101     int xMin = 0;
    102     int xMax = 0;
    103     int yMin = 0;
    104     int yMax = 0;
    105     int length = 0;
     95    psS32 x = 0;
     96    psS32 y = 0;
     97    psS32 t = 0;
     98    psS32 deltaT;
     99    psS32 oldX;
     100    psS32 oldY;
     101    psS32 xMin = 0;
     102    psS32 xMax = 0;
     103    psS32 yMin = 0;
     104    psS32 yMax = 0;
     105    psS32 length = 0;
    106106    psKernelType normalizeTime = 1.0;  // fraction of total time for each shift clock
    107107    psKernel* result = NULL;
     
    153153        y = 0; \
    154154        t = 0; \
    155         for (int lcv = 0; lcv < length; lcv++) { \
     155        for (psS32 lcv = 0; lcv < length; lcv++) { \
    156156            if (relative) { \
    157157                x += xShiftData[lcv]; \
     
    181181        y = 0; \
    182182        t = 0; \
    183         for (int i = 0; i < length; i++) { \
     183        for (psS32 i = 0; i < length; i++) { \
    184184            deltaT = t; \
    185185            oldX = x; \
     
    228228}
    229229
    230 psImage* psImageConvolve(psImage* out, const psImage* in, const psKernel* kernel, bool direct)
     230psImage* psImageConvolve(psImage* out, const psImage* in, const psKernel* kernel, psBool direct)
    231231{
    232232    if (in == NULL) {
     
    242242        return NULL;
    243243    }
    244     int xMin = kernel->xMin;
    245     int xMax = kernel->xMax;
    246     int yMin = kernel->yMin;
    247     int yMax = kernel->yMax;
     244    psS32 xMin = kernel->xMin;
     245    psS32 xMax = kernel->xMax;
     246    psS32 yMin = kernel->yMin;
     247    psS32 yMax = kernel->yMax;
    248248    psKernelType** kData = kernel->kernel;
    249249
    250250    // make the output image to the proper size and type
    251     int numRows = in->numRows;
    252     int numCols = in->numCols;
     251    psS32 numRows = in->numRows;
     252    psS32 numCols = in->numCols;
    253253
    254254
     
    261261            ps##TYPE** inData = in->data.TYPE; \
    262262            out = psImageRecycle(out, numCols, numRows, PS_TYPE_##TYPE); \
    263             for (int row=0;row<numRows;row++) { \
     263            for (psS32 row=0;row<numRows;row++) { \
    264264                ps##TYPE* outRow = out->data.TYPE[row]; \
    265                 for (int col=0;col<numCols;col++) { \
     265                for (psS32 col=0;col<numCols;col++) { \
    266266                    ps##TYPE pixel = 0.0; \
    267                     for (int kRow = yMin; kRow < yMax; kRow++) { \
     267                    for (psS32 kRow = yMin; kRow < yMax; kRow++) { \
    268268                        if (row-kRow >= 0 && row-kRow < numRows) { \
    269                             for (int kCol = xMin; kCol < xMax; kCol++) { \
     269                            for (psS32 kCol = xMin; kCol < xMax; kCol++) { \
    270270                                if (col-kCol >= 0 && col-kCol < numCols) { \
    271271                                    pixel += kData[kRow][kCol] * inData[row-kRow][col-kCol]; \
     
    310310    } else {
    311311        // fourier convolution
    312         int paddedCols = numCols+2*FOURIER_PADDING;
    313         int paddedRows = numRows+2*FOURIER_PADDING;
     312        psS32 paddedCols = numCols+2*FOURIER_PADDING;
     313        psS32 paddedRows = numRows+2*FOURIER_PADDING;
    314314
    315315        // check to see if kernel is smaller, otherwise padding it up will fail.
    316         int kRows = kernel->image->numRows;
    317         int kCols = kernel->image->numCols;
     316        psS32 kRows = kernel->image->numRows;
     317        psS32 kCols = kernel->image->numCols;
    318318        if (kRows >= numRows || kCols >= numCols) {
    319319            psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConvolve",
     
    328328        // pad the image
    329329        psImage* paddedImage = psImageAlloc(paddedCols,paddedRows,in->type.type);
    330         int elementSize = PSELEMTYPE_SIZEOF(in->type.type);
     330        psS32 elementSize = PSELEMTYPE_SIZEOF(in->type.type);
    331331
    332332        // zero out padded area on top and bottom
     
    335335
    336336        // fill in the image-containing rows.
    337         int sidePaddingSize = FOURIER_PADDING*elementSize;
    338         int imageRowSize = numCols*elementSize;
     337        psS32 sidePaddingSize = FOURIER_PADDING*elementSize;
     338        psS32 imageRowSize = numCols*elementSize;
    339339        psU8* paddedData = paddedImage->data.U8[FOURIER_PADDING];
    340         for (int row=0;row<numRows;row++) {
     340        for (psS32 row=0;row<numRows;row++) {
    341341            // zero out padded area on left edge.
    342342            memset(paddedData,0,sidePaddingSize);
     
    354354        psImage* paddedKernel = psImageAlloc(paddedCols,paddedRows,PS_TYPE_KERNEL);
    355355        memset(paddedKernel->data.U8[0],0,sizeof(psKernelType)*numCols*numRows); // zero-out image
    356         int yMax = kernel->yMax;
    357         int xMax = kernel->xMax;
    358         for (int row = kernel->yMin; row <= yMax;row++) {
    359             int padRow = row;
     356        psS32 yMax = kernel->yMax;
     357        psS32 xMax = kernel->xMax;
     358        for (psS32 row = kernel->yMin; row <= yMax;row++) {
     359            psS32 padRow = row;
    360360            if (padRow < 0) {
    361361                padRow += paddedRows;
     
    363363            psKernelType* padData = paddedKernel->data.PS_TYPE_KERNEL_DATA[padRow];
    364364            psKernelType* kernelRow = kernel->kernel[row];
    365             for (int col = kernel->xMin; col <= xMax; col++) {
     365            for (psS32 col = kernel->xMin; col <= xMax; col++) {
    366366                if (col < 0) {
    367367                    padData[col+paddedCols] = kernelRow[col];
     
    418418        out = psImageRecycle(out,numCols,numRows,PS_TYPE_F32);
    419419        float factor = 1.0f/numCols/numRows;
    420         for (int row = 0; row < numRows; row++) {
     420        for (psS32 row = 0; row < numRows; row++) {
    421421            psF32* outRow = out->data.F32[row];
    422422            psC32* resultRow = complexOutSansPad->data.C32[row];
    423             for (int col = 0; col < numCols; col++) {
     423            for (psS32 col = 0; col < numCols; col++) {
    424424                outRow[col] = crealf(resultRow[col])*factor;
    425425            }
Note: See TracChangeset for help on using the changeset viewer.