[mmmat2set] [Up] [mmreadgray] Image Information and Manipulation

mmset2mat
Converts image representation from set to matrix

Synopsis

M = mmset2mat( A )

Implemented in Python.

Input

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

Tuple with array of coord and array of values

Output

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

Image in matrix format.

Return tuple with array of coord and array of values

Source Code

def mmset2mat(A):
    from MLab import max
    from Numeric import put, ones, ravel, shape, NewAxis, array
    (x,v)=A
    if len(x) == 0:  return array([0]).astype(v.typecode())
    if len(x.shape) == 1: x = x[NewAxis,:]
    dh,dw = max(abs(x))
    h,w = (2*dh)+1, (2*dw)+1 
    M=ones((h,w)) * mmlimits(v)[0]
    offset = x[:,0] * w + x[:,1] + (dh*w + dw)
    put(M,offset,v)
    M = M.astype(v.typecode())
    return M
    
[mmmat2set] [Up] [mmreadgray] Python