IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 1, 2004, 11:27:26 AM (22 years ago)
Author:
gusciora
Message:

astyle

File:
1 edited

Legend:

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

    r2585 r2586  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-12-01 21:26:17 $
     8 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-12-01 21:27:26 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    143143
    144144    psStatsOptions statOptions = stats->options;
    145     if (1 < p_psDetermineNumBits(statOptions) {
    146             //XXX  psWarning(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");
    147             statOptions = getHighestPriorityStatOption(statOptions)
    148                               ;
    149             }
    150 
    151             // Bin the input image according to input parameters.
    152             if ((binFactor <= 0) ||
    153                     (stats == NULL)) {
    154             if (binFactor <= 0) {
    155                     psLogMsg(__func__, PS_LOG_WARN,
    156                              "WARNING: pmSubtractSky(): binFactor is %d\n", binFactor);
    157                 }
    158                 if (stats == NULL) {
    159                     psLogMsg(__func__, PS_LOG_WARN,
    160                              "WARNING: pmSubtractSky(): input parameter stats is NULL\n");
    161                 }
    162                 binnedImage = origImage;
    163             } else {
    164                 binnedImage = binImage(origImage, binFactor, statOptions);
    165             }
    166 
    167             // Clip pixels that are outside the acceptable range.
    168             if (clipSD <= 0.0) {
     145    if (1 < p_psDetermineNumBits(statOptions)) {
     146        //XXX  psWarning(PS_ERR_UNKNOWN,true, "Multiple statistical options have been requested.\n");
     147        statOptions = getHighestPriorityStatOption(statOptions);
     148    }
     149
     150    // Bin the input image according to input parameters.
     151    if ((binFactor <= 0) ||
     152            (stats == NULL)) {
     153        if (binFactor <= 0) {
    169154            psLogMsg(__func__, PS_LOG_WARN,
    170                      "WARNING: pmSubtractSky(): clipSD is %f\n", clipSD)
    171                 ;
    172             } else {
    173                 psF64 binnedMean;
    174                 psF64 binnedStdev;
    175                 psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    176                 myStats =  psImageStats(myStats, binedImage, NULL, 0);
    177                 p_psGetStatValue(myStats, &binnedMean);
    178 
    179                 myStats->options = PS_STAT_SAMPLE_STDEV;
    180                 myStats =  psImageStats(myStats, binedImage, NULL, 0);
    181                 p_psGetStatValue(myStats, &binnedStdev);
    182                 psFree(myStats);
    183 
    184                 for (int row = 0; row < binnedImage->numRows ; row++) {
    185                     for (int col = 0; col < binnedImage->numCols ; col++) {
    186                         if (fabs(binnedImage->data.F32[row][col] - binnedMean) >
    187                                 (clipSD * binnedStdev)) {
    188                             binnedImage->mask.U8[row][col] = 1;
    189                         }
    190                     }
     155                     "WARNING: pmSubtractSky(): binFactor is %d\n", binFactor);
     156        }
     157        if (stats == NULL) {
     158            psLogMsg(__func__, PS_LOG_WARN,
     159                     "WARNING: pmSubtractSky(): input parameter stats is NULL\n");
     160        }
     161        binnedImage = origImage;
     162    } else {
     163        binnedImage = binImage(origImage, binFactor, statOptions);
     164    }
     165
     166    // Clip pixels that are outside the acceptable range.
     167    if (clipSD <= 0.0) {
     168        psLogMsg(__func__, PS_LOG_WARN,
     169                 "WARNING: pmSubtractSky(): clipSD is %f\n", clipSD)
     170        ;
     171    } else {
     172        psF64 binnedMean;
     173        psF64 binnedStdev;
     174        psStats *myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
     175        myStats =  psImageStats(myStats, binedImage, NULL, 0);
     176        p_psGetStatValue(myStats, &binnedMean);
     177
     178        myStats->options = PS_STAT_SAMPLE_STDEV;
     179        myStats =  psImageStats(myStats, binedImage, NULL, 0);
     180        p_psGetStatValue(myStats, &binnedStdev);
     181        psFree(myStats);
     182
     183        for (int row = 0; row < binnedImage->numRows ; row++) {
     184            for (int col = 0; col < binnedImage->numCols ; col++) {
     185                if (fabs(binnedImage->data.F32[row][col] - binnedMean) >
     186                        (clipSD * binnedStdev)) {
     187                    binnedImage->mask.U8[row][col] = 1;
    191188                }
    192189            }
    193 
    194             // XXX: fit the polynomial to the binned image
    195             if (fit == PM_FIT_POLYNOMIAL) {
    196             // Fit a polynomial to the old overscan vector.
    197             myPoly = (psPolynomial2D *)
    198                          fitSpec;
    199                 myPoly = psImageFitPolynomial(myPoly, origImage);
    200                 // XXX Do we need to do something with ordinate scaling if Chebyshev?
    201                 binnedImage = psImageEvalPolynomial(binnedImage, myPoly);
    202 
    203             } else if (fit == PM_FIT_SPLINE) {
    204             // Fit a spline to the old overscan vector.
    205             mySpline = (psSpline1D *)
    206                            fitSpec;
    207                 // XXX: What do we do?  We don't have 2-D splines.
    208                 return(in);
     190        }
     191    }
     192
     193    // XXX: fit the polynomial to the binned image
     194    if (fit == PM_FIT_POLYNOMIAL) {
     195        // Fit a polynomial to the old overscan vector.
     196        myPoly = (psPolynomial2D *)
     197                 fitSpec;
     198        myPoly = psImageFitPolynomial(myPoly, origImage);
     199        // XXX Do we need to do something with ordinate scaling if Chebyshev?
     200        binnedImage = psImageEvalPolynomial(binnedImage, myPoly);
     201
     202    } else if (fit == PM_FIT_SPLINE) {
     203        // Fit a spline to the old overscan vector.
     204        mySpline = (psSpline1D *)
     205                   fitSpec;
     206        // XXX: What do we do?  We don't have 2-D splines.
     207        return(in);
     208    }
     209
     210    //Subtract the polynomially fitted image from the original image
     211    if (binFactor <= 0) {
     212        for (int row = 0; row < origImage->numRows ; row++) {
     213            for (int col = 0; col < origImage->numCols ; col++) {
     214                origImage->data.F32[row][col]-= binnedImage->data.F32[row][col];
    209215            }
    210 
    211             //Subtract the polynomially fitted image from the original image
    212             if (binFactor <= 0) {
    213             for (int row = 0; row < origImage->numRows ; row++) {
    214                     for (int col = 0; col < origImage->numCols ; col++) {
    215                         origImage->data.F32[row][col]-= binnedImage->data.F32[row][col];
    216                     }
    217                 }
    218             } else {
    219                 for (int row = 0; row < origImage->numRows ; row++) {
    220                     for (int col = 0; col < origImage->numCols ; col++) {
    221                         int binRow = row / binFactor;
    222                         int binCol = col / binFactor;
    223                         origImage->data.F32[row][col]-= binnedImage->data.F32[binRow][binCol];
    224                     }
    225                 }
    226 
     216        }
     217    } else {
     218        for (int row = 0; row < origImage->numRows ; row++) {
     219            for (int col = 0; col < origImage->numCols ; col++) {
     220                int binRow = row / binFactor;
     221                int binCol = col / binFactor;
     222                origImage->data.F32[row][col]-= binnedImage->data.F32[binRow][binCol];
    227223            }
    228             return(in);
    229         }
     224        }
     225
     226    }
     227    return(in);
     228}
Note: See TracChangeset for help on using the changeset viewer.