예제 #1
0
int
main (void)
{
  testA ();
  testB ();
  testC ();
  testD ();
  testE ();
  testF ();
  testG ();
  testH ();
  testI ();
  testJ ();
  testK ();
  testL ();
  testM ();
  testN ();
  testO ();
  testP ();
  testQ ();
  testR ();
  testS ();
  testT ();
  testU ();
  testV ();
  /*
  testW ();
  testX ();
  testY ();
  testZ ();
  */
  exit (0);
}
예제 #2
0
//This function generates the Zernike Polynomials. Please see: Efficient Cartesian representation of Zernike polynomials in computer memory
//SPIE Vol. 3190 pp. 382 to get more details about the implementation
void PolyZernikes::create(const Matrix1D<int> & coef)
{
    Matrix2D<int> * fMatT;

    int nMax=(int)VEC_XSIZE(coef);
    for (int nZ = 0; nZ < nMax; ++nZ)
    {
        if (VEC_ELEM(coef,nZ) == 0)
        {
            fMatT = new Matrix2D<int>(1,1);
            dMij(*fMatT,0,0)=0;
            //*fMatT = 0;
        }
        else
        {
            // Note that the paper starts in n=1 and we start in n=0
            int n = (size_t)ZERNIKE_ORDER(nZ);
            int l = 2*nZ-n*(n+2);
            int m = (n-l)/2;

            Matrix2D<int> testM(n+1,n+1);
            fMatT = new Matrix2D<int>(n+1,n+1);

            int p = (l>0);
            int q = ((n % 2 != 0) ? (abs(l)-1)/2 : (( l > 0 ) ? abs(l)/2-1 : abs(l)/2 ) );
            l = abs(l); //We want the positive value of l
            m = (n-l)/2;

            for (int i = 0; i <= q; ++i)
            {
                int K1=binom(l,2*i+p);
                for (int j = 0; j <= m; ++j)
                {
                    int factor = ( (i+j)%2 ==0 ) ? 1 : -1 ;
                    int K2=factor * K1 * fact(n-j)/(fact(j)*fact(m-j)*fact(n-m-j));
                    for (int k = 0; k <= (m-j); ++k)
                    {
                        int ypow = 2 * (i+k) + p;
                        int xpow = n - 2 * (i+j+k) - p;
                        dMij(*fMatT,xpow,ypow) +=K2 * binom(m-j,k);
                    }
                }
            }
        }

        fMatV.push_back(*fMatT);
    }
}