[iaptrans] [Up] [iadctmatrix] Image Transformation

iadct
Discrete Cossine Transform.

Synopsis

F = iadct( f )

Implemented in Python.

Input

f Image. Gray-scale (uint8 or uint16) or binary image (logical).

Output

F Image. Gray-scale (uint8 or uint16) or binary image (logical).

Examples

>>> import Numeric

              
>>> f = 255 * iacircle([256,256], 10, [129,129])

              
>>> iashow(f)
(256, 256) Min= 0 Max= 255 Mean=1.233 Std=17.69
>>> F = iadct(f)

              
>>> iashow(Numeric.log(abs(F)+1))
(256, 256) Min= 8.42130923981e-005 Max= 6.43313745608 Mean=1.188 Std=0.89
f Numeric.log(abs(F)+1)

Source Code

def iadct(f):
    from Numeric import asarray, Float64, NewAxis, matrixmultiply, transpose
    f = asarray(f).astype(Float64)
    if len(f.shape) == 1: f = f[:,NewAxis]
    (m, n) = f.shape
    if (n == 1):
        A = iadctmatrix(m)
        F = matrixmultiply(A, f)
    else:
        A=iadctmatrix(m)
        B=iadctmatrix(n)
        F = matrixmultiply(matrixmultiply(A, f), transpose(B))
    return F
    
[iaptrans] [Up] [iadctmatrix] http://www.python.org