IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 4, 2004, 4:45:42 PM (22 years ago)
Author:
gusciora
Message:

Compiles, but doesn't run.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/pmReadoutCombine.c

    r2282 r2286  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-11-04 20:52:17 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-05 02:45:42 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5555    PS_PTR_CHECK_NULL(inputs, NULL);
    5656    PS_PTR_CHECK_NULL(params, NULL);
    57     //    unsigned int maskVal = params->maskVal;
     57    unsigned int maskVal = params->maskVal;
    5858    psStats *stats = params->stats;
    5959    int i;
    6060    int j;
    61     int numInputCols = -1;
    62     int numInputRows = -1;
    6361    int maxInputCols = 0;
    6462    int maxInputRows = 0;
     
    6967    psReadout *tmpReadout;
    7068    float tmpF;
     69
    7170
    7271    //
     
    9291        minInputRows = PS_MIN(minInputRows,
    9392                              (tmpReadout->row0 + tmpReadout->image->row0));
     93        tmpF = tmpReadout->row0 +
     94               tmpReadout->image->row0 +
     95               tmpReadout->image->numRows;
     96        maxInputRows = PS_MAX(maxInputRows, tmpF);
     97
     98        minInputCols = PS_MIN(minInputCols,
     99                              (tmpReadout->col0 + tmpReadout->image->col0));
    94100        tmpF = tmpReadout->col0 +
    95101               tmpReadout->image->col0 +
    96102               tmpReadout->image->numCols;
    97103        maxInputCols = PS_MAX(maxInputCols, tmpF);
    98 
    99         minInputCols = PS_MIN(minInputCols,
    100                               (tmpReadout->col0 + tmpReadout->image->col0));
    101         tmpF = tmpReadout->row0 +
    102                tmpReadout->image->row0 +
    103                tmpReadout->image->numRows;
    104         maxInputRows = PS_MAX(maxInputRows, tmpF);
    105104        tmpInput = tmpInput->next;
    106105        numInputs++;
    107106    }
    108107
     108    // We ensure that the zero vector is of the proper size.
     109    if (zero != NULL) {
     110        PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL);
     111        if (numInputs > zero->n) {
     112            // XXX: ERROR: the zero vector does not have enough elements.
     113            return(NULL);
     114        } else if (numInputs < zero->n) {
     115            // XXX: WARNING: the zero vector too many elements.
     116        }
     117    }
     118
     119    // We ensure that the scale vector is of the proper size.
     120    if (scale != NULL) {
     121        PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL);
     122        if (numInputs > scale->n) {
     123            // XXX: ERROR: the scale vector does not have enough elements.
     124            return(NULL);
     125        } else if (numInputs < scale->n) {
     126            // XXX: WARNING: the scale vector too many elements.
     127        }
     128    }
     129
     130    // At this point, the following variables have been computed:
     131    // maxInputRows: the largest input row value, in output image space.
     132    // maxInputCols: the largest input column value, in output image space.
     133    // minInputRows: the smallest input row value, in output image space.
     134    // minInputCols: the smallest input column value, in output image space.
     135    //
    109136    if (output == NULL) {
    110         output = psImageAlloc(numInputCols-minInputCols,
    111                               numInputRows-minInputRows, PS_TYPE_F32);
     137        output = psImageAlloc(1+maxInputCols-minInputCols,
     138                              1+maxInputRows-minInputRows, PS_TYPE_F32);
    112139        *(int *) &(output->col0) = minInputCols;
    113140        *(int *) &(output->row0) = minInputRows;
     
    115142        if (((output->col0 + output->numCols) < maxInputCols) ||
    116143                ((output->row0 + output->numRows) < maxInputRows)) {
    117             //XXX            psError(__func__, "Output image (%d, %d) is too small to hold combined images.\n",
     144            //XXX ERROR: "Output image (%d, %d) is too small to hold combined images.\n",
    118145            //                    output->row0 + output->numRows,
    119146            //                    output->col0 + output->numCols);
     
    121148        }
    122149
    123         if ((output->col0 > minInputCols) ||
    124                 (output->row0 > minInputRows)) {
    125             //XXX            psError(__func__, "Output image offset is larger then input image offset.\n");
     150        if ((output->col0 > minInputCols) || (output->row0 > minInputRows)) {
     151            //XXX ERROR "Output image offset is larger then input image offset.\n");
    126152            return(NULL);
    127153        }
     
    136162    psVector *tmpPixelMask = psVectorAlloc(numInputs, PS_TYPE_U8);
    137163    psVector *tmpPixelMaskNKeep = psVectorAlloc(numInputs, PS_TYPE_U8);
     164    psVector *outRowLower = psVectorAlloc(numInputs, PS_TYPE_U32);
     165    psVector *outRowUpper = psVectorAlloc(numInputs, PS_TYPE_U32);
     166    psVector *outColLower = psVectorAlloc(numInputs, PS_TYPE_U32);
     167    psVector *outColUpper = psVectorAlloc(numInputs, PS_TYPE_U32);
    138168    psReadout **tmpReadouts = (psReadout **) psAlloc(numInputs * sizeof(psReadout *));
     169
     170
     171    // For each input readout, we create a pointer to that readout in
     172    // "tmpReadouts[]", and we store the min/max pixel indices for that
     173    // readout, in putput image coordinates, in the psVectors
     174    // (outRowLower, outColLower, outRowUpper, outColUpper).
    139175    i = 0;
    140176    while (NULL != tmpInput) {
    141177        tmpReadouts[i] = (psReadout *) tmpInput->data;
     178        outRowLower->data.U32[i] = tmpReadouts[i]->row0 + tmpReadout->image->row0;
     179        outColLower->data.U32[i] = tmpReadouts[i]->col0 + tmpReadout->image->col0;
     180        outRowUpper->data.U32[i] = tmpReadouts[i]->row0 +
     181                                   tmpReadouts[i]->image->row0 +
     182                                   tmpReadouts[i]->image->numRows;
     183        outColUpper->data.U32[i] = tmpReadouts[i]->col0 +
     184                                   tmpReadouts[i]->image->col0 +
     185                                   tmpReadouts[i]->image->numCols;
     186
    142187        tmpInput = tmpInput->next;
    143188        i++;
    144     }
    145 
    146     for (i = 0; i < output->numRows ; i++) {
    147         for (j = 0; j < output->numCols ; j++) {
     189
     190    }
     191
     192    // We loop through each pixel in the output image.  We loop through each
     193    // input readout.  We determine if that output pixel is contained in the
     194    // image from that readout.  If so, we save it in psVector tmpPixels.
     195    // If not, we set a mask for that element in tmpPixels.  Then, we mask off
     196    // pixels not between fracLow and fracHigh.  Then we call the vector
     197    // stats routine on those pixels/mask.  Then we set the output pixel value
     198    // to the result of the stats call.
     199    for (i = output->row0; i < output->numRows ; i++) {
     200        for (j = output->col0; j < output->numCols ; j++) {
    148201            for (int r = 0; r < numInputs ; r++) {
    149                 //                if (i,j are valid for this readout) {
    150                 if (0) {
    151                     //                     tmpPixels->data.F32[r] = WHATEVER;
    152                     tmpPixelMask->data.U8[r] = 0;
     202                if ((outRowLower->data.U32[r] <= i) &&
     203                        (outColLower->data.U32[r] <= j) &&
     204                        (outRowUpper->data.U32[r] > i) &&
     205                        (outColUpper->data.U32[r] > j)) {
     206
     207                    int imageRow = i - (tmpReadouts[r]->row0 +
     208                                        tmpReadouts[i]->image->row0);
     209                    int imageCol = j - (tmpReadouts[r]->col0 +
     210                                        tmpReadouts[r]->image->col0);
     211                    if (!(maskVal && tmpReadouts[i]->mask->data.U8[imageRow][imageCol])) {
     212                        tmpPixels->data.F32[r] = tmpReadouts[i]->image->data.F32[imageRow][imageCol];
     213                        tmpPixelMask->data.U8[r] = 0;
     214                    } else {
     215                        tmpPixels->data.F32[r] = 0.0;
     216                        tmpPixelMask->data.U8[r] = 1;
     217                    }
    153218                } else {
    154219                    tmpPixels->data.F32[r] = 0.0;
     
    156221                }
    157222            }
     223            // At this point, we have scanned all input readouts for this
     224            // one output pixel.
    158225
    159226            // Determine how many pixels lie between fracLow and fracHigh.
     
    184251            }
    185252
     253            // XXX: Is this correct?
     254            // We add the zero vector, if non-NULL.
     255            if (zero != NULL) {
     256                for (int r = 0; r < numInputs ; r++) {
     257                    tmpPixels->data.F32[r]+= zero->data.F32[r];
     258                }
     259            }
     260
     261            // XXX: Is this correct?
     262            // We scale the pixels by the scale vector, if not-NULL.
     263            if (scale != NULL) {
     264                for (int r = 0; r < numInputs ; r++) {
     265                    tmpPixels->data.F32[r]*= scale->data.F32[r];
     266                }
     267            }
     268
     269            // XXX: Is this correct?
     270            if (gain > 0.0) {
     271                for (int r = 0; r < numInputs ; r++) {
     272                    tmpPixels->data.F32[r]*= gain;
     273                }
     274            }
     275
     276            // XXX: Is this correct?
     277            if (!(readnoise < 0.0)) {
     278                for (int r = 0; r < numInputs ; r++) {
     279                    tmpPixels->data.F32[r]+= readnoise;
     280                }
     281            }
     282
    186283            // Calculate the specified statistic on the stack of pixels.
    187284            stats = psVectorStats(stats,
     
    193290            double statValue;
    194291            if (!p_psGetStatValue(stats, &statValue)) {
    195                 psError(PS_ERR_UNKNOWN,true, "Could not determine stats value.\n");
     292                //XXX ERROR: "Could not determine stats value.\n"
    196293                return(NULL);
    197294            } else {
    198                 output->data.F32[i][j] = (float) statValue;
     295                output->data.F32[i-output->row0][j-output->col0] = (float) statValue;
    199296            }
    200297        }
     
    205302    psFree(tmpPixelMask);
    206303    psFree(tmpPixelMaskNKeep);
     304    psFree(outRowLower);
     305    psFree(outRowUpper);
     306    psFree(outColLower);
     307    psFree(outColUpper);
    207308    psFree(tmpReadouts);
    208309
Note: See TracChangeset for help on using the changeset viewer.