예제 #1
0
파일: test_daubfilt.py 프로젝트: uniomni/CV
    def test_vanishing_moments(self):
        """Test that coefficients in lp satisfy the
           vanishing moments condition
        """ 

        from daubfilt import daubfilt, number_of_filters

        for i in range(number_of_filters):
            D = 2*(i+1)

            P = D/2  # Number of vanishing moments
            N = P-1  # Dimension of nullspace of the matrix A
            R = P+1  # Rank of A, R = D-N = P+1 equations
        
            lp, hp = daubfilt(D)


            # Condition number of A grows with P, so we test only
            # the first 6 (and eps is slightly larger than machine precision)

            A    = zeros((R,D), Float)  # D unknowns, D-N equations
            b    = zeros((R,1), Float)  # Right hand side
            b[0] = sqrt(2)                
  
            A[0,:] = ones(D, Float)   # Coefficients must sum to sqrt(2)
            for p in range(min(P,6)): # the p'th vanishing moment (Cond Ap)
                for k in range(D):            
                    m=D-k;
                    A[p+1,k] = (-1)**m * k**p;

            assert allclose(b, mvmul(A,lp))         
예제 #2
0
파일: test_daubfilt.py 프로젝트: uniomni/CV
    def test_filterlength(self):

        from daubfilt import daubfilt
        
        for p in range(1,26):
            D=2*p
            lp, hp = daubfilt(D)
            if len(lp) != D:      # Test number of coefficients
                S = 'Bad filter length (%d), D = %d' %(length(lp), D) 
                raise S
예제 #3
0
파일: test_daubfilt.py 프로젝트: uniomni/CV
    def test_conservation_of_area(self):
        """Test that coefficients in lp satisfy the dilation equation
        """ 

        from daubfilt import daubfilt, number_of_filters

        for p in range(number_of_filters):
            D = 2*(p+1)
            lp, hp = daubfilt(D)

            err = abs(sum(lp)-sqrt(2))
            #assert abs(err) <= epsilon, 'Error == %e' %err
            assert allclose(err, 0), 'Error == %e' %err    
예제 #4
0
파일: test_daubfilt.py 프로젝트: uniomni/CV
    def test_orthogonality(self):
        """Test that coefficients in lp satisfy orthogonality condition
        """ 

        from daubfilt import daubfilt, number_of_filters

        for p in range(number_of_filters):
            D = 2*(p+1)
            P = D/2  # Number of vanishing moments
            N = P-1  # Dimension of nullspace of the matrix A            

            lp, hp = daubfilt(D)
            
            for k in range(1, N+1):  #FIXME: use P
                o = ortho(k,lp);              
                if k==0:
                    o = 1-o
                err = abs(o)
 
                #assert abs(err) <= epsilon, 'Error == %e' %err
                assert allclose(err, 0), 'Error == %e' %err