| [mmdatatype] [Up] [mmset2mat] | Image Information and Manipulation |
Return tuple with array of coord and array of values
def mmmat2set(A):
from Numeric import take, ravel, nonzero, transpose, NewAxis
if len(A.shape) == 1: A = A[NewAxis,:]
offsets = nonzero(ravel(A) - mmlimits(A)[0])
if len(offsets) == 0: return ([],[])
(h,w) = A.shape
x = range(2)
x[0] = offsets/w - (h-1)/2
x[1] = offsets%w - (w-1)/2
x = transpose(x)
CV = x,take(ravel(A),offsets)
return CV
| [mmdatatype] [Up] [mmset2mat] | |
| Copyright (c) 2003, Roberto A. Lotufo, UNICAMP-University of Campinas; Rubens C. Machado, CenPRA-Renato Archer Research Center. |