Function iadctmatrix

namespace:ia636
page:iadctmatrix

Synopse

Kernel matrix for the DCT Transform.

  • A = iadctmatrix(N)
    • A: Image.
    • N: Double.
1. from numpy import *
2. 
3. def iadctmatrix(N):
4.     from iameshgrid import iameshgrid
5.     x, u = iameshgrid(range(N), range(N)) # (u,x)
6.     alpha = ones((N,N)) * sqrt(2./N)
7.     alpha[0,:] = sqrt(1./N) # alpha(u,x)
8.     A = alpha * cos((2*x+1)*u*pi / (2.*N)) # Cn(u,x)
9.     return A

Examples

Example 1

1. from ia636 import iadctmatrix, ianormalize
2. 
3. A = iadctmatrix(128)
4. adshow(ianormalize(A,[0,255]))

Example 2

1. A = iadctmatrix(4)
2. print array2string(A, precision=4, suppress_small=1)
3. B = dot(A,transpose(A))
4. print array2string(B, precision=4, suppress_small=1)
[[ 0.5     0.5     0.5     0.5   ]
 [ 0.6533  0.2706 -0.2706 -0.6533]
 [ 0.5    -0.5    -0.5     0.5   ]
 [ 0.2706 -0.6533  0.6533 -0.2706]]
[[ 1.  0. -0. -0.]
 [ 0.  1.  0.  0.]
 [-0.  0.  1.  0.]
 [-0.  0.  0.  1.]]