[iahaarmatrix] [Up] [iahadamardmatrix] Image Transformation

iahadamard
Hadamard Transform.

Synopsis

F = iahadamard( 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 = iahadamard(f)

              
>>> iashow(Numeric.log(abs(F)+1))
(256, 256) Min= 0.00389864041566 Max= 10.4656680176 Mean=2.649 Std=1.10
f Numeric.log(abs(F)+1)

Source Code

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