[iahadamardmatrix] [Up] [iaidct] Image Transformation

iahwt
Haar Wavelet Transform.

Synopsis

F = iahwt( 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 = iaread('cameraman.pgm')

              
>>> iashow(f)
(256, 256) Min= 0 Max= 251 Mean=137.066 Std=87.20
>>> F = iahwt(f)

              
>>> iashow(Numeric.log(abs(F)+1))
(256, 256) Min= 0.0 Max= 10.4656680176 Mean=1.715 Std=1.31
f Numeric.log(abs(F)+1)

Source Code

def iahwt(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
    A = iahaarmatrix(m)
    if A==-1: return -1
    if (n == 1):
        F = matrixmultiply(A, f)
    else:
        B = iahaarmatrix(n)
        if B==-1: return -1
        F = matrixmultiply(matrixmultiply(A, f), transpose(B))
    return F
    
[iahadamardmatrix] [Up] [iaidct] http://www.python.org