IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 25, 2004, 11:03:05 AM (22 years ago)
Author:
gusciora
Message:

Comments.

File:
1 edited

Legend:

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

    r1889 r1901  
    88 *  @author George Gusciora, MHPCC
    99 *
    10  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-09-24 23:47:21 $
     10 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-09-25 21:03:05 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    1818#endif
    1919
    20 #include<stdio.h>
    21 #include<math.h>
    22 #include "pslib.h"
    2320#include "pmSubtractBias.h"
    2421
     
    5754            (in->image)->data.F32[i][j]-=
    5855                (bias->image)->data.F32[i+in->row0-bias->row0][j+in->col0-bias->col0];
     56
    5957            ((in->mask)->data.U8[i][j])|=
    6058                (bias->mask)->data.U8[i+in->row0-bias->row0][j+in->col0-bias->col0];
     
    146144/******************************************************************************
    147145ScaleOverscanVector(): this routine takes as input an arbitrary vector,
    148 creates anew vector of length n, and fills the new vector with the
     146creates a new vector of length n, and fills the new vector with the
    149147interpolated values of the old vector.  The type of interpolation is:
    150148    PM_FIT_POLYNOMIAL: fit a polynomial to the entire input vector data.
     
    159157                              pmFit fit)
    160158{
     159    if (n == overscanVector) {
     160        return(overscanVector);
     161    }
     162
    161163    psVector *newVec = psVectorAlloc(n, PS_TYPE_F32);
    162164    psPolynomial1D *myPoly;
     
    166168
    167169    if (fit == PM_FIT_POLYNOMIAL) {
     170        // Fit a polynomial to the old overscan vector.
    168171        myPoly = (psPolynomial1D *) fitSpec;
    169172        myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL);
     173
     174        // For each element of the new vector, convert the x-ordinate to that
     175        // of the old vector, use the fitted polynomial to determine the
     176        // interpolated value at that point, and set the new vector.
    170177        for (i=0;i<n;i++) {
    171             x = (((float) i) / ((float) n)) * ((float) overscanVector->n);
     178            x = ((float) i) * ((float) overscanVector->n) / ((float) n);
    172179            newVec->data.F32[i] = psPolynomial1DEval(x, myPoly);
    173180        }
    174181    } else if (fit == PM_FIT_SPLINE) {
     182        // Fit a spline to the old overscan vector.
    175183        mySpline = (psSpline1D *) fitSpec;
    176184        mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL);
     185
     186        // For each element of the new vector, convert the x-ordinate to that
     187        // of the old vector, use the fitted polynomial to determine the
     188        // interpolated value at that point, and set the new vector.
    177189        for (i=0;i<n;i++) {
    178             x = (((float) i) / ((float) n)) * ((float) overscanVector->n);
     190            x = ((float) i) * ((float) overscanVector->n) / ((float) n);
    179191            newVec->data.F32[i] = psSpline1DEval(mySpline, x);
    180192        }
     
    254266
    255267    // XXX: How to use multiple overscans?  Currently, only the first is used.
     268
    256269    if ((overScanAxis == PM_OVERSCAN_ROWS) || (overScanAxis == PM_OVERSCAN_COLUMNS)) {
    257270        myOverscanImage = (psImage *) ((overscans->head)->data);
     
    271284                        tmpRow->data.F32[j] = myOverscanImage->data.F32[i][j];
    272285                    }
    273                     stat = psVectorStats(stat, tmpRow, NULL, 0xffffffff);
     286                    stat = psVectorStats(stat, tmpRow, NULL, 0);
    274287                    p_psGetStatValue(stat, &statValue);
    275288                    overscanVector->data.F32[i] = statValue;
     
    295308                        tmpRow->data.F32[j] = myOverscanImage->data.F32[i][j];
    296309                    }
    297                     stat = psVectorStats(stat, tmpRow, NULL, 0xffffffff);
     310                    stat = psVectorStats(stat, tmpRow, NULL, 0);
    298311                    p_psGetStatValue(stat, &statValue);
    299312                    overscanVector->data.F32[i] = statValue;
    300313                }
    301                 //                tmpOverscan = tmpOverscan->next;
     314                // tmpOverscan = tmpOverscan->next;
    302315                tmpOverscan = NULL;
    303316            }
     
    306319        }
    307320
     321        //
     322        // Re-bin the overscan vector (change its length).
     323        //
    308324        if ((nBin > 0) && (nBin < overscanVector->n)) {
    309325            numBins = 1+((overscanVector->n)/nBin);
     
    327343
    328344            }
     345
    329346            // Change the effective size of overscanVector.
    330347            overscanVector->n = numBins;
     
    338355        }
    339356
     357        //
     358        // Fit a polynomial to the overscan vector.
     359        //
    340360        if (!((fitSpec == NULL) || (fit == PM_FIT_NONE))) {
    341361            if (fit == PM_FIT_POLYNOMIAL) {
     
    352372        }
    353373
     374        //
     375        // Subtract overscan vector row-wise from the image.
     376        //
    354377        if (overScanAxis == PM_OVERSCAN_ROWS) {
    355378            for (i=0;i<(in->image)->numCols;i++) {
     
    360383        }
    361384
     385        //
     386        // Subtract overscan vector column-wise from the image.
     387        //
    362388        if (overScanAxis == PM_OVERSCAN_COLUMNS) {
    363389            for (i=0;i<(in->image)->numRows;i++) {
Note: See TracChangeset for help on using the changeset viewer.