IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 29, 2004, 2:34:02 PM (22 years ago)
Author:
gusciora
Message:

Fixed the spline stuff.

File:
1 edited

Legend:

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

    r2848 r2849  
    66 *  @author George Gusciora, MHPCC
    77 *
    8  *  @version $Revision: 1.24 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-12-29 22:44:33 $
     8 *  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-12-30 00:34:02 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    159159{
    160160    psTrace(".psModule.pmSubtracBias.ScaleOverscanVector", 4,
    161             "---- ScaleOverscanVector() begin ----\n");
    162 
    163     printf("HMMM: fit is %d\n", fit);
     161            "---- ScaleOverscanVector() begin (%d -> %d) ----\n", overscanVector->n, n);
    164162
    165163    if (NULL == overscanVector) {
     
    196194        }
    197195    } else if (fit == PM_FIT_SPLINE) {
     196        psS32 mustFreeSpline = 0;
    198197        // Fit a spline to the old overscan vector.
    199198        mySpline = (psSpline1D *) fitSpec;
     199        if (mySpline == NULL) {
     200            mustFreeSpline = 1;
     201        }
     202        //
     203        // NOTE: Since the X arg in the psVectorFitSpline1D() function is NULL,
     204        // splines enpoints will be from 0.0 to overscanVector->n-1.  Must scale
     205        // properly when doing the spline eval.
     206        //
    200207        mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL);
    201208
     
    204211        // interpolated value at that point, and set the new vector.
    205212        for (i=0;i<n;i++) {
    206             x = ((float) i) * ((float) overscanVector->n) / ((float) n);
     213            // Scale to [0 : overscanVector->n - 1]
     214            x = ((float) i) * ((float) (overscanVector->n-1)) / ((float) n);
    207215            newVec->data.F32[i] = psSpline1DEval(mySpline, x);
    208216        }
     217        if (mustFreeSpline ==1) {
     218            psFree(mySpline);
     219        }
     220
    209221    } else {
    210222        psError(PS_ERR_UNKNOWN, true, "unknown fit type\n");
     
    226238{
    227239    psTrace(".psModule.pmSubtracBias.pmSubtractBias", 4,
    228             "---- ScaleOverscanVector() begin ----\n");
     240            "---- pmSubtractBias() begin ----\n");
    229241    PS_READOUT_CHECK_NULL(in, NULL);
    230242    PS_READOUT_CHECK_EMPTY(in, NULL);
     
    335347                overscanVector->data.F32[i] = 0.0;
    336348            }
    337             tmpRow = psVectorAlloc((in->image)->numRows, PS_TYPE_F32);
     349            tmpRow = psVectorAlloc(myOverscanImage->numRows, PS_TYPE_F32);
    338350
    339351            // For each column of the input image, loop through every row,
     
    378390                overscanVector->data.F32[i] = 0.0;
    379391            }
    380             tmpCol = psVectorAlloc((in->image)->numCols, PS_TYPE_F32);
     392            tmpCol = psVectorAlloc(myOverscanImage->numCols, PS_TYPE_F32);
    381393
    382394            // For each row of the input image, loop through every column,
     
    449461        // image divided by numBins.
    450462        //
     463
    451464        if (!((fitSpec == NULL) || (fit == PM_FIT_NONE))) {
    452465            //
     
    482495                        tmpF32 = psSpline1DEval(mySpline, ((float) i) / ((float) nBin));
    483496                    }
    484 
    485497                    for (j=0;j<(in->image)->numRows;j++) {
    486498                        (in->image)->data.F32[j][i]-= tmpF32;
     
    541553
    542554    psTrace(".psModule.pmSubtracBias.pmSubtractBias", 4,
    543             "---- ScaleOverscanVector() exit ----\n");
     555            "---- pmSubtractBias() exit ----\n");
    544556
    545557    if (bias != NULL) {
Note: See TracChangeset for help on using the changeset viewer.