IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 23, 2004, 11:41:15 AM (22 years ago)
Author:
gusciora
Message:

...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageStats.c

    r1025 r1072  
    155155}
    156156
     157/*****************************************************************************
     158p_psCalcScaleFactorsEval(n): The Chebyshev polynomials are defined over the
     159interval [-1.0 : 1.0].  Images typically have sizes of 512x512 or more.  In
     160order to use Chebyshev polynomials, we must scales the coordinates from
     1610:512 to -1:1.  This routine takes as input an integer N and produces as
     162output a vector of evenly spaced floating point values between -1.0:1.0.
     163 *****************************************************************************/
    157164float *p_psCalcScaleFactorsEval(int n)
    158165{
     
    200207
    201208/*****************************************************************************
    202     psImageFitPolynomial():
    203  This routine takes as input a 2-D image and produces as output
    204  the coefficients of the Chebyshev polynomials which match that
    205  input image.
    206     Input:
    207     Output:
    208     Internal Data Structures:
    209  
    210  chebPolys[i][j]
    211  
    212  sums[i][j]: This will contain the sum of
    213   input->data.F32[x][y] *
     209psImageFitPolynomial(): This routine takes as input a 2-D image and produces
     210as output the coefficients of the Chebyshev polynomials which match that
     211input image.
     212  Input:
     213  Output:
     214  Internal Data Structures:
     215    chebPolys[i][j]
     216    sums[i][j]: This will contain the sum of
     217                input->data.F32[x][y] *
    214218                psEvalPolynomial1D((float) x, chebPolys[i]) *
    215219                psEvalPolynomial1D((float) y, chebPolys[j]);
    216       over all pixels (x,y) in the image.
    217  
    218  
     220        over all pixels (x,y) in the image.
    219221 *****************************************************************************/
    220222psPolynomial2D *
     
    253255    chebPolys = p_psCreateChebyshevPolys(maxChebyPoly);
    254256
    255     // Sanity check for the Chebyshevs
     257    // Sanity check for the Chebyshevs.
    256258    for (i=0;i<coeffs->nX;i++) {
    257259        for (j=0;j<coeffs->nY;j++) {
     
    262264
    263265            }
    264         }
    265     }
    266 
     266            printf("SUM(Cheby(%d) * Cheby(%d)) is %f\n", i, j, tmp);
     267        }
     268    }
     269
     270    // Compute the sums[][] data structure.
    267271    for (i=0;i<coeffs->nX;i++) {
    268272        for (j=0;j<coeffs->nY;j++) {
     
    279283
    280284    // NOTE: Check the math on this at a later date.
    281     coeffs->coeff[0][0] = sums[0][0] / ((float) (coeffs->nX * coeffs->nY));
    282     for (i=0;i<coeffs->nX;i++) {
    283         coeffs->coeff[i][0] = ((sums[i][0] * 2.0) /
    284                                ((float) (coeffs->nX * coeffs->nY))) -
    285                               coeffs->coeff[0][0];
    286     }
    287     for (j=0;j<coeffs->nY;j++) {
    288         coeffs->coeff[0][j] =
    289             ((sums[0][j] * 2.0) /
    290              ((float) (coeffs->nX * coeffs->nY))) -
    291             coeffs->coeff[0][0];
    292     }
    293     for (i=1;i<coeffs->nX;i++) {
    294         for (j=1;j<coeffs->nY;j++) {
    295             coeffs->coeff[i][j] =
    296                 ((sums[i][0] * 4.0) / ((float) (coeffs->nX * coeffs->nY))) -
    297                 (coeffs->coeff[0][0] +
    298                  coeffs->coeff[i][0] +
    299                  coeffs->coeff[0][j]);
     285    //    coeffs->coeff[0][0] = sums[0][0] / ((float) (coeffs->nX * coeffs->nY));
     286    //    for (i=0;i<coeffs->nX;i++) {
     287    //        coeffs->coeff[i][0] = ((sums[i][0] * 2.0) /
     288    //                               ((float) (coeffs->nX * coeffs->nY))) -
     289    //                              coeffs->coeff[0][0];
     290    //    }
     291    //    for (j=0;j<coeffs->nY;j++) {
     292    //        coeffs->coeff[0][j] =
     293    //            ((sums[0][j] * 2.0) /
     294    //             ((float) (coeffs->nX * coeffs->nY))) -
     295    //            coeffs->coeff[0][0];
     296    //    }
     297
     298    for (i=0;i<coeffs->nX;i++) {
     299        for (j=0;j<coeffs->nY;j++) {
     300            coeffs->coeff[i][j] = sums[i][j];
     301            coeffs->coeff[i][j]/= ((float) coeffs->nX) * ((float) coeffs->nY);
     302            if ((i != 0) && (j != 0)) {
     303                coeffs->coeff[i][j]*= 4.0;
     304            } else if ((i == 0) && (j == 0)) {
     305                coeffs->coeff[i][j]*= 1.0;
     306            } else {
     307                coeffs->coeff[i][j]*= 2.0;
     308            }
     309
     310            //            coeffs->coeff[i][j] =
     311            //                ((sums[i][0] * 4.0) / ((float) (coeffs->nX * coeffs->nY))) -
     312            //                (coeffs->coeff[0][0] +
     313            //                 coeffs->coeff[i][0] +
     314            //                 coeffs->coeff[0][j]);
    300315        }
    301316    }
Note: See TracChangeset for help on using the changeset viewer.