IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2282


Ignore:
Timestamp:
Nov 4, 2004, 10:52:17 AM (22 years ago)
Author:
gusciora
Message:

Compiles, but does not run.

File:
1 edited

Legend:

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

    r2277 r2282  
    1 p/** @file  pmReadoutCombine.c
     1/** @file  pmReadoutCombine.c
    22 *
    33 *  This file will contain a module which will combine multiple readout images.
     
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-11-04 19:22:07 $
     7 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-11-04 20:52:17 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4343}
    4444
    45 
     45#define MAX_INT 10000
    4646psImage *pmReadoutCombine(psImage *output,
    4747                          const psList *inputs,
     
    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;
     
    6161    int numInputCols = -1;
    6262    int numInputRows = -1;
    63     int minInputCols = HUGE;
    64     int minInputRowss = HUGE;
     63    int maxInputCols = 0;
     64    int maxInputRows = 0;
     65    int minInputCols = MAX_INT;
     66    int minInputRows = MAX_INT;
    6567    psListElem *tmpInput = NULL;
    6668    int numInputs = 0;
    6769    psReadout *tmpReadout;
     70    float tmpF;
    6871
    6972    //
     
    9093                              (tmpReadout->row0 + tmpReadout->image->row0));
    9194        tmpF = tmpReadout->col0 +
    92                tmpReadout->numCols +
    9395               tmpReadout->image->col0 +
    9496               tmpReadout->image->numCols;
     
    98100                              (tmpReadout->col0 + tmpReadout->image->col0));
    99101        tmpF = tmpReadout->row0 +
    100                tmpReadout->numRows +
    101102               tmpReadout->image->row0 +
    102103               tmpReadout->image->numRows;
     
    109110        output = psImageAlloc(numInputCols-minInputCols,
    110111                              numInputRows-minInputRows, PS_TYPE_F32);
    111         output->col0 = minInputCols;
    112         output->row0 = minInputRows;
     112        *(int *) &(output->col0) = minInputCols;
     113        *(int *) &(output->row0) = minInputRows;
    113114    } else {
    114115        if (((output->col0 + output->numCols) < maxInputCols) ||
    115116                ((output->row0 + output->numRows) < maxInputRows)) {
    116             psError(__func__, "Output image (%d, %d) is too small to hold combined images.\n",
    117                     output->row0 + output->numRows,
    118                     output->col0 + output->numCols);
     117            //XXX            psError(__func__, "Output image (%d, %d) is too small to hold combined images.\n",
     118            //                    output->row0 + output->numRows,
     119            //                    output->col0 + output->numCols);
    119120            return(NULL);
    120121        }
     
    122123        if ((output->col0 > minInputCols) ||
    123124                (output->row0 > minInputRows)) {
    124             psError(__func__, "Output image offset is larger then input image offset.\n");
     125            //XXX            psError(__func__, "Output image offset is larger then input image offset.\n");
    125126            return(NULL);
    126127        }
     
    128129
    129130    if (1 < p_psDetermineNumBits(params->stats->options)) {
    130         psError(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");
     131        //XXX        psError(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");
    131132        return(NULL);
    132133    }
     
    145146    for (i = 0; i < output->numRows ; i++) {
    146147        for (j = 0; j < output->numCols ; j++) {
    147 
    148             // XXX: put code in here to figure out for each readout if it has
    149             a pixel that corresponds to this output pixel.
    150 
    151148            for (int r = 0; r < numInputs ; r++) {
    152                 if (i,j are valid for this readout) {
    153                         if (0) {
    154                             tmpPixels->data.F32[r] = WHATEVER;
    155                             tmpPixelMask->data.U8[r] = 0;
    156                         } else {
    157                             tmpPixels->data.F32[r] = 0.0;
    158                             tmpPixelMask->data.U8[r] = 1;
    159                         }
     149                //                if (i,j are valid for this readout) {
     150                if (0) {
     151                    //                     tmpPixels->data.F32[r] = WHATEVER;
     152                    tmpPixelMask->data.U8[r] = 0;
     153                } else {
     154                    tmpPixels->data.F32[r] = 0.0;
     155                    tmpPixelMask->data.U8[r] = 1;
     156                }
     157            }
     158
     159            // Determine how many pixels lie between fracLow and fracHigh.
     160            int pixelCount = 0;
     161            for (int r = 0; r < numInputs ; r++) {
     162                if (tmpPixelMask->data.U8[r] == 0) {
     163                    if ((params->fracLow <= tmpPixels->data.F32[r]) &&
     164                            (params->fracHigh >= tmpPixels->data.F32[r])) {
     165                        pixelCount++;
    160166                    }
    161 
    162                 // Determine how many pixels lie between fracLow and fracHigh.
    163                 int pixelCount = 0;
     167                }
     168            }
     169
     170            // If more than params->nKeep pixels lie between the valid range,
     171            // then loop through the pixels, and mask away any pixels outside
     172            // that range.
     173            if (pixelCount >= params->nKeep) {
    164174                for (int r = 0; r < numInputs ; r++) {
    165175                    if (tmpPixelMask->data.U8[r] == 0) {
    166176                        if ((params->fracLow <= tmpPixels->data.F32[r]) &&
    167177                                (params->fracHigh >= tmpPixels->data.F32[r])) {
    168                             pixelCount++;
     178                            tmpPixelMaskNKeep->data.U8[r] = 0;
     179                        } else {
     180                            tmpPixelMaskNKeep->data.U8[r] = 1;
    169181                        }
    170182                    }
    171183                }
    172 
    173                 // If more than params->nKeep pixels lie between the valid range,
    174                 // then loop through the pixels, and mask away any pixels outside
    175                 // that range.
    176                 if (pixelCount >= params->nKeep) {
    177                     for (int r = 0; r < numInputs ; r++) {
    178                         if (tmpPixelMask->data.U8[r] == 0) {
    179                             if ((params->fracLow <= tmpPixels->data.F32[r]) &&
    180                                     (params->fracHigh >= tmpPixels->data.F32[r])) {
    181                                 tmpPixelMaskNKeep->data.U8[r] = 0;
    182                             } else {
    183                                 tmpPixelMaskNKeep->data.U8[r] = 1;
    184                             }
    185                         }
    186                     }
    187                 }
    188 
    189                 // Calculate the specified statistic on the stack of pixels.
    190                 stats = psVectorStats(stats,
    191                                       tmpPixels,
    192                                       tmpPixelMaskNKeep,
    193                                       1);
    194 
    195                 // Set the pixel value in the output image to the stat value.
    196                 double statValue;
    197                 if (!p_psGetStatValue(stats, &statValue)) {
    198                     psError(PS_ERR_UNKNOWN,true, "Could not determine stats value.\n");
    199                     return(NULL);
    200                 } else {
    201                     output->data.F32[i][j] = (float) statValue;
    202                 }
    203             }
    204         }
    205 
    206         psFree(tmpPixels);
    207         psFree(tmpPixels);
    208         psFree(tmpPixelMask);
    209         psFree(tmpPixelMaskNKeep);
    210         psFree(tmpReadouts);
    211 
    212         return(output);
    213     }
     184            }
     185
     186            // Calculate the specified statistic on the stack of pixels.
     187            stats = psVectorStats(stats,
     188                                  tmpPixels,
     189                                  tmpPixelMaskNKeep,
     190                                  1);
     191
     192            // Set the pixel value in the output image to the stat value.
     193            double statValue;
     194            if (!p_psGetStatValue(stats, &statValue)) {
     195                psError(PS_ERR_UNKNOWN,true, "Could not determine stats value.\n");
     196                return(NULL);
     197            } else {
     198                output->data.F32[i][j] = (float) statValue;
     199            }
     200        }
     201    }
     202
     203    psFree(tmpPixels);
     204    psFree(tmpPixels);
     205    psFree(tmpPixelMask);
     206    psFree(tmpPixelMaskNKeep);
     207    psFree(tmpReadouts);
     208
     209    return(output);
     210}
Note: See TracChangeset for help on using the changeset viewer.